Use NI Rig Kontrol to send CC MIDI messages and control MOD Duo

Hi all,

While waiting for the expresion pedal and footswitch extension for MOD Duo to finally be ready for shipment , I felt curious about using my Native Instruments Rig Kontrol 3 ( foot pedal controller/audio interface ) to accomplish a similar task but instead of connecting via Control Chain like the two above mentioned, I thought it should also work well by sending Control Change MIDI messages from Rig Kontrol ( when put in MIDI Mode ) to the MOD, through a simple DIN type 5-pin connector MIDI cable between them ( Rig Kontrol Midi-OUT --> Mod Duo Midi-IN jack ).

Note: Though, as some of you may already know, the Rig Kontrol 3 is really meant for both tasks: a hardware footpedal controller and also an external audio interface to connect your instrument and amp, I am only interested here in the Controller part, consisting of 9 foot switches, one expresion pedal, and the MIDI In and MIDI Out pair of DIN 5-pin connectors, but NOT the audio interface part: analog input and oulput 1/4" jacks, volume and gain knobs, and so on… Only want to actuate the pedal and foot switches and get them to send the corresponding MIDI orders to control the virtual pedalboard running on the MOD Duo.

After configuring Rig Kontrol on Windows with NI Controller Editor software and then assigning the pedal and the switches to different plugin parameters on the MOD Web UI by using MIDI Learn, all seems to work fine : the Rig Kontrol sends MIDI messages to the MOD Duo and the parameters assigned changes as expected… Hurrah!!!

The problem that I did not imagine in the begining, comes when you want to get rid of the PC and only keep Mod and Rig Kontrol for a gig or stage situation: Sadly, the successful situation described above only works as long as the NI Rig Kontrol is plugged by USB cable to the computer: not only for powering itself via USB ( that could be resolved getting the 5V power from somewhere else, of course , and not the PC ) but because it seems the controller configuration ( the CC midi numbers assigned to each switch and to the pedal on the Rig Kontrol 3 ) is kept in by a software that runs on the PC itself ( precisely the “NI Hardware Service”, run as a Windows service ). In fact, you dont even need to really disconnect the USB cable in order to render the Hardware Controller useless: it is sufficient just to stop for a moment that service on the local services console, which causes the Rig Kontrol to leave out of “MIDI Mode” ( normally displayed as “CON” on the 7-seg LED Display on top ) and all indication lights go off … If you restart the asociated windows service ( while the USB cable remained plugged all the time ) the lights return along with the indication “CON” on the hardware controller LED display and everything goes back to normal…

My question is: Could it be some way to force the Rig Kontrol to stay on MIDI Mode while disconnected from PC ( though may be still connected to Mod USB Host port A instead ) ?
Would it be too difficult for Mod Duo to replicate the task performed by the NI Hardware Service that runs on the PC and monitors the harwdare via USB ?
Or I will always need to carry my PC in order to use the Rig Kontrol as a MIDI Controller ?

I fear I know the answer, but at least I would like to hear some of your opinions :wink:

Regards,
Federico

There is a project which provide this service for linux
https://code.google.com/archive/p/rigkontrol3-linux-midicontroller/

I don’t know how far it works, nor, if it will work on the MOD Duo, but it could be a starting point for the case that support for NI controllers would be implemented into the MOD.

1 Like

That link leads to a 404.

The NI driver seems to be on the linux kernel already.
I did a new build of v1.3 with it enabled, http://download.moddevices.com/releases/testing/modduo-v1.3.0.304-RC1.tar

@fratto can you try it out please?
(the manual update procedure is explained at http://wiki.moddevices.com/wiki/Releases)

Let me know how it goes, if it makes any difference or not.

1 Like

As far I understand it, the driver is used for the audio device only, what is needed is a service (daemon) running, instruct the NI to switch into MIDI mode. This is what the project I linked above provide. The NI Rig Kontrol didn’t send MIDI messages, but Key Events, those needs to be translated to midi messages by the daemon.
If the link above didn’t work for you, (here it works), try this one
http://archive.is/FDzmT
and check out the link “source” there.
But yea, the last commit there was at 2012-12-16 , so maybe a deed end. :confused:

Thank you both @falkTX and @brummer !

Sure, I could try to apply the manual firmware update and then see if Rig Kontrol audio interface gives any sign of life when connected to USB port A on MOD Duo. And of course I will let you know of any advance!

But anyway the audio and analog sound part of Rig Kontrol is not what I am really interested in…
Instead I suspect the source code Brummer pointed would be the way to go to process those USB input events generated by toggling the switches and moving the pedal, and then later to be converted to MIDI messages by that daemon, which would internally ( or by means of a loop cable between Midi-IN and Midi-OUT ports on Duo ) reach the virtual pedalboard currently running on the MOD.

Looking at the source code on the link, it seems to do its job by translating the pressing of foot switches to MIDI “note on” ( with value 127 ) and their releasing to MIDI “note off” ( value 64 ) messages dispatched to some virtual sequencer port opened in ALSA , through these calls :

snd_seq_ev_set_noteon(&ev, CHANNEL, BUTTON_8, 127);

snd_seq_ev_set_noteoff(&ev, CHANNEL, BUTTON_8, 64);

As for the expresion pedal, it converts and scales the value read as input to a MIDI range between 0 and 127, and then it does the following call :

snd_seq_ev_set_controller(&ev, CHANNEL, EXPRESSION_COARSE, val);

Well, I do understand a bit of C/C++ coding but dont have much experience with system programming on Linux ( nor kernel modules like ALSA ). So, my best bet is to try and compile this source on my Kubuntu Desktop and then see if it really does what the author says when connecting the NI Rig Kontrol on a USB port of my computer.

Question:
How could I test on my Linux Box if the MIDI messages are truely being sent ? ( on channel 0, I think, as stated on the source code )
Maybe with some MIDI-OX equivalent for Linux ? Or how can I monitor those sequencer events generated by the daemon?

I also have been searching the internet for some Linux drivers to Native Instruments control surfaces ( Kore Controller, Traktor Control, Maschine Control, etc. ) to see the code and the kind of Configuration Editor they may use, but no luck there ! : NI only supports MAC OSX and Windows, and no source code of course… :unamused:

Regards

Midisnoop does a good job.
http://libremusicproduction.com/tools/midisnoop

1 Like

Hint: jack_midi_dump that comes by default with jack does the same.

I still cannot access the code for that project.
But the kernel config screen shows this text:

CONFIG_SND_USB_CAIAQ_INPUT:

Say Y here to support input controllers like buttons, knobs,
alpha dials and analog pedals on the following products:

  • Native Instruments RigKontrol2
  • Native Instruments RigKontrol3
  • Native Instruments Kore Controller
  • Native Instruments Kore Controller 2
  • Native Instruments Audio Kontrol 1
  • Native Instruments Traktor Kontrol S4
  • Native Instruments Maschine Controller

So I imagine the code was completely merged in the kernel.

Some users in the guitarix forum reported that with this driver (CAIAQ), the audio interface works, but not the MIDI.

I guess, the culprit is indeed the translation from Key Events to midi events.
I could send you the code for your review, if you wish, it’s small. It just grab the Device Event Port and translate the messages to a (alsa) midi sequencer port.
But maybe lets wait if @fratto get it to work on his linux box.

Even if you send me the code, I don’t have the device here to test it with.
This seems like one of those cases where having the hardware is essential…

This is the code:

http://pastebin.com/2GzZcsfE

And the Author’s description about the intention of his project:

rigkontrol3-linux-midicontroller

Enables Native Instruments Rig Kontrol 3 to be used as a MIDI controller on Linux

Linux support for the RigKontrol3 audio and MIDI input and output interfaces are provided by the snd-usb-caiaq ALSA kernel driver which currently sends button presses and pedal movements from the controller as Key Events. This utility, written in C, runs as a daemon to grab the input events (so they don't go anywhere else) and sends them as MIDI events thru an ALSA sequencer port. udev rules are included to make this 100% plug-n-play.

This utility is under development and will interact with the LEDs on the controller to make this hardware a fully functional MIDI controller in Linux. In the future, we want to expose the lights and display panel settings as a MIDI input as well.

Several control modes are being implemented and others planned.

Tested on Xubuntu 12.10.

Encouraging news guys !!!

In short: the above code “rigkontrol3d.c” does what it says and so after some testing, I was able to assign parameters on MOD Duo from the Rig Kontrol Hardware using the MIDI learn feature !!!
That with the exact same hardware connections described in my first post, the only difference being the PC now runs Linux instead of Windows… Encouraging, don’t you think?

Let me describe the steps involved:

– Plug in the Rig Kontrol Hardware via USB, it is recognized by Linux as an audio interface: you can play mp3 files when selected as audio output , the sound comes out through the output jacks and the leds array VUmeter on hardware reflects the output levels… You can also plug in an instrument and see how the input level indication leds response too : But that is no news, right ? Lets devote to the “MIDI mode” that we want to workaround :wink:

– Well, I quickly noticed that pressing the foot switches on the hardware simulated the input of keyboard keys: caracters from “1” to “9” , that you could simply capture with any text editor or web browser if it’s got the focus when you press the switches: That begins to explain some translations seen in the “rigkontrol3d.c” source code: character “1” appears when pressing FootSwitch Nº5, so in the code there is a SWITCH-CASE sentence: CASE KEY_1 —> BUTTON_5 . Got it, lets move on!

–First step, compiled the source and tried to run the binary to lanch the daemon: but it asked for an argument, so went and took a look at the list displayed by file /proc/bus/input/devices to get it : "/dev/input/event13 "

– With a second try and adding that argument, the daemon was up and running, you can see all the terminal commands involved:

– Now configure MIDISnoop to monitor the messages generated by our daemon when pedal and footswitches are being actuated :

– Here the MIDI messages when pressing the switches:

–And now when moving the expresion pedal:

–Now it’s time to close MIDISnoop and capture the MIDI messages with an app that can re-route them to the hardware MIDI-OUT on Rig Kontrol ( sorry, I could not make it with MIDISnoop :unamused: ) :

– That app is “Virtual MIDI Piano Keyboard” and, as you also can see in the picture above, I could successfully assign the gain control on the ouptut gain plugin to the hardware expresion pedal on Rig Kontrol, using MIDI Learn method on the MOD Duo Web IU : You also can see in the picture I moved the pedal close enough to 0db gain setting, but it only reaches -0.31db or +0.31db , I think because of the scaling and rounding set in source code to produce values between 0 ans 127 ( there is a flag called HIGHRES in the code, that can be changed to achieve more resolution for the expresion pedal message generated, MIDI CC11 ).

– Some last notes: The app vmpk reflects the pedal movements graphically by a knob when selecting “Control:11-Expresion” as seen in the picture, and the “MIDI” LED on the Kontrol Hardware lights every time a MIDI message in sent from Linux through its MIDI OUT jack , to the MIDI-IN jack on the MOD.

–Some things to fix:
Also the pressing of hardware footswiches produces some low octave note sounds ( so low they are not even displayed in the graphical piano keyboard ), which is no surprise since our daemon translates those input events as MIDI Note ON and Note Off messages: This of course should be modified in source code to produce ControlChange MIDI type of messages, in order to use the MIDILearn on Duo to assign the footswitches, right ?
Another good improvement to the code would be to add feedback through the LEDs on each footswitch, but this is not strictly necessary, of course!

Now I think I can just rest and wait for the suggestions of the MOD Team, so the last stage would be to modify the code and run it right on MOD Duo…and finally get rid of the PC :slight_smile:

Regards

1 Like

Very interesting!

For making it work on MOD the code would need some tweaking (using jack-midi instead of alsa-midi, avoiding any extra latency).
Modifying the code to use CC instead of notes sounds a good thing to do, not sure how useful sending notes with Rig3 is… :smiley:

Let’s see if we can get our hands on some NI devices.
If they work like Rig3, we should be able to support them pretty easily.

1 Like

Though editable, this is the default Template shown in NI Controller Editor software, and I think it would be a good starting point to assign the switches and the pedal with their respective CC numbers:

I have also contacted Xendarboh , the author of rigkontrol3-linux-midicontroller project, and he told me he had a more developed version of it, including controller´s LED feedback, pedal calibration, and more improvements!

I will keep you informed about any news!

Thank you @falkTX and @brummer for your kind support :smile:

1 Like

@fratto thanks for bringing this up!
i had exactly the same thought (rig kontrol as a temporary solution) and now have exactly the same “problems”.
i will read up everything in the post, but without developing skills i guess i’m a bit in a pickle here.
But i’ll keep on reading.
(including led feedback for tap tempo would be the most awesome thing)

2 Likes

Hi @falkTX and all you guys,

I read this in the anouncements of the last firmware release v1.3.0 :

Generic USB joysticks as MIDI devices
Last but not least, you can now use generic joysticks as if they were a MIDI device.
Previously we could already use PS3 and PS4 joysticks over USB, now thanks to @Azza (and some little extra integration…) we can now use any joystick recognized by the MOD as a MIDI device. :smiley:
Buttons will send MIDI notes while Axis send MIDI CCs.

Then I searched for the related source code to try to understand better:

My question: Do you think something similar can be done with Rig Kontrol and be able to translate the pedal and switches input events to MIDI CC messages in JACK inside Mod Duo ?

If you would give me some hints, of course I could test it!

( And if necessary, even try to modify and compile from source code, if that could be done with modpluginbuilder cross-compilation toolchain… )

Regards

That is my intention for such devices, I said before:

For making it work on MOD the code would need some tweaking (using jack-midi instead of alsa-midi, avoiding any extra latency).

Still don’t have a RigKontrol here though.
For this you don’t need to be able to build it for mod, if you modify the nooice code and make it work for you device natively, then the same code will work fine for mod (very very likely).

1 Like

@fratto: if you’re making those mods i’d be very interested in a how to
in the meantime:
@falkTX: as i can’t use my RigKontrol right now, i’d be happy to lend it to you (i.e. send it to you) for developing purposes.

1 Like

Hi people,

Following the advice from @falkTX, I git-cloned the nooice project to compile and test it natively on my linux box.
While with ordinary game joysticks it worked as expected, I soon ran into some trouble when trying to use it with Rig Kontrol Hardware…

Shortly, the reason is nooice tries to use the joystick api for handling input events, which sends joystick axis movements and button pressings as individual separate input events of type “js_event”.

Although UDEV in my system automatically creates an input node /dev/input/jsX when Rig Kontrol Hardware is connected, this can only capture the expression pedal movements ( as if they were absolute axis movements of a joystick’s hat) , but not the events when a stomp-switch is actuated ( because, sadly, they don’t emulate a joystick button, but sends a keyboard key code instead ).
So, the Rig Kontrol behaves more like a combined mouse-keyboard input device than a game joystick.
You can compare the output of this two known utilities ( “jstest” and “eventest”) to see what I mean:

In other words, when you press a footswitch, it sends a numeric keyboard key code input event, and when you act over the pedal ( in fact any of them three: “pedal 1” - 1/4" jack input, “pedal 2” - 1/4" jack input , or the built-in expression “pedal 3” ) it sends absolute movement events ( axis X for “pedal 1”, axis Y for “pedal 2”, and axis Z for the built-in “pedal 3” ).

From above, it turns out it’s not enough to use only the jsX as input arguement for nooice, because it only catches the axis movement events, but not the footswitches pressing and releasing, which still appears as numeric key strokes on the console, not captured by the nooice jack client at all.

So the logical step seemed to modify nooice source code to use the “input_event” type instead of “js_event”, while using not /dev/input/js1 but the eventXX command-line arguement instead:

$./nooice /dev/input/event13

I dont want to go further and get too technical here, but let me just say that using nooice code as the starting point to register the jack client and midi output port, I then wrote the callback routine to process and translate the Rig Kontrol input events into midi CC messages. This is the result when monitoring MIDI messages using jack_midi_dump utility :

Here is a full sample of all MIDI CC generated when actuating over each of the three pedals and 8 footswitches in RigKontrol Hardware:

Though the above example may prove it is possible to translate RigKontrol inputs into CC MIDI messages ( all in the realtime context provided by JACK Server ), for me there are some questions that still need to be answered before even trying to merge the support for RigKontrol as a new jack-midi device like the others already supported in the current nooice project ( mostly oriented to handle game joysticks ).

So I kindly ask @falkTX for some guidance here :
Would it be a good idea to merge RigKontrol support into nooice GitHub project ?
I personally find it a bit difficult to do it without substantial modification to the actual nooice.cpp source, but you wrote it so you know it better and may find a simple way to do it… :wink:

Would it be better instead to do some kind of fork of Nooice project in order to adapt it to devices that use the “input_event” type , like keyboards, mice and possibly other NI interfaces ?

And more important: Can I contact you by private mailbox to pass the source code I tested and discuss some details about the original nooice source code ?

Regards :relaxed:

1 Like

just fyi,
i kinda have given up pursuing the Rig Kontrol soulution.
When i’ll recieve the footswitch and arduino shield i can solve my problems myself. i’ll propably build a expression to midi/controlchain interface with arduino. this way i’ll be able to program different expression curves for the pedals.
we’ll see :slight_smile:

Does anyone want to buy my RigKontrol3?

I rather not use email if I can :smiley:
Contact me via IRC during normal work hours if possible. freenode server #moddevices.
Maybe discord? Still new to that…

1 Like