[chuck-users] osc listener shred woes

Stefan Blixt stefan.blixt at gmail.com
Mon Apr 28 10:52:31 EDT 2008


I don't know about the segv signal, but it seems to me that there is only
one Bang instance that is shared by all iterations/shreds. This means that
if two events arrive at this loop:

       while( oe.nextMsg() ) {
           oe.getInt() => b.value;
           osctype => b.message;
           b.broadcast();
       }

the second's values will overwrite those of the first (value and message
from the first event will be lost). Also, if the two oscListener shreds
happen to call broadcast simultaneously, one shred's bang values will
overwrite the other's.

I'm wondering about this statement:

osctype => b.message;

Will it cause some kind of copied string object? Probably not, I guess. The
lack of garbage collection of strings has been one of my woes when composing
OSC addresses.

/Stefan

On Mon, Apr 28, 2008 at 1:24 PM, dan trueman <dtrueman at princeton.edu> wrote:

> 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
>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>


-- 
Release me, insect, or I will destroy the Cosmos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080428/991838e0/attachment.htm>


More information about the chuck-users mailing list