Why isn't the Hi hat loop working

can someone help? the hi hat loop isn’t working.

#Written by Sam Humphreys

#Setting BPM to 70
use_bpm 70

#Make variables for the drums
clap = "/Users/samhumphreys/Library/Mobile Documents/com~apple~CloudDocs/Logic Pro X/Music Plug-Ins/Cymatics/Cymatics - Drill Essential Drum Kit/Drum One Shots/Claps/Cymatics - Wake Clap.wav"
hi_hats = "/Users/samhumphreys/Library/Mobile Documents/com~apple~CloudDocs/Logic Pro X/Hi hat loop for Sonic Pi.wav"

live_loop :habanera do
  use_synth :fm
  use_transpose -12
  play (ring :d, :r, :r, :a, :f5, :r, :a, :r).tick
  sleep 0.25
end

with_fx :reverb do
  live_loop :space_light do
    with_fx :slicer, phase: 0.25 do
      synth :blade, note: :d, release: 8, cutoff: 100, amp: 2
    end
    sleep 8
  end
end

sleep 17

loop do
  sample clap
  sleep 2
end

loop do
  sample hi_hats
  sleep 8
end

Hi there!

From the tutorial:

The important thing to know about loops is that they act like black holes for code. Once the code enters a loop it can never leave until you press stop - it will just go round and round the loop forever. This means if you have code after the loop you will never hear it. For example, the cymbal after this loop will never play:

loop do
  play 50
  sleep 1
end

sample :drum_cymbal_open 

In other words, your program is stuck in the clap loop, and will never arrive at the hi_hats loop. That’s when one would use a live_loop or in_thread instead.

2 Likes

ahh yes I remember that now. thanks very much

1 Like

Yep, you’re welcome! :smiley:

Hi @Future

@d0lfyn has already answered.

May i suggest you to use the samples provided in sonic pi if you want us to test your code. Otherwise, as we don’t have your own samples, sonic pi will produce no sounds :slight_smile:

Something like that :

#Written by Sam Humphreys

#Setting BPM to 70
use_bpm 70

#Make variables for the drums
clap = "/Users/samhumphreys/Library/Mobile Documents/com~apple~CloudDocs/Logic Pro X/Music Plug-Ins/Cymatics/Cymatics - Drill Essential Drum Kit/Drum One Shots/Claps/Cymatics - Wake Clap.wav"
hi_hats = "/Users/samhumphreys/Library/Mobile Documents/com~apple~CloudDocs/Logic Pro X/Hi hat loop for Sonic Pi.wav"

live_loop :habanera do
  use_synth :fm
  use_transpose -12
  play (ring :d, :r, :r, :a, :f5, :r, :a, :r).tick
  sleep 0.25
end

with_fx :reverb do
  live_loop :space_light do
    with_fx :slicer, phase: 0.25 do
      synth :blade, note: :d, release: 8, cutoff: 100, amp: 2
    end
    sleep 8
  end
end

live_loop :clap do
  # sample clap
  sample :drum_tom_hi_hard
  sleep 2
end

live_loop :hihats do
  # sample hi_hats
  sample :drum_cymbal_open
  sleep 8
end

Cheers

1 Like