Splice and Stutter

Splice and StutterToday on The Csound Blog, we’re going to learn how to build a loop-based sampler out of common household ingredients.

Listen: mp3

Download: splice_and_stutter.csdBT Sample Pack (13.2 MB)

Here’s a brief rundown of today’s example. A drum loop is loaded into an f-table with the instrument LoadSample. The instrument SampleEngine plays back selective parts of the loop. Instruments Basic, Stutter and Random are interface instruments that simplify the process of triggering samples.

The LoadSample instrument loads a sample into an f-table, while storing information about the sample into an ad hoc data structure created from chn busses. Here isn’t the place to go into detail. I will say that it is akin to a C struct, and stores the file name, sample rate, length of file (in samples), the tempo, and the number of beats (quarter notes) in the loop. All the user-defined opcodes are support opcodes for the data structure.

SampleEngine is the heart of this piece. It works by triggering discreet notes from within the loop, with the loop offset being determined by input it receives via p-field 7. The offset unit is in beats. Let’s say the loop is 16 beats long. A passed value of 0 plays the first quarter note. A value of 1 plays the second quarter note of the loop, etc.

This instrument is designed to be played by other instruments, rather than being triggered directly by a score i-event. That is…

Instead of having multiple samplers that do various things, I created a single complex sampler engine that is capable of a wider range of tricks. The problem with complex instruments in Csound is that writing score events can be cumbersome to write and certainly hard to read, especially when dealing with several parameters. This is where the interface instruments come into play.

The interface instruments Basic, Stutter and Random help us tame the complexity of SampleEngine by reducing the number of p-fields needed by the score, and by defining clear behaviors.  Basic is a no thrills controller that simply triggers part of the loop. Stutter, well, stutters. Random randomly picks a beat and plays it.

A greatly added benefit to this approach is that the score is much easier to read. Instead of trying to figure out if a particular i-event stutters or not by scanning a row of numbers, one can just casually look at the name of the instrument used. To put it another way, does this stutter?

i 5 7 1 0.25 0.5 100 12 0.083 1 0

How about this?

i $Stutter 7 1 0.25 0.5 100 12 [1 / 12]

There are a lots of ins and outs to today’s example. And I admit, I skipped over most of them. If there is a particular issue or issues you wish for me to expand on, comment below, and I’ll make it a priority to blog about it in the future.

This sampler is a derivitive work based on an instrument co-developed by Jean-Luc Sinclair (aka Jean-Luc Cohen) and myself back in 2006. The loop in today’s example is by BT (aka Brian Transeau), released under a Creative Commons attribution license, and released as part of the OLPC Sample Library. You can obtain this sample and others here. (13.2 MB) You will need the loop “105 Blanketed Lama.wav” in order to run the csd file.

Update: There is an issue with the CSD file not running on Windows Windows Me (or earlier). There is now a fix. Download the new splice_and_stutter.csd, and see line 269 for details. This only applies to users of Windows Windows Me (or earlier versions).

Thanks to everyone on the Csound Mailing List who helped straighten this out.

Personal Log Stardate 60278.1

Csound Instr

I’ve recently started the painstaking process of compiling all of my compositions into one cohesive online portfolio. Already, I’ve discovered I’ve lost some older works. Oops! The butterflies are nibbling at my stomach as I type. My hope is that some of the people I’ve collaborated with in the past have copies. There is always the possibility that one or two pieces exist in an archive at CalArts. But I’m going to have to face the reality that some of my works are forever lost…

The blunt of the project should take me about two weeks. After which, I will slowly add to the collection. I have a few papers and tutorials I’ve written I will eventually include, though the priority for now is the music. I want to note that I’m re-releasing most of these works under a Creative Commons license. I subscribe to the philosophy that putting too many restraints on art can kill the art. Creative Commons allows me to free my music so that it might someday find an audience, and hopefully inspire derivative works.