Help Korg nanoKontrol and synthdefs

94 views
Skip to first unread message

Joel Kruger

unread,
Jan 2, 2014, 4:57:54 AM1/2/14
to nycsuper...@googlegroups.com
Hello everyone,

I was told that I midi controllers were a popular topic here as of late. Allow me to dive right in :-)

I am used to using the korg nano PAD and in the past, I have used this:

(
SynthDef( \tirescreaching,
{| freq = 440, gate =1, sustain =1, amp = 0.25, width = 0.15, preamp = 5|
var sig,
env = Env.adsr(0.01, 0.1, 0.1, 0.01);
sig = Saw.ar(Latch.ar(GrayNoise.ar, SyncSaw.ar(9)) * 400 + 800 + freq, 4, 0.2) * EnvGen.kr(env, gate, doneAction:2) * amp;
Out.ar(0, sig ! 2)
}).add

)

//Set up below

(
var notes, on, off;

MIDIClient.init;
MIDIIn.connectAll;

notes = Array.newClear(128);   // array has one slot per possible MIDI note

on = MIDIFunc.noteOn({ |veloc, num, chan, src|
    notes[num] = Synth(\tirescreaching, [\freq, num.midicps,
        \amp, veloc * 0.00315]);
});

off = MIDIFunc.noteOff({ |veloc, num, chan, src|
    notes[num].release;
});

q = { on.free; off.free; };
)

I have recently acquired a korg nanoKontrol to control, among other things, amplitude and stutter/glitch effects with knobs and faders. My attempts so far have been getting me closer to the goal. I have been able to get the kontrol to print commands to the post window when I move the faders and knobs.

I have discovered that I can control pitch, using the faders, in this manner:

MIDIIn.connectAll; 

n = Ndef(\test1,{|freq = 440|0.1*SinOsc.ar(freq)}).play; 

MIDIdef.cc('test1', { |val| 
        n.set(\freq, \freq.asSpec.map(val / 127)); 
}, ccNum: 14); // knob 1 

Spec.add(\freq, [200, 1000, \exp]); 

(
// and then: 
MIDIdef.cc('test1', { |val| n.set(\freq, \freq.asSpec.map(val / 
127))}, ccNum: 2); // slider 1 
)


I have discovered that I can control amplitude, using the faders, in this manner:


(
SynthDef(\sound,{arg freq=440, amp=1;
var saw, sig, filter, env; 

saw= Saw.ar(freq);

sig = Saw.ar(Latch.ar(GrayNoise.ar, SyncSaw.ar(9)) * 400 + 800 + freq, 4, 0.2) * amp;
filter= Resonz.ar(saw,1000,0.1)*amp;

Out.ar(0,sig,filter.dup(2))
}).add
)

a= Synth(\sound,[\freq,200,\amp,1]); //create running synth

//use the set message to update the control inputs of the running synth
MIDIIn.control = { arg src, chan, num, val;   a.set(\amp, val/127) };

//when you're finished twiddling MIDI controllers
a.free;

I am curious if anyone has made good use of the other buttons, besides the faders and knobs as well.

I have read that some people use Responders with success but I am not experienced enough to really apply them. I am hoping someone would be able to assist me with understanding how to make use of nano kontrol. It seems like a very versatile tool but I need a little push. If anyone would like to share some working examples of using this thing, I would be beyond grateful. As you may have guessed, I am still pretty new to SC and appreciate all input that you can afford. Happy New Year!

Regards,
Joel

Nick Colvin

unread,
Jan 2, 2014, 6:58:18 AM1/2/14
to nycsuper...@googlegroups.com
Hi Joel,

I haven't done much with MIDI control beyond note on/off messages, though I have played a bit with OSC control.

You are sort of exploring responders already with your use of the MIDIdef class. The usage looks very similar to me. I'm pretty sure that your use of identical keys (i.e. 'test1') in the MIDIdef is causing the second to overwrite the first. If you'd like to control multiple parameters simultaneously, you'll need to use MIDIdefs stored in different keys.

It seems you're pretty close to getting what you want done. Do you know all of the MIDI CC numbers being output by the Korg? If you know that, then it's just a matter of setting up and mapping all of the MIDIdefs/responders/whatever.

You should probably check out James Harkins' DDW quarks, specifically ddwMIDI and ddwVoicer, which are specifically for helping to build control and management structures for synths and MIDI.

If you come to the next meet up we can discuss in person.

Also, if you send questions like this to the global Supercollider list, you will hit people who are actually experts in MIDI->SC work (like James) who are often very helpful.

Cheers,
Nick




--
You received this message because you are subscribed to the Google Groups "nycsupercollider" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nycsupercollid...@googlegroups.com.
To post to this group, send email to nycsuper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nycsupercollider/678d3747-6894-4ae8-910f-b4a7860b7d08%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dan Palkowski

unread,
Jan 2, 2014, 12:22:05 PM1/2/14
to nycsuper...@googlegroups.com
Like Nick says, looks like you're pretty much there; Responders have supposedly been replaced with MIDIdef, MIDIfunc, etc., so the first thing the sc-users group would say is 'don't use em' ;-) (on the other hand, they work quite well for simple applications)
I've been messing around with a BCR2000 I got a while back, but am digging the smaller footprint of the nano, so you've inspired me to pick one up! Then I'll try out your code & see if I can flesh it out to respond to the controls individually.  For note input on the nanopad, the ddw Voicer is a great way to go, I'd definitely favor that approach for live input.
Do echo any specific code queries to sc-u...@lists.bham.ac.uk also, there are inevitably at least 20 folks out there who have solved any given problem who will jump in with a variety of approaches.

Joel Kruger

unread,
Jan 2, 2014, 10:12:39 PM1/2/14
to nycsuper...@googlegroups.com
Thanks for the input guys! I agree, the nano has a lot to offer on such a small form factor. I am glad that you took the plunge and picked one up Dan, I am sure that we can figure out some interesting stuff between the two (and more) of us.

As for the CC numbers, I took a look around and have not found a list yet but will play around some more and post what I discover. I believe they can be changed with some software that they provide but I would rather stick to the defaults if possible.

Any way, thanks again, I will stay in touch.

Regards,
Joel


--
You received this message because you are subscribed to a topic in the Google Groups "nycsupercollider" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nycsupercollider/Lkbv_zP4UP8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nycsupercollid...@googlegroups.com.

To post to this group, send email to nycsuper...@googlegroups.com.

daniel palkowski

unread,
Jan 2, 2014, 10:20:02 PM1/2/14
to nycsuper...@googlegroups.com
Once mine arrives I can throw it into Max & quickly detect the defaults for whatever it has on it, we can then make up a dictionary of nano cc defs, etc.

cheers
dp


--
You received this message because you are subscribed to the Google Groups "nycsupercollider" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nycsupercollid...@googlegroups.com.

To post to this group, send email to nycsuper...@googlegroups.com.

Joel Kruger

unread,
Jan 3, 2014, 3:46:05 AM1/3/14
to nycsuper...@googlegroups.com
I was able to find the the cc #s utilizing this bit of code:

(
//receive CC messages
MIDIdef.cc(\printCC, {
arg val, num, chan, src;
("cc msg:"++[val,num,chan,src]).postln;
});

)

Then it was simply a matter of pressing the buttons and watching the output to the post window. The following is what I found:

KORG nanoKontrol MIDI cc numbers

Faders (1-8 from left to right)

Fader 1 = cc# 0
Fader 2 = cc# 1
Fader 3 = cc# 2
Fader 4 = cc# 3
Fader 5 = cc# 4
Fader 6 = cc# 5
Fader 7 = cc# 6
Fader 8 = cc# 7

Knobs (1-8 from left to right)

Knob 1 = cc# 16
Knob 2 = cc# 17
Knob 3 = cc# 18
Knob 4 = cc# 19
Knob 5 = cc# 20
Knob 6 = cc# 21
Knob 7 = cc# 22
Knob 8 = cc# 23

Solo Buttons (1-8 from left to right)

Solo Button 1 = cc# 32
Solo Button 2 = cc# 33
Solo Button 3 = cc# 34
Solo Button 4 = cc# 35
Solo Button 5 = cc# 36
Solo Button 6 = cc# 37
Solo Button 7 = cc# 38
Solo Button 8 = cc# 39

Mute Buttons (1-8 from left to right)

Mute Button 1 = cc# 48
Mute Button 2 = cc# 49
Mute Button 3 = cc# 50
Mute Button 4 = cc# 51
Mute Button 5 = cc# 52
Mute Button 6 = cc# 53
Mute Button 7 = cc# 54
Mute Button 8 = cc# 55

Arm/Record Track Buttons (1-8 from left to right)

Arm/Record Track Button 1 = cc# 64
Arm/Record Track Button 2 = cc# 65
Arm/Record Track Button 3 = cc# 66
Arm/Record Track Button 4 = cc# 67
Arm/Record Track Button 5 = cc# 68
Arm/Record Track Button 6 = cc# 69
Arm/Record Track Button 7 = cc# 70
Arm/Record Track Button 8 = cc# 71

Cycle Button

Cycle Button = cc# 46

Track Buttons (1-2 from left to right)

Track Button Left Arrow = cc# 58
Track Button Right Arrow = cc# 59

Marker Buttons (Set, Left Arrow, Right Arrow)

Set Button = cc# 60
Marker Arrow Left = cc# 61
Marker Arrow Right = cc# 62

Transport Control Buttons (from left to right)

Rewind Button = cc# 43
Fast Forward Button = cc# 44
Stop Button = cc# 42
Play Button = cc# 41
Record Button = cc# 45

Next, I will attempt to combine multiple MIDIdefs so that I can control independant actions and more fully populate the nanoKontrol. We are getting closer guys! cheers.

- Joel


Joel Kruger

unread,
Jan 3, 2014, 5:25:59 AM1/3/14
to nycsuper...@googlegroups.com
It seems like the buck stops there. I am having trouble assigning individual channels. I read that saving these to an array might be the way to go, a way to represent the client side to the server side.

I tried doing this:

(
// Fader 2
n = Ndef(\Fader2,{|freq = 440|0.1*Saw.ar(freq)}).play;

MIDIdef.cc('Fader2', { |val|
        n.set(\freq, \freq.asSpec.map(val / 127));
});

Spec.add(\freq, [20, 9000, \exp]);

// Assign to fader 2
MIDIdef.cc('Fader2', { |val| n.set(\freq, \freq.asSpec.map(val /
127))}, ccNum: 1, /*chan: 0, srcID:2,*/); // Any other channel number will cause it to fail.

Hopefully we can get multiple MIDIdefs going independent of each other.

- Joel

daniel palkowski

unread,
Jan 3, 2014, 9:52:54 AM1/3/14
to nycsuper...@googlegroups.com
yes, I ran into the channel issue with the BCR as well, seems to respond to everything regardless of setting the channel to a specific number, pbly just a syntax thing


daniel palkowski

unread,
Jan 3, 2014, 10:11:05 AM1/3/14
to nycsuper...@googlegroups.com
one thing to be sure of, the idea would be to take the global channel being transmitted by the device (usually defaults to 1 (0) i'd imagine), then remap it to an output channel based on the fader/knob etc selected..possible that the MIDIdef is automatically passing the input channel to the output channel and freaking out if they don't match?
Let's pass the code snippet to the sc-users list & see what comes back..
Reply all
Reply to author
Forward
0 new messages