chuck icontrol

Nikolaus Gradwohl2008-05-22T18:04:00+00:00

I own a m-audio icontrol and some time ago i started to play with chuck a programming language for making electronic music. today i managed to link them together and use my icontrol to start and stop my chuck programms :-)

next thing i will try is to convert the values from the "endless"-knobs to floats and to pass messages to the sub programms

1 => int device;

MidiIn min;
MidiOut mout;
MidiMsg msg;

// open the device
if( !min.open( device ) ) me.exit();
if( !mout.open( device ) ) me.exit();
[0,0,0,0,0,0,0,0] @=> int on[];
[-1, -1, -1, -1, -1, -1, -1, -1] @=> int ids[];
["beep.ck", "sing.ck", "autoloop.ck", "", "", "", "", "" ] @=> string names[];
while ( true ) {
    min => now;

    // get the message(s)
    while( min.recv(msg) ) {
        // print out midi message
        <<< msg.data1, msg.data2, msg.data3 >>>;

        if ( msg.data1 == 176 && msg.data2 >= 64 && msg.data2 < 72 && msg.data3 == 127 ) {
            msg.data2 - 64 => int chan;
            if ( on[chan] == 1 ) {
                0 => on[chan];
                sendOff( chan );
                if (ids[chan] > 0) {
                    Machine.remove( ids[ chan ] )
                        -1 => ids[chan];
                    }
                } else {
                    1 => on[chan];
                    sendOn( chan );
                    if ( names[chan] != "" ) {
                        Machine.add( names[chan] ) => ids[chan];
                    }
                }
            }
            // send( msg.data1, msg.data2, msg.data3 );
        }
    }

    fun void sendOn( int chan ) {
    send( 176, 64 + chan , 127 );
    }

    fun void sendOff( int chan ) {
    send( 176, 64 + chan, 0 );
    }

    fun void send( int d1, int d2, int d3 ) {
        MidiMsg msg;
    d1 => msg.data1;
    d2 => msg.data2;
    d3 => msg.data3;
    mout.send( msg );
    }
Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

Chuck iControl Projectpage
osc sequencer in ruby
Processing OSC
sketch experiment 7 - osc events
music live-coding environments - my first impressions

Trackbacks

Comments

Leave a response

Leave a comment