[chuck-users] semi complicated midi setup

Graham Percival gpermus at gmail.com
Tue Nov 22 01:15:44 EST 2005

On 18-Nov-05, at 10:53 AM, Atte André Jensen wrote:

> I'd like to control chuck from my 3 usb keyboards. Preferably with the 
> abiliy to split one or more of the keyboards to different sounds, 
> dynamic voice allocation is a must for polyphonic sound.
> I'd like to make the code as modular as possible, in order to easily 
> create one such setup for each song. This means that the definition of 
> which keyboard(s) is spilt and how + routing to actual instruments + 
> code for each instrument should be in seperate files.
> I'm still very new to chuck, so my first question is simply: is this 
> at all possible with chuck?

Yes.  To use chuck with multiple files, include them all on the command 
line.  ie
$ chuck foo.ck bar.ck

> The second question: (if possible) could soneone provide a rough 
> outline, how to achieve what I'd like?

The beauty of a language like chuck is that you can solve any problem 
in many different ways.  I don't think this is the best solution, but 
it's the easiest to explain:

1)  get MIDI information from keyboard.  This is covered in the manual.
2)  Look at the midi info;
if ((notein>x)&&(notein<y)) inst1(notein);
if ((notein>z)&&(notein<a)) inst2(notein);

fun void inst1(int note)
   Bowed foo;   // or any other stk instrument; see the docs.
   foo.freq => std.mtof(note);
   1=>foo.startStuff;  // I can't remember if it's noteOn or startBow or 
   2::second=>now; // or however long you want this to be... you could 
certainly write this to stop when you receive a midi note off, but 
that's left as an exercise to the reader.  :)

That should be enough to get you started.

- Graham

More information about the chuck-users mailing list