Some help needed with understanding the grid and 'sleep' function

Hope it is a right place to ask this question.

I am struggling to replicate the beats that I for example make using Ableton grid. In this particular case 16/16 grid.
For example, how would we code a loop like this:
| K - - - | C - - K | K - K - | C - - -

where we have Kick and Clap on 16/16 grid.

I was struggling to recreate it in Sonic Pi, since I am not sure what values to pass to ‘sleep’ function after each sound.

Also does ‘sleep’ only starts after the Kick/Clap sound finishes? Not sure, the documentation is not clear about it either.


Hello @magnetic_pole - welcome to in_thread :grinning:
Almost the right place! the ‘Support, Help & Resources’ category is the ideal place for questions such as this - but at the end of the day, it can always be shifted around if necessary. (I’ve taken the liberty of transferring it to that category :slight_smile: )

To answer and address your last question and confusion around sleep first: if you want to have, say, 1 bar divided into 16 quarter beats, then you would have a sleep of 0.25 beats between every drum sample.

Triggering a sample does not in itself cause any delays while the sample is playing; it merely sends an instruction to the sound engine to start playing, and continues on immediately with the next Sonic Pi code. So, if we have the following:

sample :misc_burp
sleep 1

The sample will start playing and the code will immediately sleep for 1 beat :slight_smile:

Regarding making beat patterns in general - how much of Sonic Pi have you explored so far? - there’s several ways to do it. You can play multiple drum types in separate live_loops (separate live_loops being discussed in for example, if you haven’t already read the related tutorial chapter), or all drums in a single live_loop.

There are many interesting topics here on the forum about creating beat patterns - in case you are interested, here’s a few to get you started:

…No doubt there are others hidden away elsewhere. You can probably find more by searching the forum for something like ‘beats pattern’ or ‘drums pattern’ :+1:

Having said that, if none of those posts are quite as helpful as you would hope, and you’re still stuck afterwards, you’re absolutely welcome to come back and ask for further advice :slight_smile:

Hi Ethan,

thanks for answering, I am just starting (although I was making music for almost 2 decades), however I am really thinking in Ableton grids way etc, so it is a bit hard to translate it into a more abstract way of Sonic Pi to fully express myself and what I would like it to sound like, I will go though the links, particularly General Purpose Drumkit seems to be the closest to what I was looking for. Thanks again, will get back if I struggle :wink:


1 Like