<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hello again Chuckists,</div><div><br></div><div>This is the second time today that I harangue the list with a question about some unexpected behaviour from code (unexpected to me, anyways!).  This one is a bit more complicated…</div><div><br></div><div>I declare a public class that maintains a static array of oscillators and envelopes (through a helper class).  A function in the public class creates a new oscillator and envelope, and connects them both to the dac.  Another function in the public class makes the envelope "go".</div><div><br></div><div>Now here's the funny thing, to my mind: </div><div><br></div><div>(1) If I call the creation function and the "go" function from the same (second) shred, everything works.</div><div><br></div><div>(2) If I call the creation function in one shred and the "go" function in another shred, there is no sound - and a little investigation seems to reveal that the ugens all exist and are accessible, but are no longer connected to each other.</div><div><br></div><div>(3) If I call a special "connect" function - _from any shred_ - that simply reestablishes the connections, then the "go" function works when called _from any shred.</div><div><br></div><div>Here is an example of "calling shreds" and below that is the public class code:</div><div><br></div><div>// one possible shred…</div><div>Cells.sinOsc("low",28);</div><div><br></div><div>// I want this to work from a separate shred but there is no sound/connections</div><div>Cells.ad("low",5::ms,5::ms);</div><div><br></div><div>// However, the above starts to work again if this is called from any shred</div><div>Cells.connect("low");</div><div><br></div><div>// public class code in a separate file and shred</div><div><br></div><div>class Cell {<br>    Osc o;<br>    Envelope e;<br>}<br><br>public class Cells {<br>    <br>    static Cell @cells[];<br>    <br>    function static void sinOsc(string name, float nn) {<br>        Cell c;<br>        new SinOsc @=> c.o;<br>        nn => Std.mtof => c.o.freq;<br>        new Envelope @=> c.e;<br>        c.o => c.e => dac;<br>        c @=> cells[name];<br>    }<br>    <br>    function static void ad(string name, dur att,dur dec) {<br>        cells[name] @=> Cell c;<br>        1 => c.e.target;<br>        att => c.e.duration => now;<br>        0 => c.e.target;<br>        dec => c.e.duration => now;<br>    }<br>    <br>    // the function below shouldn't be necessary, I don't think<br>    // but it is… unless connect is called on a given cell from<br>    // a shred other than the shred that calls sinOsc, the <br>    // ugens are not connected to the dac! ???<br>    function static void connect(string name) {<br>        cells[name] @=> Cell c;<br>        c.o => c.e => dac;<br>    }<br>    <br>    function static void note(string name, float nn) {<br>        nn => Std.mtof => cells[name].o.freq;<br>    }<br><br>}<br><br>Cell theCells[0] @=> Cells.cells;<br><br>while(true) {<br>    <<< "public class Cells is still alive" >>>;<br>    10::second => now; <br>}<br><br></div><div>// Thanks for any help!</div><div>// Yours truly,</div><div>// David<br><br></div><div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>-------------------------------------------------------------------</div><div>Dr. David Ogborn, Assistant Professor<br>Communication Studies & Multimedia</div><div>Director, Cybernetic Orchestra & ESP Studio</div><div>McMaster University, Hamilton, Canada<br><br>ogbornd --at-- <a href="http://mcmaster.ca">mcmaster.ca</a></div><div><div><a href="http://davidogborn.net/">http://davidogborn.net</a></div><div><a href="http://twitter.com/ogbornd">http://twitter.com/ogbornd</a></div><div><span class="Apple-style-span" style="font-size: medium; "><a href="http://esp.mcmaster.ca/">http://esp.mcmaster.ca</a> (Cybernetic Orchestra)</span></div></div><div>1-905-525-9140 ext 27603</div></div><div><br></div></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></body></html>