[chuck-users] Polyphony/Multiple Instruments in ChucK

Stefan Blixt stefan.blixt at gmail.com
Sun Jan 20 14:12:14 EST 2013


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.

Here's a rearranged version of your code (finally got around to testing
github :) ):


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.

Below that is some initalization of the two objects, followed by this:

spork ~ mySynths[0].startPlaying();

spork ~ mySynths[1].startPlaying();

... 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.

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.

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.

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,


On Sun, Jan 20, 2013 at 6:05 PM, Curtis Ullerich <curtullerich at gmail.com>wrote:

> Hello,
> In my experiments with ChucK I've reached the point of wanting to use
> multiple instruments in polyphony (two Moogs in this case).
> My example is on GitHub here<https://github.com/curtisullerich/computer-music/blob/d37a98cb4f7b237b1791be3f051ae485235ad425/chuck/euc.ck>
> .
> 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?
> 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?
> 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.
> Thanks!
> Curtis
> _______________________________________________
> 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/20130120/7aa83aa7/attachment.htm>

More information about the chuck-users mailing list