# Drums and bass loop (tips and comments appreciated)

**URL:** <https://in-thread.sonic-pi.net/t/drums-and-bass-loop-tips-and-comments-appreciated/5911>\
**Category:** Creations & Ideas\
**Created:** [August 31, 2021, 12:22am UTC](https://in-thread.sonic-pi.net/t/drums-and-bass-loop-tips-and-comments-appreciated/5911 "2021-08-31T00:22:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddimitrov](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/ddimitrov/32/2060_2.png) [@ddimitrov](https://in-thread.sonic-pi.net/u/ddimitrov)\
**Post date:** [August 31, 2021, 12:22am UTC](https://in-thread.sonic-pi.net/t/drums-and-bass-loop-tips-and-comments-appreciated/5911/1 "2021-08-31T00:22:13Z")

</div>

I had a bit of fun with Sonic PI ([work in progress here](https://gist.github.com/ddimtirov/6dd7f3147462f713daf249ef4222c7aa)), but I feel I may be doing it “the hard way” 🙂

Hre is a short list:

1. The “roll” function feels like something I shouldn’t have to do myself, but I couldn’t find an idiomatic way to achieve the same thing.
2. Also it feels weird to set the tempo to 480 bpm, to achieve something that sounds more like 120bpm. Is `sleep 1` supposed to be one beat or a full bar? Is there any way to specify a time signature and use notations like `full`, `half`, `dot`, etc? Or define a meter for a loop and then just write the sequencer of notes?
3. Is there any way to include external files / libraries without pasting them in a buffer?

I will appreciate review comments and tips, as well as pointers to articles/docs or interesting code that I can read.

P.S. I found [Sonic Pi Online Resources](https://in-thread.sonic-pi.net/t/sonic-pi-online-resources/17) - this would keep me busy for a while

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [August 31, 2021, 9:39am UTC](https://in-thread.sonic-pi.net/t/drums-and-bass-loop-tips-and-comments-appreciated/5911/2 "2021-08-31T09:39:27Z")

</div>

Hey @ddimitrov,

> [@ddimitrov](#):
>
> The “roll” function feels like something I shouldn’t have to do myself, but I couldn’t find an idiomatic way to achieve the same thing.

There isn’t a dedicated roll function, but the function that will probably be most useful for creating your own is `density`. (See details in the Lang section of the help panel). There are a handful of topics here on in\_thread I can see that relate to a similar question:

> [@New to Sonic pi so every little helps](https://in-thread.sonic-pi.net/t/new-to-sonic-pi-so-every-little-helps/3312):
>
> Hey Im looking to make rap, trap, grime, drill lofi and afrobeats type music. So far i’ve gone through the tutorials and have got a grasp of a lot of the language. I guess I want to know if there are any resources out or if you have any advice to get me going in the right direction. Cheers

> [@Stutter / beat repeat](https://in-thread.sonic-pi.net/t/stutter-beat-repeat/513):
>
> Hi, this is my first post and I’m also very new to live coding or even coding for that matter. I first stumbled upon Tidal Cycles and then Sonic Pi. I actually prefer Sonic Pi as it has many things implemented in more straightforward way. There is however a thing that I find Tidal is especially good at, and being a newb, I wonder how you would approach the same thing in Sonic Pi. The thing is about making beat repeats or stutter. In Tidal you simply multiply / divide chosen beat and bam. To b…

> [@How to do beat repeat](https://in-thread.sonic-pi.net/t/how-to-do-beat-repeat/4597):
>
> I’ve been wanting to do more IDM kinda music lately, got into ableton live, but drawing midi is boring and I’m super bad at playing drums on a midi controller or coming up with good patterns in the first place. So here comes sonic pi to the rescue! I came up with a pattern I like and will be sending it via midi to ableton to experiment with. But I wanted to se if I could do some beat repeat directly in sonic pi. I found a thread by @sub_repeat but I could not reply, maybe it’s locked or patreon…

(There might be others)…

> [@ddimitrov](#):
>
> Is `sleep 1` supposed to be one beat or a full bar?

The sleep function works with beats, so 1 beat.

> [@ddimitrov](#):
>
> Is there any way to specify a time signature and use notations like `full` , `half` , `dot` , etc? Or define a meter for a loop and then just write the sequencer of notes?

Not that I know of, you’d need to assign durations to variables yourself - eg:

```ruby
quaver = 0.5
crotchet = 1
dottedcrotchet = 1.5
minim = 2
semibreve = 4
minimquaver = 2.5

```

(Or whatever names you want to give them obviously).

> [@ddimitrov](#):
>
> Is there any way to include external files / libraries without pasting them in a buffer?

As far as external files, yes! What you are after is `run_file`. Libraries on the other hand, such as Ruby gems, are not officially supported - you can try referencing them in Sonic Pi code, but there’s no guarantee they will work…

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [August 31, 2021, 11:08am UTC](https://in-thread.sonic-pi.net/t/drums-and-bass-loop-tips-and-comments-appreciated/5911/3 "2021-08-31T11:08:07Z")

</div>

hi @,

Just concerning the name of note lengths, [Music Theory: Note Names, Rests & Dotted Notes - YouTube](https://youtu.be/168Y5HiYeFw), it seems that american and British have different names 🙂  
here is a little example [How to code this song on sonic PI - #5 by nlb](https://in-thread.sonic-pi.net/t/how-to-code-this-song-on-sonic-pi/4795/5)
