I’m using a nanoKONTROL2 to control the volume and the on/off of the instruments/plugins but I would like to be able to say for example when I pressed a button (m) in this case to be able to have that button lit in the nanokontrol2 so I can see it instead of the computer so that way I know for sure what plugins are active or no active. I hope you understand what I’m trying to accomplish here.
The problem I have when I pressed a Button, I get this 2 values on/off is there any way so it can show only one value(light on) or off when I Press it?
The nanoKontrol2 puts out note-off in the form of note-off with velocity of 0. For LED’s to turn off, it requires a different form of note-of which is a note-on with a velocity of 0.
The below script will toggle the value of the LED of any button pushed. You have to define the names of your MIDI In and MIDI out blocks. I just named them “nk2in” and “nk2out”. I toggle a single value so if you need to track multiple notes, each button would need to have its own toggle value
Var
nk2in: MidiInBlock
nk2out: MidiOutBlock
toggle: Int
value : Int
notenum: Int
midichan: Int
message: MidiMessage
On NoteOnEvent(m : NoteMessage) from nk2in
notenum = GetNoteNumber(m)
midichan = GetChannel(m)
toggle=!toggle
Print ("Value is " + toggle)
if toggle <0 then value = 127
else value = 0
End
message = MakeNoteMessageEx(notenum,value,midichan)
SendNowExternal(nk2out,message)
End
Var
nk2in: MidiInBlock
nk2out: MidiOutBlock
toggle: Int
value : Int
notenum: Int
midichan: Int
message: MidiMessage
On NoteOnEvent(m : NoteMessage) from nk2in
notenum = GetNoteNumber(m)
midichan = GetChannel(m)
value = GetVelocity(m)
if notenum == 0 then
Print ("toggle =" + toggle)
toggle=!toggle
if toggle<0 then value=0 else value = 127 end
End // if notenum=0
message = MakeNoteMessageEx(notenum,value,midichan)
SendNowExternal(nk2out,message)
End
I changed from momentary to toggle (in nanoKontrol Editor) everything is working fine but now when switching rackspaces the button in nanoKONTROL2 is not changing with the new rackspace.
Ex: if rackspace1 has button1 and button2 lights ON, when I switch to rackspace2 button1 stays (light ON) even if the widget that belongs to button1 is off.
You just want to update the LED on your NanoKontrol2 right? That is all I’m fixing here because sync doesn’t work because off sends the wrong kind of message to the NanoKontor2.
The script makes sure that proper MIDI message goes back to your controller. That is all it does.
You need to learn the button from your NanoKontrol 2. I have C1 which is R on MIDI CH 1 or our you can change the note number if you want in the script.s
The button should be Momentary to Latching and Thru to make sure the MIDI message gest through to wherever you wanted the original MIDI message to go. You may need to select a plugin to control with the button which I did not.
FYI,
If you only need to recognize a single note, then consider adding a matching clause,
On NoteOnEvent(m : NoteMessage) matching C-1 from nk2in
That will save you from having to test the incoming note and so will be significantly more efficient because the system will only invoke that callback for C-1