Play long sample across loop

Hi @zabladowski :slight_smile: Not sure where in the forum that particular example might be - finding things can be a bit challenging sometimes!

You only really need to determine slices based on the sample duration if you prefer to track lengths of time for a specific reason. Otherwise, Sonic Pi has simple ways of slicing samples into chunks - as @holz mentions, the slice: opt is a simple way to play a chunk of the sample. You can divide the whole sample up into evenly sized slices with num_slices:, and pick which slice each time around a loop to play with slice:.

If you’re only interested in playing successive slices each time, rather than jumbling them up, then you’d just use something like sample ..., slice: tick to play each next slice every time around the loop.

There are other ways you can tell Sonic Pi to slice up a sample - see the following for a few more details: