Introducing Slipmat for Java and Csound

Yesterday, I released the first public version of Slipmat, a Java-based modular computer music library built on top of the Csound API. You can download it at Sourceforge.

Let me back up a bit…

Ever since I started Csounding about a decade ago, I’ve heard people refer to the syntax of the Csound language as being very similar to that of Assembly on numerous occasions. I certainly see their point. Let’s face it, Csound is a Frankenstein of language, stitched together with duct tape and bubble gum. And like Frankenstein, it is both powerful, yet scary to those who judge it solely on its facade. Those who turn a blind eye to Csound’s frightening nature and learn to understand it for what it is are rewarded with an amazingly expressive computer music environment. Unfortunately, most people equate their first experience with ladling hot soup onto their laps. Did I mention Csound is afraid of fire?

Continuing with the Frankenstein metaphor a little longer, Slipmat is a Java abstraction layer that attempts to tame the monster. To teach it some manners and civility. If all goes well, Csound will be putting on the ritz in no time.

Let’s take a look at a simple Slipmat java program (included with the download.) The following plays every note in a 12 note octave between 440 and 880:

import com.thumbuki.slipmat.*;
import com.thumbuki.slipmat.module.*;

public class SimpleExample {
    public static void main(String[] args) {
        SynthRack synthRack = new SynthRack(false);
        SinePerc sinePerc = new SinePerc();
        Output output = new Output();

        synthRack.addModule(sinePerc);
        synthRack.addModule(output);
        output.setInput(sinePerc.getOutput());
        
        for (int i = 0; i <= 12; i++)             sinePerc.playNote(i * 0.25, 0.9, 440 * Math.pow(2, i / 12.0));         synthRack.startCsound();                  try {             Thread.sleep(4000); /* Keep java running for four seconds */         }         catch(Exception ex) { }     } }

If we think of Slipmat as a high-level abstraction of Csound, which it is, then what happens behind the scenes is that Slipmat "compiles" Csound code, and then this code is fed to the Csound engine. This is sorta how Java produces bytecode that is executed by a Java Virtual Machine. The following is the code that is produced by the previous example:

<CsoundSynthesizer>
<CsOptions>
csound -d -A -odevaudio null.csd
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

0dbfs = 1.0

gitable1 ftgen 1, 0, 8192, 10, 1.0

chn_a "chna0", 3

instr 1
aclear = 0.0
chnset aclear, "chna0"
endin

instr 2
a1 oscil p4, p5, gitable1
aenv linseg 0, p3 * 0.05, 1, p3 * 0.95, 0
a1 = a1 * aenv
chnmix a1, "chna0"
endin

instr 3
a1 chnget "chna0"
outs a1, a1
endin

</CsInstruments>
<CsScore>
i 2 0.0 0.125 0.9 440.0
i 2 0.25 0.125 0.9 466.1637615180899
i 2 0.5 0.125 0.9 493.8833012561241
i 2 0.75 0.125 0.9 523.2511306011972
i 2 1.0 0.125 0.9 554.3652619537442
i 2 1.25 0.125 0.9 587.3295358348151
i 2 1.5 0.125 0.9 622.2539674441618
i 2 1.75 0.125 0.9 659.2551138257398
i 2 2.0 0.125 0.9 698.4564628660078
i 2 2.25 0.125 0.9 739.9888454232689
i 2 2.5 0.125 0.9 783.9908719634986
i 2 2.75 0.125 0.9 830.6093951598903
i 2 3.0 0.125 0.9 880.0
i 1 0 -1.0
i 3 0.0 -1.0

</CsScore>
</CsoundSynthesizer>

I know what you're thinking... What the hell am I looking at? Truth is, this code is not meant for human consumption. A person who regularly writes Csound code can write code that is more clear than this. Even then, compared to Java-Slipmat code, it can look like chicken scratch. Or my handwriting.

Since Slipmat is more or less a Java library built on top of the Java-Csound API, this means all of Java's and whistles are now available to use in conjunction with Csound. Want a reliable cross-platform GUI? Give swing a try. Want to integrate Processing with you Csound? You can. Want a tool that automagically hides all the grunt work from you, such as assigning instr numbers, tables, chn software busses, etc? More than anything else in life (personally speaking.)

I should warn you... Slipmat is currently pre-alpha. Which means everything is in a state of flux, and there isn't anything that resembles a specification at this point. Methods and classes are guaranteed to change drastically over the next few months. Tutorials on the way...

Maintenance Tomorrow

Just a quick heads up. Tomorrow, I’m doing maintenance work on this site. I don’t foresee any major problems, though I have seriously screwed things in the past. So if this site goes blank for a couple of days, then I made a bad. :)

Update: (March 30th, 2008) WordPress 2.5 installed. In the middle of upgrading the theme. Tag support may take a few days. Need to add links back to the sidebar.

Update: (March 31th, 2008) This site is starting to come back together. Put the links back in the sidebar, along with upgraded twitter and flickr support. The theme still needs work. Tags are currently on hold.

Csound Journal Issue 8

Csound Journal Cover Art

The 8th issue of the Csound Journal is hot off the press.

OLPC donates 8.5+ Gigs of Samples

One Laptop Per Child

The OLPC has donated 8.5+ gigs of samples to the children of the world, and us. This library is licensed under the Creative Commons Attribution License. So feel free to start remixing.

From the official press release:

Several prestigious groups of musicians have donated their sound libraries to One Laptop per Child (OLPC), a non-profit organization focused on providing educational tools to help children in developing countries “learn learning.” The XO laptop’s unique user interface and applications enable children to create and share music, drawings, video, personal diaries and other things they make online with family and friends worldwide.

Leading musicians, colleges and companies making their sound libraries freely available on the XO laptop are: The Berklee College of Music in Boston, Berklee Music Synthesis alumni – including electronic music superstar BT, the international Csound Developer community, M-Audio and Digidesign (parts of Avid Technology, Inc.), and the Open Path Music group.

I want thank Dr. Richard Boulanger for all the time and effort he put into collecting and assembling such a vast and wonderful resource.

Here are my donated samples in three different sampling rates: baby talk plus eurorack, serge and csound synth sounds

Step and Funny Talk for the OLPC

I spent my spare time last week developing two audio-based activity prototypes for the OLPC: Step and Funny Talk. The whole process was surprisingly quick and easy. I attribute this to Victor Lazzarini’s Csound Sugar GUI toolkit. I do a lot of Csound programming, but I’ve never actually done any GUI work for it. Using the toolkit was as simple as defining widgets and mapping them in Csound.

Step

OLPC Step Activity

Flickr photo be me

Step is the first activitiy I’m developing for the XO. It’s a straight forward eight note step sequencer with synth notes, snare and kick parts. So far, I’ve probably put in about 8 hours on this. Once a user has a pattern they like, they can render the loop to an audio file, which can then be loaded in other activities. It still needs a lot of work, especially the synth engine. Though you can still take a listen if you would like: StepDemo1.mp3.

Funny Talk

OLPC Funny Talk Activity

Flickr photo be me

This is my favorite of the two, as my inspiration for this activity comes from my childhood memories of the Yamaha VSS-30 keyboard. My friends and I used to spend hours playing with that keyboard. Often in a very juvenile manner. I figured if we had such a great time playing with our voices, then perhaps the target audience of the OLPC will as well. Here is “the sound of my voice” being processed with Funny Talk: FunnyTalkDemo1.mp3.

Csound and the OLPC

OLPC

Flickr photo by me

Since friday, I’ve been learning the ins and outs of my XO computer. I finally got to a point this morning where I can start writing csound-based activities for it.

Using the csndsugui toolkit, I slapped together a primitive step-sequencer in about five hours. It features: An 8-step pitch slider array, two oscillators for notes, AD envelope for amplitude, tempo control, volume control, 8-step kick row and an 8-step snare row. So while it might not do much at the moment, I can certainly see myself fixing it up to a point where it’ll be a fun musical toy in the near future. I’ll post a pic in a few days, once it shapes up a bit.