Slipmat Prototype & Processing

I experimenting combining the first Slipmat prototype (built with the Csound API) with Processing. Getting the two systems working together was fairly straight forward. Here’s the code that generated the video.

The following method from class Disc does two things when a disc collides with a border: change direction of the disc and trigger a slipmat event:

public void moveDisc() {
    x += xVelocity * SCALE_VELOCITY;
    y += yVelocity * SCALE_VELOCITY;

    if (x <= DISC_RADIUS || x >= width - 1 - DISC_RADIUS) {
        xVelocity *= -1;

    if (y <= DISC_RADIUS || y >= height - 1 - DISC_RADIUS) {
        yVelocity *= -1;

The method playNote() also belongs to class Disc, and is where the actual triggering of the Slipmat event occurs. The instances sp1 and sp2 are part of the Slipmat system. The “sp” is short for “sine percussion.”

public void playNote() {
    sp1.playNote(0.0, 0.35 * (1 - x / width), frequency);
    sp2.playNote(0.0, 0.35 * x / width, frequency);

Early Java Slipmat Prototype

Slipmat has been a pet project of mine for a few years now. The first working prototype was realized in Java. The code for this is up at sourceforge.

Originally, the idea was for slipmat to be a java interface layer that sits on top of Csound. Hence the slipmat metaphor. At one point, it became much too unwieldily and I had abandoned it. Until later when I picked up Python, and decided to give it another go. Python made things much easier all the way around, but I eventually abandoned that too, for reasons I’ll go into later.

Here is an excerpt from one of the original Java prototype examples:

public ControllerExample() {
    /* Create empty SynthRack */
    SynthRack synthRack = new SynthRack(false);
    /* Create modules */
    LinearSlide linearSlider = new LinearSlide();
    SynthBass bass = new SynthBass();
    Output output = new Output();

    /* Add modules to the SynthRack */

    /* Patch the SynthBass to the Output */

    /* Create a sequence */
    linearSlider.slide(1.0, 0.05, 2.0, bass.getOscillator1Detune());
    linearSlider.slide(1.125, 0.05, 1.5, bass.getOscillator1Detune());
    bass.playNote(0.0, 8.0, 0.5, 100);
    bass.playNote(2.5, 6.0, 0.25, 200);

    /* Set duration and press play */
    synthRack.setDuration((double) SCORE_DURATION);

The full code can be seen here. Once I get things sorted out at sourceforge, I’ll post the Python package there as well.

Slipmat Pre-Alpha 0.01.0 Released

Slipmat 0.01.0

I just released a new Slipmat package at sourceforge. This latest version comes with three new examples, including one that uses a basic Java GUI. Four out of the five examples are now pre-rendered as CSDs for convenience. There are also a handful of new synth Modules to play with.

The documentation has been improved, including better Javadoc support. The Javadocs are not pre-rendered as to keep the size of the release to a minimum, so you’ll have to generate them yourself. Many IDEs, including NetBeans and Eclipse, will generate them for you.

There is also the PseudoTutorial example that gives a broad overview of the design of Slipmat and how to use it.

And in case you’re wondering, Slipmat is “A Java-based modular computer music library built on top of the Csound API.”

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();

        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:

csound -d -A -odevaudio null.csd
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"

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

instr 3
a1 chnget "chna0"
outs a1, a1

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


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...