Code Error on my first try

Just started having a play with this brilliant application, and the first small effort throws an error on a sleep statement every single time.

Runtime Error: [buffer 0, line 18] - NoMethodError
Thread death!
undefined method `Play’ for Runtime:SonicPiLang

workspace_zero:18:in `block (2 levels) in __spider_eval’

C:/Users/adme713/Downloads/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:781:in `eval’

C:/Users/adme713/Downloads/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:781:in `block (2 levels) in __spider_eval’

C:/Users/adme713/Downloads/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:1042:in `block (2 levels) in __in_thread’

The error makes no sense…

What did you have in the workspace? maybe you wrote “Play” with a capital P?

Hey @Jon, Welcome!
Lenz is indeed correct.
Sonic Pi (as with many other programming languages/environments) is particular about the case of the words/letters you use. Commands in Sonic Pi are all lowercase.
Thanks for the info about the error message by the way, we can always use feedback like that in case it’s worth making adjustments :+1:

Lenz, you da MAN !! That was it, capital P… stupid rookie mistake…:frowning:

Have to get the samples right but it doesn’t sound 1/2 bad for a 3 minute effort.

That was my problem, upper case “P”… stupid rookie mistake…:frowning:

BTW, is there a way of attaching RB files as examples to posts ?

Jon

The most common way so far to share code here has been to do something like create a ‘gist’ at https://gist.github.com/, (looking at that link currently it seems like github is in the process of updating it, if you are not signed in to github - but otherwise it should work) Seems to be fine now… Or some other external site that lets you create a text snippet like pastebin, and then paste a link from that in your post here.
You can also create an in-line code snippet here, by placing three back ticks (`) together one one line, then your code on the next few lines, and finishing off with another line of three back ticks. That gives the code a nice syntax highlighting effect.

For big files, as Ethan says, use github… but for examples in posts, etc, the
3 backtick method is much more direct…

use_debug false
use_bpm 130

master = (ramp *range(0.5, 1, 0.1))
kick_volume = 1
bass_volume = 1
revbass_volume = 1
snare_volume = 0.5
hats_volume = 0.5
open_hats_volume = 1
synth_volume = 1
pad_volume = 1
beep_volume = 0.5

kick_cutoffs = range(35, 95, 1).mirror # A LFO for the poor
live_loop :kick do
  if (spread 1, 4).tick then # 4-on-the-floor
    sample :bd_tek, amp: master.look * kick_volume,
      cutoff: kick_cutoffs.look
  end
  sleep 0.25 # 16th note heartbeat
end

define :snare do |amp|
  sample :sn_dolf, amp: amp, start: 0.15, finish: 0.35, rate: 0.7
end

live_loop :snares do
  sleep 1
  snare 1 * master.tick * snare_volume
  sleep 1
end

live_loop :snare_break do
  sync :snares
  sleep 15.75
  with_fx :reverb, mix: 0.3, room: 0.8 do
    with_fx :echo, mix: 0.4, decay: 12, phase: 0.75 do
      snare 0.5 * master.tick * snare_volume
    end
  end
  sleep 0.25
end

live_loop :hats do
  sync :kick
  if (spread 3, 8).tick then
    # (spread 3, 8) produces this pattern: * _ _ * _ _ * _
    with_fx :rhpf, cutoff: 125, res: 0.8 do
      with_synth :pnoise do
        play :d1, amp: hats_volume * master.tick,
          attack: 0.05, decay: 0.08, release: 0.1
      end
    end
  end
  sleep 0.25
end

live_loop :noise_hats do
  sync :kick
  # Create hi-hats by slicing continuous noise
  with_fx :slicer, mix: 1, phase: 0.25, pulse_width: 0.1 do
    with_fx :hpf, cutoff: 130 do
      with_synth :noise do
        play :d1, decay: 1, amp: master.tick * hats_volume
      end
    end
  end
  sleep 1
end

open_hats_cutoffs = range(120, 130, 0.5).mirror
live_loop :open_hats do
  sync :kick
  with_fx :echo, amp: open_hats_volume * master.look,
  mix: 0.4, decay: 4, phase: 0.75 do
    with_fx :hpf, cutoff: open_hats_cutoffs.tick do
      with_fx :reverb, mix: 0.4, room: 0.8 do
        sleep 0.5
        sample :drum_cymbal_open, start: 0.2, finish: 0.3, amp: 0.5
        sleep 0.5
      end
    end
  end
end

bassline_rhythm = (ring 1, 0, 0, 0, 1, 0, 0, 0,
                   1, 0, 0.5, 0, 1, 0, 0.5, 0)
bassline_notes = (stretch [:d1] * 12 + [:f1, :f1, :a1, :f1], 8)
live_loop :bassline do
  sync :kick
  with_synth :fm do
    play bassline_notes.look,
      amp: master.look * bassline_rhythm.tick * bass_volume,
      attack: 0.03, divisor: 1, depth: 2.5
  end
  sleep 0.25
end

live_loop :revbassline do
  sync :snares
  sleep 7.5
  with_fx :pan, pan: -0.5 do
    with_synth :fm do
      play :d1, amp: bass_volume * master.tick,
        attack: 0.5, divisor: 0.5, depth: 6
    end
  end
  sleep 0.5
end

dchord = chord(:d2, :minor, num_octaves: 3)
synth_cutoffs = range(60, 100, 0.5).mirror
synth_rhythm = (ring 1.5, 1.5, 1)
synth_transpositions = (stretch 0, 36) + (stretch -12, 6) + (stretch 12, 6)
synth_phases = (stretch 0.75, 15) + [0.25]
synth_pans = (ring -0.5, 0.5)
live_loop :synth do
  sync :kick
  ch = invert_chord(dchord, rand_i(3))
  sleep synth_rhythm.tick
  with_fx :echo, amp: synth_volume * master.look, mix: 0.3,
  decay: 8, phase: synth_phases.look do
    with_fx :pan, pan: synth_pans.look do
      with_fx :reverb, room: 0.7, damp: 0.8 do
        with_synth_defaults attack: 0.05, release: 0.3 do
          with_transpose synth_transpositions.look do
            with_synth :sine do
              play_chord ch
            end
            cutoff = synth_cutoffs.look
            with_fx :ixi_techno, cutoff_min: cutoff,
            cutoff_max: cutoff - 30, phase: 1, res: 0.3 do
              with_synth :dsaw do
                play_chord ch, attack: 0.1
              end
            end
          end
        end
      end
    end
  end
end

dubpad_cutoffs = range(70, 100, 5).mirror
dubpad_phases = (ring 8, 8, 8, 0.5)
dubpad_mixes = (ring 0.5, 0.5, 0.5, 0)
define :dubpad do |ch, amp|
  with_fx :echo, amp: amp, mix: dubpad_mixes.look,
  phase: 1.5, decay: 2 do
    with_fx :reverb, room: 0.8 do
      with_fx :ixi_techno, phase: dubpad_phases.tick, cutoff_min: 70 do
        with_synth :tb303 do
          with_synth_defaults attack: 0.1, release: 8,
          cutoff: dubpad_cutoffs.look, res: 0.5 do
            play_chord ch
            play_chord ch.map { |n| n + 0.3 } # Detune chord
          end
        end
      end
    end
  end
end

live_loop :pad do
  sync :snares
  dubpad dchord, master.tick * pad_volume
  sleep 16
end

beep_notes = (ring :d2, :d2, :f2, :e2, :d3, :g2)
live_loop :beeps do
  sync :kick
  sleep 0.5
  with_fx :distortion do
    with_synth :beep do
      play beep_notes.tick, amp: beep_volume * master.look,
        decay: 0.2, release: 0.1
    end
  end
  sleep 0.5
end

live_loop :kickSetter do
  set :kicks, (ring
               (spread 1.375,8).take_last(4),
               (spread 1.375,8).drop_last(4),
               (spread 2.75,16),
               ).tick
  sleep 4
end

Eli…

1 Like