how to create launchpad light effects with chuck

Nikolaus Gradwohl2014-02-26T05:28:26+01:00

Most launchpad videos feature cool effects running on a launchpad. There are several tutorials on how to make such effects using ableton live. But since my launchpad is connected to a linux box this doesn´t help me much. So I wrote a short chuck script that reacts to the midi events sent by the launchpad and creates an arpeggiator effect to light up the leds. The color can be influenced by changing the velocity.

This script works with a launchpad S or a launchpad mini.

here is a short video that shows my script in action

launchpad lightshow

I create a midi in and out. My launchpad is the third midi interface on my box - adjust the value used with open to match your setup.

every time a midi event is received i check if it is a note on event and which block of rows it belongs to. For every effect block I start a new thread using spork. The function that runs in the threads creates new midi events and sends them to the launchpad.

MidiIn min;
MidiOut mout;
MidiMsg msg;

min.open(3);
mout.open(3);

[-16, -15, 1, 17, 16, 15, -1, -17 ] @=> int scale[];
[-16, -32, -48 ] @=> int scale2[];


while(true) {
    min => now;
    min.recv(msg);
    if ( msg.data1 == 144 && msg.data3 > 0 ) {
         if ( msg.data2 < 63 ) {
            spork ~ blink2( msg );
        } else if ( msg.data2 < 112 ) {
            spork ~ blink( msg );
        } else {
            spork ~ blink3( msg );
        }
    }
}
fun void blink( MidiMsg m ) {
    MidiMsg msg2;
    MidiMsg cpy;
    m.data1=>cpy.data1;
    m.data2=>cpy.data2;
    m.data3=>cpy.data3;

    60 => msg2.data3;
    144 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
    100::ms => now;
    63 => msg2.data3;
    for( 0 => int i; i < scale.cap(); i++) {
        cpy.data2 + scale[i] => msg2.data2;
        mout.send( msg2 );
30::ms => now;

    }
    100::ms => now;

    128 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
    for( 0 => int i; i < scale.cap(); i++) {
        cpy.data2 + scale[i] => msg2.data2;
        mout.send( msg2 );
        mout.send( msg2 );
    }
}

fun void blink2( MidiMsg m ) {
    MidiMsg msg2;
    MidiMsg cpy;
    m.data1=>cpy.data1;
    m.data2=>cpy.data2;
    m.data3=>cpy.data3;

    15 => msg2.data3;
    144 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
    100::ms => now;
    15 => msg2.data3;
    for( 0 => int i; i < scale2.cap(); i++) {
        cpy.data2 + scale2[i] => msg2.data2;
        mout.send( msg2 );
        30::ms => now;
    }
    100::ms => now;

    128 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
    for( 0 => int i; i < scale2.cap(); i++) {
        cpy.data2 + scale2[i] => msg2.data2;
        mout.send( msg2 );
    }

}

fun void blink3( MidiMsg m ) {
    MidiMsg msg2;
    MidiMsg cpy;
    m.data1=>cpy.data1;
    m.data2=>cpy.data2;
    m.data3=>cpy.data3;

    15 => msg2.data3;
    144 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
    100::ms => now;
    128 => msg2.data1;
    cpy.data2 => msg2.data2;
    mout.send( msg2 );
}
Tweet This! submit to reddit Digg!   Tags: | no comments | no trackbacks

See also:

Sonic Pi Launchpad lightshow
Tale of a trs-midi-cable
volca ardour3 jam
launchpad mini to play push like scales using puredata
Chuck iControl Projectpage

Trackbacks

Comments

Leave a response

Leave a comment