Archive for June, 2009

Editing Drum Patterns in RjDj

Tuesday, June 23rd, 2009

Hi you real(ity) DJs out there.

We figured its time to start the composers blog that has been quietly lurking in the navigation sidebar of more.rjdj.me for a while now. So, where better to start than providing you with a little tutorial on some of the new reactive music making objects we have added to the rj-library lately. You can grab the files to follow this tutorial in this zip archive: drumpattern-tutorial.zip

So lets dive right in with a pretty useful graphical pattern managing object called g_pattern32. Here’s how it looks:

The g_pattern32 object

The g_pattern32 object

You need to pass a unique name for the pattern table as an argument when creating the g_pattern32 object. Here I called it "MYPATTERN", but you’re free to give it any name you want that isn’t used as a table or receiver name in your patch elsewhere.

g_pattern32 stores a sequence of 32 numbers, that you can read out by sending numbers from 0 to 31 into its first inlet. To change a step, just select it with the radio button below the pattern display and use the toggle, the slider or the number box to change its value.

The toggle will always toggle between zero and a maximum value that you can set via an optional second argument. The default is a maximum of 1. The slider and number box allow you to set the step to other values as well.

So if you want to store some on/off patterns, you can just use a g_pattern32 without a second argument, but to store midi pitch melodies with a range from 0 to 128, create it as [g_pattern32 PATTERN_NAME 128] or so.

You can set the whole pattern in one go by sending a list of 32 numbers to the right inlet of the object and you can also make the pattern report its current sequence to the right outlet as such a 32-item list by pressing the "dump" button. Every mouse action on the toggle, the slider or the number box will automatically do such a "dump" as well.

If you store the pattern list from the right outlet somewhere, like in a textfile or in a Pd message box, you can later restore it through the right inlet. The help-file for g_pattern32 shows an example for message-box saving in the "pd restore" subpatch.

One possible use of g_pattern32 is to drive it with a [c_multimetro] or some other beat-counter to read out each of the stored values in sequence, and then use these to drive a musical instrument like a simple sample player. This is shown in this patch:

Playing a bassdrum sequence with g_pattern32

Playing a bassdrum sequence with g_pattern32

Sample Kits

We will come back to the pattern object later, but lets detour a bit now and check out a useful way to load lots of soundfiles from a directoy into Pd-tables with [u_samplekit].

A samplekit in this context is a directory of samples that also contains a text file mapping sample filename names to numbers. The default name of this file is "index.txt". Each line here contains a sample filename (no spaces, please) and a number. For drumsounds it’s useful to follow the GM midi standard when selecting numbers.

Here’s an excerpt of an index.txt file describing a 909-drumkit:

909CX-31-SN3-2.wav    31
909CX-33-BD3-1.wav    33
909CX-35-BD1-2.wav    35
909CX-36-BD2-2.wav    36
909CX-37-RM-8.wav     37
909CX-38-SN1-2.wav    38
909CX-39-CP1-6.wav    39
...

After a kit is loaded you can look up the actual table names by sending a number to the [u_samplekit]’s first inlet. It will then send out the matching table name to its first outlet.

So if we send a number 36 to a [u_samplekit] primed with the 909-kit from above, it will send out the name of the table into which it has loaded the file "909CX-36-BD2-2.wav" to the first outlet. If you send a number that doesn’t have a connected table, nothing will be sent. So you can directly connect this outlet to any of rj’s mono sample players like [s_playtable] or [s_fplaytable]. Neat, huh!

Now lets combine this with our pattern editor. We have been using a g_pattern32 that toggles between 0 and 1 so far and used a [select 1] to convert any 1 to a symbol to send to the sample player.

Now with the u_samplekit kit-loader, we can directly input numbers. u_samplekit will translate it to a table name for us. So lets just change the range of a g_pattern32 to toggle between 0 and another number like 36 to play a bassdrum in the 909 kit from above. We remove the [select 1] and directly go into the sample player from u_samplekit. Here’s a screenshot of pattern-tut-03.pd

Using u_samplekit to load many samples

Using u_samplekit to load many samples

Without much effort we can now immediatly add more 909 drum sequences to the patch. In the next example I added two more [g_pattern32] objects. One toggles between 0 and 40, where 40 is the GM note number for snare sounds, and the other toggles 42, which is a closed hihat in the sample kit.

To keep the patch clean, I used two receiers: "$0-BEAT" gets the beat number, and "$0-DRUMHIT" is connected to the samplekit/sampleplayer combo almost like before. Almost because now I use 3 sample players neatly autocreated inside the [u_robinpoly 3 s_playtable] object.

Again here’s a screenshot:

Adding more sequences to play complex beats.

Adding more sequences to play complex beats.

All in all that should make handling and editing drum patterns quite easy. How easy is shown in the following video.

Editing drum patterns in RjDj/Pd from Frank Barknecht on Vimeo.

I hope you have a lot of fun with these new rj-objects. If you do a scene with them, why don’t you share it! Sharing on rjdj.me is easy, just go to rjdj.me/sharescene/ and upload it there!

RjDj Workshop at the Music Hack Day in London

Thursday, June 18th, 2009

The Music Hack Day is a fabulous initiative from Dave Haynes and James Darling, where geeks, hackers, music lovers and music companies with APIs and tools gather for two days to find new wonderful combinations and ideas. The event takes place at the Guardian Offices on July 11th and 12th.

RjDj will be there with a workshop on how to create reactive music and use data from the RjDj universe. If you’d like to join us, register on the Music Hack Day website, hurry up because tickets will be going fast we hear!