<div dir="ltr">Hi!<div><br></div><div style><p style="margin:0px;font-size:12px;font-family:Helvetica">It looks like you are using the two signal paths in a similar way, so the first thing you can is to organise the samey stuff in a class. Basically whereever you have copied something and added "2" at the end.</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><br></p><p style="margin:0px;font-size:12px;font-family:Helvetica">Here's a rearranged version of your code (finally got around to testing github :) ):</p><p style="margin:0px;font-size:12px;font-family:Helvetica">
<br></p><p style="margin:0px;font-size:12px;font-family:Helvetica"><a href="https://github.com/Antimon262/curtisullerich_test/blob/master/tmp1.ck">https://github.com/Antimon262/curtisullerich_test/blob/master/tmp1.ck</a><br>
</p><p style="margin:0px;font-size:12px;font-family:Helvetica"><br></p><p style="margin:0px;font-size:12px;font-family:Helvetica">The bottom code that generates stuff is pretty much as you wrote it. The top stuff is a class with some common stuff, the play method (it's like yours except it uses data stored in the object (defined by the class) instead of taking arguments), and a method that mimics what you did in your endless loop.</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><br></p><p style="margin:0px;font-size:12px;font-family:Helvetica">Below that is some initalization of the two objects, followed by this:</p><p style="margin:0px;font-size:12px;font-family:Helvetica">
<br></p><p style="margin:0px;font-size:12px;font-family:Helvetica"></p><p style="margin:0px">spork ~ mySynths[0].startPlaying();</p><p style="margin:0px">spork ~ mySynths[1].startPlaying();</p><div><br></div><div style>... which starts up two endless loops in parallell as defined by startPlaying() in the MySynth class. These loops will run simultaneously and stay in sync forever.</div>
<div style><br></div><div style>After that is the endless loop that you need to have in a ChucK program like this, since it isn't enough to have endless loops running in shreds (started by spork), you need to have something going on in the main program as well.</div>
<div style><br></div><div style>The benefit here is that you don't have to type everything twice, or fix bugs in two places etc. If you need more stuff to differ between the classes, just add variables in side them and and code to initialize them.</div>
<div style><br></div><div style>I haven't looked that closely yet at the rest of the code, but my basic approach to coding ChucK is: if you can read it and see that it works, it's all right. If it's difficult to manage, try to bundle stuff like I described here. If it's difficult to read, try to change it around, experiment.</div>
<div style><br></div><div style>/Stefan</div><p></p></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 20, 2013 at 6:05 PM, Curtis Ullerich <span dir="ltr"><<a href="mailto:curtullerich@gmail.com" target="_blank">curtullerich@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>In my experiments with ChucK I've reached the point of wanting to use multiple instruments in polyphony (two Moogs in this case). </div>
<div><br></div><div>My example is on GitHub <a href="https://github.com/curtisullerich/computer-music/blob/d37a98cb4f7b237b1791be3f051ae485235ad425/chuck/euc.ck" target="_blank">here</a>.<br clear="all">


<div><br></div><div>My usage pattern feels awkward and not very clean, and I'm hoping someone else has encountered the same situation. My question: What is a good way to manage and use multiple instruments in ChucK?</div>



<div><br></div><div>It seems like a simple thing to want to do, but I haven't found any examples in the doc that work this way. Am I completely backwards about how I want to accomplish polyphony?</div><div><br>

</div><div>My particular use case is made most awkward because I'm using an ADSR envelope. I think it's mostly ChucK's style of time tracking/advancement that's derailing me. If I'm not describing this well enough, please let me know. Any advice is appreciated. </div>



<div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Curtis</div><div><br></div>
</font></span></div></div>
<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></blockquote></div><br><br clear="all"><div><br></div>-- <br>Release me, insect, or I will destroy the Cosmos!
</div>