Total beginner question - NanoKontrol2 + SC

Hello there,

I want to connect my Korg nanoKONTROL2 to Super Collider. First thing I did is

MIDIClient.init;
MIDIIn.connectAll;

but how can I actually monitor the incoming midi messages?

Try MIDIFunc.trace to view all incoming MIDI messages. Call MIDIFunc.trace(false) to stop posting messages.

1 Like

Also : There are a couple of good extensions out there for the nanokontrol2 , just FYI. I’ve used this one quite a lot: GitHub - davidgranstrom/NanoKontrol2: SuperCollider interface for NanoKONTROL2

2 Likes

This is fantastic. Thank you so much. I didn’t know there were such things as extensions in super collider. I just installed it.

Now I am trying to make a fader control the amplitude of a sine wave, but I can’t figure out what I am doing wrong.

First I do the synthDef for the sine wave:
(
SynthDef.new(\sineTest, {
arg freq = 100, amp = 0.5;
var sig;
sig = SinOsc.ar(freq)*amp;
Out.ar(0, sig);
}).add;
)
Then I run the NanoKontrol2 extension function just to make sure it’s working:
n = NanoKontrol2();

Then I get the values of my fader on the post window:
n.fader1.onChange = {|val| (val/127).postln;}

Then, when I start making sound with:

Synth.new(\sineTest, [\amp, ???]);

How can I make the fader control the \amp argument?

Basically all I want is to have a sine wave’s volume assigned to a fader.

Can’t thank you enough for your help.

I’ve not used that quark myself, but I believe that you’d need to stick control of the amp parameter within the function called by n.fader1.onChange.

Most likely you’ll want to instantiate your Synth ahead of time. If you call it within the function itself, it’ll actually create a new and overlapping instance of sineTest on top of the other one(s), and you’ll effectively have no control over any of them, because on every movement of the fader you’ll make a new Synth, with the fader being able to control ‘that one’, but only until you move the fader again.

You will need to use a variable name when declaring your Synth, otherwise you won’t be able to effectively get values to its arguments with the .set message.

Something like this:

n = NanoKontrol2(); 
a = Synth(\sineTest);

n.fader1.onChange = { |val| 
    a.set(\amp, (val / 127));
};

By the way, you can actually use whatever variable names you want - so you aren’t tied to n for the NanoKontrol, nor are you tied to a for the synth. You can use any lower case letter, these are called environmental variables in SC. A few other them are ‘presupposed’ for other purposes (for instance s is by default used for communicating with the server. So it’s best to not use that one.

If you want to give these variables custom names stick a ~ in front of a word starting with a lower case letter, eg. ~nano or ~sineSynth, etc.

You can also leave off the .new messages when instantiating SynthDefs or Synths, or most other classes. If you don’t add them, they’re implied anyway.

1 Like