Hello all,
So, the following code sporks out two shreds to listen for two (for
now--I want to be using 14) OSC messages, put their int values into an
event and report back to the parent shred with the value and the
address. This is supposed to be a way to get around the fact that,
a) I seem to have to listen on a different port if the OSC messages
have the same type,
b) that I can't wait on multiple events and,
c) that I want all the values to control parameters in a single patch.
My OSC messages are being lobbed at Chuck via a Python script and
everything seems to be working fine on that end. I've even gotten
this to work using two chuck shreds that were manually sporked. At
any rate, this code runs fine for about two seconds and then dies in
either a segmentation fault or a bus error.
Any guesses?
---
// extend the Event class
class Bang extends Event {
string message;
int value;
}
// a generic osc listener shred
fun void oscListener( Bang b, int port, string osctype ) {
// create our OSC receiver
OscRecv recv;
port => recv.port;
recv.listen();
// create an address in the receiver, store in new variable
recv.event( osctype ) @=> OscEvent oe;
while( true ) {
// wait for osc event to arrive
oe => now;
while( oe.nextMsg() ) {
oe.getInt() => b.value;
osctype => b.message;
b.broadcast();
}
}
}
// our event "Bang"
Bang bang;
8000 => int oscport;
// the types for the osc objects
"/leftraw, i" => string leftraw;
"/leftavg, i" => string leftavg;
spork ~ oscListener( bang, oscport, leftraw );
// shreds are usually happier listening on a separate port
spork ~ oscListener( bang, oscport + 1, leftavg );
SinOsc raw => dac;
SinOsc avg => dac;
while( true ) {
bang => now;
//<<