Sorry if I came across as a big arrogant earlier - it's an interesting problem. I got to thinking while walking home from work if you couldn't use some polymorphic class setup. Here's a thing i tried:<div><br></div>
<div>----------------------------------</div><div><br></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">class OscListener {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>fun void listenOnOsc(string msg, int port) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>OscRecv recv;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>port => recv.port;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>recv.listen();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>recv.event(msg) @=> OscEvent oe;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>while (true) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                        </span>oe => now;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                        </span>while (oe.nextMsg()) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                                </span>receiveEvent(oe);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>fun void receiveEvent(OscEvent oe) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">SinOsc raw => dac;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">SinOsc avg => dac;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">//---- Listen on OSC for raw</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">class ListenOnRaw extends OscListener {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>fun void receiveEvent(OscEvent oe) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span><<< "Received raw event" >>>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>oe.getInt() => raw.freq;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">ListenOnRaw listenOnRaw;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">spork ~ listenOnRaw.listenOnOsc("/leftraw/press,i", 8000);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">//---- Listen on OSC for avg</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">class ListenOnAvg extends OscListener {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>fun void receiveEvent(OscEvent oe) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span><<< "Received avg event" >>>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                </span>oe.getInt() => avg.freq;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">ListenOnAvg listenOnAvg;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">spork ~ listenOnAvg.listenOnOsc("/leftavg/press,i", 8001);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">while (true) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>1::second => now;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">}</p>
<div>----------------------------------</div><div>I tried out a modified version of this code - I only have one OSC-sending device that sends three parameters - but I think it should work. However you do this, I agree that it amounts up to a lot of code for each kind of OSC message, but I guess it can't be avoided.</div>
<div><br></div><div>Hope you get everything in order for the installation!</div><div><br></div><div>/Stefan<br><br><div class="gmail_quote">On Mon, Apr 28, 2008 at 8:43 PM, mike clemow <<a href="mailto:gelfmuse@gmail.com">gelfmuse@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Wow, okay... Trying to make sense of this...<br>
<div class="Ih2E3d"><br>
> Actually, come to think of it, Mike, why have the Bang object at all? Why<br>
> not just move the code (the if statements) from the main loop into the<br>
> oscListener loops/shreds, and replace the broadcast with actual<br>
> functionality instead? Maybe there is some more advanced stuff that you<br>
> haven't included that prevents this?<br>
<br>
</div>No, the only thing that I left out were the spork lines for the other<br>
12 OSC listeners I need. :)<br>
<br>
I guess the answer to your question is that I never thought of doing<br>
that because I'm still trying to wrap my head around Chuck's notions<br>
of scope. What you're indirectly telling me is that it's possible to<br>
access my SinOsc objects (and indeed my whole patch) from the other<br>
shreds, which I imagined would not be possible because of scope<br>
limitations. However, considering how classes work, I'm clearly not<br>
fully grasping reality here. I thought that the only way I could<br>
share data between shreds was an event.<br>
<br>
Kassen, I completely forgot about me.yield(), which makes me feel<br>
pretty dumb. But I guess concurrency is not as simple as Chuck leads<br>
me to believe!<br>
<br>
Dan, thanks for pointing out the bug. Honestly, I seem to remember<br>
running into issues where if I had one OSC message with a signature of<br>
"/test, i" and another with a signature of "/mike, i" and both were<br>
coming in on the same port, that Chuck couldn't tell the difference<br>
between them for some reason. I remember fixing this with multiple<br>
listeners on multiple ports. Perhaps I was doing something else<br>
wrong.<br>
<br>
I'm going to mess around with these excellent suggestions and get back<br>
to you all. (sadly, this is all due today. oh well.)<br>
<br>
Thanks!<br>
Mike<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Mon, Apr 28, 2008 at 12:10 PM, Stefan Blixt <<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>> wrote:<br>
> Actually, come to think of it, Mike, why have the Bang object at all? Why<br>
> not just move the code (the if statements) from the main loop into the<br>
> oscListener loops/shreds, and replace the broadcast with actual<br>
> functionality instead? Maybe there is some more advanced stuff that you<br>
> haven't included that prevents this?<br>
><br>
> /Stefan<br>
><br>
><br>
><br>
> On Mon, Apr 28, 2008 at 6:00 PM, Stefan Blixt <<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>><br>
> wrote:<br>
> > Yeah, but note that there are two shreds running this loop in parallell.<br>
> So if one event on each port arrive at the same time, chances are that the<br>
> first yield will hand over execution to the second shred, that in turn<br>
> overwrites b.value and b.message. I think you need at least two Bang<br>
> instances to be sure that this doesn't happen.<br>
> ><br>
> > /Stefan<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > On Mon, Apr 28, 2008 at 5:10 PM, Kassen <<a href="mailto:signal.automatique@gmail.com">signal.automatique@gmail.com</a>><br>
> wrote:<br>
> ><br>
> > ><br>
> > ><br>
> > ><br>
> > > 2008/4/28 Stefan Blixt <<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>>:<br>
> > ><br>
> > ><br>
> > ><br>
> > > > I don't know about the segv signal, but it seems to me that there is<br>
> only one Bang instance that is shared by all iterations/shreds. This means<br>
> that if two events arrive at this loop:<br>
> > > ><br>
> > > ><br>
> > > > while( oe.nextMsg() ) {<br>
> > > > oe.getInt() => b.value;<br>
> > > > osctype => b.message;<br>
> > > > b.broadcast();<br>
> > > > }<br>
> > > ><br>
> > > > the second's values will overwrite those of the first (value and<br>
> message from the first event will be lost).<br>
> > ><br>
> > > I think that's right and I think the way around this would be<br>
> > ><br>
> > ><br>
> > > while( oe.nextMsg() ) {<br>
> > > oe.getInt() => b.value;<br>
> > > osctype => b.message;<br>
> > > b.broadcast();<br>
> > > //yield to receiving shreds,<br>
> > > //then continue processing the message cue<br>
> > > me.yield();<br>
> > > }<br>
> > ><br>
> > > This is the exact same principle I talked about earlier in this topic;<br>
> if you don't yield you don't give the waiting shreds a chance to run.<br>
> Advancing time here would probably not be a good idea.<br>
> > ><br>
> > > Yours,<br>
> > > Kas.<br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > chuck-users mailing list<br>
> > > <a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
> > > <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
> > ><br>
> > ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Release me, insect, or I will destroy the Cosmos!<br>
><br>
><br>
><br>
> --<br>
> Release me, insect, or I will destroy the Cosmos!<br>
> _______________________________________________<br>
> chuck-users mailing list<br>
> <a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
> <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
</div></div><a href="http://semiotech.org" target="_blank">http://semiotech.org</a><br>
<div><div></div><div class="Wj3C7c">_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Release me, insect, or I will destroy the Cosmos!
</div>