[chuck-users] Communicating with external processes

Joel Matthys jwmatthys at yahoo.com
Wed Jan 21 02:47:33 EST 2009


Hello Andrew. I've just been working on a similar project that sends OSC 
from Processing. You can send and receive multiple values with each message.

Unfortunately, this doesn't work as midiEvent and oscEvent do not have 
boolean values:

midiEvent || oscEvent => now; // wait for whichever comes first


This is how I resolved it:

// --------------------------------------------
OscRecv orec;
6449 => orec.port;
orec.listen();

orec.event("/foo, i f f f") @=> OscEvent fooData;
orec.event("/bar, i f f f") @=> OscEvent barData;

while(true)
{
    if (fooData.nextMsg() != 0)
    {
        fooData.getInt() => int w;
        fooData.getFloat() => float p;
        fooData.getFloat() => float f;
        fooData.getFloat() => float a;
        spork ~ foo(w,p,f,a);
    }    
    if (barData.nextMsg() != 0)
    {
        barData.getInt() = int w;
        barData.getFloat() => float p;
        barData.getFloat() => float f;
        barData.getFloat() => float a;
        spork ~ bar(w,p,f,a);
    }    
    5::ms => now;
}
// --------------END----------------------




More information about the chuck-users mailing list