home/ atoms/ sonic-pi-sample-slicing

Chopping a sample into equal slices and playing them in random order creates beat-slicing effects

A sample can be divided into n equal slices by computing start/finish as multiples of 1/n. start: idx/n and finish: (idx+1)/n selects one slice. sample_duration with matching start:/finish: gives the exact sleep time for that slice. Choosing a random idx with rand_i(n) in a live_loop creates a continuously randomly-ordered beat — the code equivalent of hardware beat-slicing samplers.

Examples

live_loop :slicer do n = 8 s = line(0, 1, steps: n).choose f = s + (1.0 / n) sample :loop_amen, start: s, finish: f sleep sample_duration(:loop_amen, start: s, finish: f) end

Assessment

Implement an 8-slice beat slicer for :loop_amen. Explain how changing from 8 to 16 slices affects the groove character.

“Chopping it into 8 slices gives us B) - notice that we've given each slice a different colour”
corpus · sonic-pi-built-in-tutorial · chunk 44