How do you guys chop samples?

Hi there, still new to Sonic Pi and chopping samples.

I downloaded this Sample from Splice Sounds, using Ableton I was able to cut the reminder of the sample in order to make it a perfect loop at 100bpm (4 bars).

Works fine in Ableton, however when chopping it in Sonic Pi I don’t get an evenly chopped slice of the sample… I was expecting to divide the sample (4 bars long) in 4 sections of 1 bar (4 beat) each one.

This is my approach to chopping samples:

live_loop :example do
sample x, num_slices: 4, slice: 0
sleep 4

The result should be 1 bar that loops perfectly, but instead I get a loop that overlaps because it does not get chopped evenly.

How do you guys chop your samples?

Hello @andresurdaneta :slightly_smiling_face:
Do you wish to have a BPM of 100 for your composition? If so, and you aren’t already with some code not posted here, you’ll need to add something to your code (perhaps at the top of your buffer) like this: use_bpm 100. (See the Lang section in the Help docs for more detail - also with_bpm for scoping a BPM to a specific code block)

Hi @andresurdaneta,

with your code you only play the first quarter of the sample and then pause for some time (depending on its length). Additionally the sample is probably not in sync with your bpm as @ethancrawford suggests (if your sample originally plays at 60 bpm and is 4 beats long then you will hear the first slice and then 3 beats of silences before it plays again).

Assuming 1. I have understood the problem and 2. the sample is already a proper loop, you might want to try the following (with :loop_amen as example):

live_loop :example do
  sample :loop_amen, beat_stretch: 2, num_slices: 4, slice: (ring 0, 1 ,2, 3).tick
  sleep 0.5

Of course you might want to reorganise the slices or leave some out:

live_loop :example do
  sample :loop_amen, beat_stretch: 2, num_slices: 4, slice: (ring 0, 2 ,0, 3).tick
  sleep 0.5

Or you want to hand it over to SP which slice to play when:

live_loop :example do
  sample :loop_amen, beat_stretch: 2, num_slices: 4, slice: pick
  sleep 0.5

Hope that helps.

1 Like

Another option to play just a specific slice of a sample is to use the start: and finish: opts which take a number between 0 and 1.

For example to play the first half of a sample:

sample :loop_amen, start: 0, finish: 0.5

Or to play the last quarter:

sample :loop_amen, start: 0.75 finish: 1

How about the last quarter in reverse:

sample :loop_amen, start: 1 finish: 0.75

This can also be combined with the num_slices: approach explained above. How about the first of 4 evenly sliced chunks taken from the last half of the sample:

sample :loop_amen, start: 0.5, finish: 1, num_slices: 4, slice: 0

Finally, another option to explore with respect to slicing up samples is the onset: option which uses audio analysis techniques to guess where the sample should be best sliced. You therefore don’t get n evenly measured slices, rather just some number of onsets which typically get cut at the high energy points in the sample (such as a drum hit):

sample :loop_amen, onset: 0