#jamuary jam number 11. I finally got around to learning how to hook up a MIDI controller (in this case a Korg nanoKONTROL2) to SuperCollider.

The MIDI hookup code looks like


~sliders = Array.fill(8, 0);
~knobs = Array.fill(8, 0);

~sliderBus = Bus.control(numChannels: 8);
~knobBus = Bus.control(numChannels: 8);

8.do({ |i|
	MIDIdef.cc("slider" ++ i, {|v, nn, chan, src|
		~sliders[nn] = v;
	}, i)

8.do({ |i|
	MIDIdef.cc("knob" ++ i, {|v, nn, chan, src|
		~knobs[nn-16] = v;
	}, i + 16)

The values for the knobs and sliders on the controller are put into an array (so that I can use them in interpreter-side code, for example pattern definitions) and into control busses (so they can be read by SynthDefs).

For this jam, I used my triangle synth, again, 5 copies of it this time with the filter cutoff and amplitude mapped to a knob and slider respectively.

5.do({ |i|
SynthDef(\tri++i, { |out, freq = 440, gate=1, control|
	var snd, env;
	env = EnvGen.ar(Env.asr(3, 0.9, 3), gate: gate, doneAction: 2);

	snd = Mix.new([
	snd = LPF.ar(snd, ~knobBus.kr(1,i).linexp(0, 127, 50, 15000));
	snd = snd * env;

	Out.ar(out, Pan2.ar(snd * ~sliderBus.kr(1, i).linlin(0, 127, 0, 1)));

The pattern stuff was just some notes from a extended major chord looping out of phase

Pdef(\c0, Pbind(
  \instrument, \tri0,
  \dur, Pseq([8, 4], inf),
  \scale, Scale.major,
  \degree, Pseq([1, 5], inf),
  \legato, 0.7,
  \ctranspose, -12,

Pdef(\c1, Pbind(
  \instrument, \tri1,
  \dur, Pseq([5, 3], inf),
  \scale, Scale.major,
  \degree, 3,
  \legato, 0.7,

Pdef(\c2, Pbind(
  \instrument, \tri2,
  \dur, Pseq([7, 5], inf),
  \scale, Scale.major,
  \degree, 7,
  \legato, 0.7,

Pdef(\c3, Pbind(
  \instrument, \tri3,
  \dur, Pseq([2, 7], inf),
  \scale, Scale.major,
  \degree, 11,
  \legato, 0.7,
  \ctranspose, -12,

Pdef(\c4, Pbind(
  \instrument, \tri4,
  \dur, Pseq([3, 5], inf),
  \scale, Scale.major,
  \degree, 5,
  \legato, 0.7,
  \ctranspose, 12,

I set all of the loops going with


and then recorded a few minutes gradually bringing up the levels and filter cutoffs to create some movement.

I recorded everything to a stereo file (and forgot to do anything interesting with the panning of the individual synths), and then applied some ValhallaVintageVerb reverb (Med Ambience) in Reaper.

Not the most interesting jam, but it’s opened up some possibilities and made SC feel more like an instrument.