[chuck-users] osc listener shred woes
dan trueman
dtrueman at Princeton.EDU
Mon Apr 28 07:24:50 EDT 2008
there is a known bug with OSC receiving on multiple ports, which may
account for this. it's been reported:
http://wiki.cs.princeton.edu/index.php/OSC_multiple_port_bug
dt
On Apr 28, 2008, at 2:47 AM, mike clemow wrote:
> 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;
> //<<<bang.message, bang.value>>>;
> if( bang.message == leftraw ) {
> bang.value => raw.freq;
> }
> else if( bang.message == leftavg ) {
> bang.value => avg.freq;
> }
> }
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080428/d0f94cdd/attachment.htm>
More information about the chuck-users
mailing list