Tone plays when sample plays?

Hello World!
Super new user, out of the box yesterday. I’m having an issue where when I loop a sample I get a tone every time it plays? This is all I’m running…

define :thing do
sample :loop_breakbeat, beat_stretch: 2
end

live_loop :loop do
play thing
sleep 2
end

The tone doesn’t play when it’s called outside a loop. I’m using headphones if that’s going to make a difference? Any help would be greatly appreciated.

Hi there welcome to to the Sonic Pi community :slight_smile:

Your code is almost right…

The issue you’re having is in the line:

play thing

Whilst your code reads well as an English sentence, the computer doesn’t follow it in that way. The function play is for triggering the internal synths and therefore needs to know which note to play. As you’re not triggering the internal synthesisers (you’re using the internal sampler) you don’t need to call play at all. Just in case it’s useful, valid uses of play are:

play 70
play :e3
play (chord :e3, :minor)

In your code you’ve defined your own function called thing. To call your function, you just need to write thing:

define :thing do
  sample :loop_breakbeat, beat_stretch: 2
end

live_loop :loop do thing
  sleep 2
end

Hope that this helps!

You’re a star Sam! Thanks for the welcome and help, must say I wasn’t expecting the man himself to reply, and in record time too! Looking forward to starting a journey ;]

2 Likes