Mapping MIDI Channels to Multiple Instruments in SuperCollider

| Notes on acoustics.

Being able to control a polyphonic instrument in MIDI is good, but being able to control multiple instruments is even better. SuperCollider offers a lot of flexibility when it comes to timbre. For my personal workflow, I like to try out a lot of different sounds to see what best in the mix. Thus when thinking about how I want to use the MIDI controller in connection with SuperCollider, it makes sense to me to be able to switch between instruments fluidly.

Finding some sounds

If you do not want to start from scratch, there are a number of excellent resources for finding SuperCollider SynthDefs:

To start, I copied a few SynthDefs:

I considered these sounds to be a good starting point for emulating many classic keyboard instruments.

Switching instruments

To allow these different timbres to be selected, I made a few changes to the function defined in the previous post. First, I created a second array with sixteen elements to hold the names of the different SynthDefs.

var keys, instruments;
keys = Array.newClear(128);

instruments = Array.newClear(16);
instruments.put(0, \sinpk);
instruments.put(1, \piano);
instruments.put(2, \rhodey_sc);
instruments.put(3, \hammond);

I then modified the NoteOn function such that the correct instrument is selected based on its position in the instruments array.

~noteOnFunc = {arg val, num, chan, src;
	var node;
	node =;
	if (node.notNil, {
		keys.put(num, nil);
	node = Synth(, [\freq, num.midicps, \vel, val]);
	[num, chan].postln;
	keys.put(num, node);

Now I could select the appropriate instrument by simply changing the MIDI channel on my controller.

A quick demo

Putting it all together, I created a simple track to demonstrate these different timbers (accompanied with some mandolin):

The past few posts have worked through some building blocks for using SuperCollider as a platform for creativity. As I wrote in “The Paradox of Creativity”, I find the creative process to be best when applied to areas that are challenging. I believe it is for this reason that I find SuperCollider to be such an interesting platform: it provides the pieces for expansive sonic possibilities, but it takes a bit of effort and curiosity to make the most of it.