I’m pretty sure that I’ve already seen the solution in this forum in the past but I failed to find it again.
I’ve a long spoken word sample. I want to play it in a way that each times in enters the loop, it plays the next slice of (I want to apply different effects on the chunk). I remember having seen a sample code where the slice of the chunk to play was determined by some computation logic based on the sample duration or something like that.
Hi @zabladowski 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: