Increasing drums BPM (sample)

Hey, sonic newbie here.

I have the following code:

notes_path = "~/work/sonic-pi/notes/"

use_bpm 60

live_loop :backing_track do
  path = notes_path + "c.wav"
  sample path, amp: 6
  sleep sample_duration(path)
end

live_loop :drums do
  use_bpm 90
  path = notes_path + "drums.wav"
  sample path, amp: 6
  sleep sample_duration(path)
end

In other words, I have backing track and drums. Drums recorded with BPM 60. I’m trying to play drums faster. I could re-record wav file, but I think it should be possible to play it faster with sonic somehow. Can’t figure out how though.

As you can see I am using “use_bpm 90”, but it has no effect. Drums are still playing at 60 bpm, the same bpm they were recorded.

Is there any way to specify new bpm for the sample, knowing its recording bpm? I can use “rate” option for sample, but seems like it’s not exactly what I’m looking for, because it’s increasing pitch, drums aren’t that good with increased pitch unfortunately.

Thanks for help!

Hi @sonic,

try the following (for the 2nd live loop):

live_loop :drums do
  use_bpm 90 # does not in itself change the samples rate
  path = notes_path + "drums.wav"
  sample path, amp: 6, beat_stretch: 4 # you might have to adjust the number of beats here ...
  sleep 4 # ... and here
end