Sorry if I came across as a big arrogant earlier - it&#39;s an interesting problem. I got to thinking while walking home from work if you couldn&#39;t use some polymorphic class setup. Here&#39;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 =&gt; 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) @=&gt; 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 =&gt; 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 =&gt; dac;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco">SinOsc avg =&gt; 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>&lt;&lt;&lt; &quot;Received raw event&quot; &gt;&gt;&gt;;</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() =&gt; 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(&quot;/leftraw/press,i&quot;, 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>&lt;&lt;&lt; &quot;Received avg event&quot; &gt;&gt;&gt;;</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() =&gt; 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(&quot;/leftavg/press,i&quot;, 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 =&gt; 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&#39;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 &lt;<a href="mailto:gelfmuse@gmail.com">gelfmuse@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Wow, okay... &nbsp;Trying to make sense of this...<br>
<div class="Ih2E3d"><br>
&gt; Actually, come to think of it, Mike, why have the Bang object at all? Why<br>
&gt; not just move the code (the if statements) from the main loop into the<br>
&gt; oscListener loops/shreds, and replace the broadcast with actual<br>
&gt; functionality instead? &nbsp;Maybe there is some more advanced stuff that you<br>
&gt; haven&#39;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. &nbsp;:)<br>
<br>
I guess the answer to your question is that I never thought of doing<br>
that because I&#39;m still trying to wrap my head around Chuck&#39;s notions<br>
of scope. &nbsp;What you&#39;re indirectly telling me is that it&#39;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. &nbsp;However, considering how classes work, I&#39;m clearly not<br>
fully grasping reality here. &nbsp;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. &nbsp;But I guess concurrency is not as simple as Chuck leads<br>
me to believe!<br>
<br>
Dan, thanks for pointing out the bug. &nbsp;Honestly, I seem to remember<br>
running into issues where if I had one OSC message with a signature of<br>
&quot;/test, i&quot; and another with a signature of &quot;/mike, i&quot; and both were<br>
coming in on the same port, that Chuck couldn&#39;t tell the difference<br>
between them for some reason. &nbsp;I remember fixing this with multiple<br>
listeners on multiple ports. &nbsp;Perhaps I was doing something else<br>
wrong.<br>
<br>
I&#39;m going to mess around with these excellent suggestions and get back<br>
to you all. &nbsp;(sadly, this is all due today. &nbsp;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 &lt;<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>&gt; wrote:<br>
&gt; Actually, come to think of it, Mike, why have the Bang object at all? Why<br>
&gt; not just move the code (the if statements) from the main loop into the<br>
&gt; oscListener loops/shreds, and replace the broadcast with actual<br>
&gt; functionality instead? Maybe there is some more advanced stuff that you<br>
&gt; haven&#39;t included that prevents this?<br>
&gt;<br>
&gt; /Stefan<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Apr 28, 2008 at 6:00 PM, Stefan Blixt &lt;<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt; &gt; Yeah, but note that there are two shreds running this loop in parallell.<br>
&gt; So if one event on each port arrive at the same time, chances are that the<br>
&gt; first yield will hand over execution to the second shred, that in turn<br>
&gt; overwrites b.value and b.message. I think you need at least two Bang<br>
&gt; instances to be sure that this doesn&#39;t happen.<br>
&gt; &gt;<br>
&gt; &gt; /Stefan<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Mon, Apr 28, 2008 at 5:10 PM, Kassen &lt;<a href="mailto:signal.automatique@gmail.com">signal.automatique@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; 2008/4/28 Stefan Blixt &lt;<a href="mailto:stefan.blixt@gmail.com">stefan.blixt@gmail.com</a>&gt;:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; I don&#39;t know about the segv signal, but it seems to me that there is<br>
&gt; only one Bang instance that is shared by all iterations/shreds. This means<br>
&gt; that if two events arrive at this loop:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;while( oe.nextMsg() ) {<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;oe.getInt() =&gt; b.value;<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;osctype =&gt; b.message;<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b.broadcast();<br>
&gt; &gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; the second&#39;s values will overwrite those of the first (value and<br>
&gt; message from the first event will be lost).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I think that&#39;s right and I think the way around this would be<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;while( oe.nextMsg() ) {<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;oe.getInt() =&gt; b.value;<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;osctype =&gt; b.message;<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b.broadcast();<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//yield to receiving shreds,<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//then continue processing the message cue<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;me.yield();<br>
&gt; &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; This is the exact same principle I talked about earlier in this topic;<br>
&gt; if you don&#39;t yield you don&#39;t give the waiting shreds a chance to run.<br>
&gt; Advancing time here would probably not be a good idea.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Yours,<br>
&gt; &gt; &gt; Kas.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; chuck-users mailing list<br>
&gt; &gt; &gt; <a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
&gt; &gt; &gt; <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Release me, insect, or I will destroy the Cosmos!<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Release me, insect, or I will destroy the Cosmos!<br>
&gt; _______________________________________________<br>
&gt; &nbsp;chuck-users mailing list<br>
&gt; &nbsp;<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
&gt; &nbsp;<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
&gt;<br>
&gt;<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>