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

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

Yes @domlo,

I think I will also order the foot-switch extender and the arduino shield from the first 100 units batch for Beta Testing.
But I’m still mostly interested in getting the two expression pedal inputs ( in the back of RK3), and of course the third built-in pedal in RigKontrol Hardware, to work with the MOD Duo.
When it finally gets to work, we could connect other external pedals ( like traditional analog resistive output type expression pedals some of us may have already bought in the past ) to pedal 1 and pedal 2 inputs of Rig Kontrol, interfacing these two and the built-in “pedal 3” with the MOD.
So, at least for now, I will not get rid of my RK3 till I can further test these posibilities. :slight_smile:

But your idea to use the Control Chain Arduino Shield to interface your traditional expression pedal with Duo is of course another great solution : I think people in MOD Team already made a similar hack to use the Quadra Pedal with Duo, by using an Arduino and the Control Chain Shield.

Please tell us about any advance on that direction :wink:

Regards

HeyHello.
I dont own a Rig Kontrol, but I’ve made and arduino MIDI controller, that sends CC messages, that I can then assign with “learn Midi” and it, works great.
But what I can’t do (and want to) is to get any feedback from guitar rig, to send it back to the arduino (to toogle a led for example)…I’ve tried a MIDI monitor but I don’t see anything from the guitar rig. Is there a way to accomplish this?? I’ve read all the post but I only understood 50% I think :cold_sweat:

I found very useful the picture with the CC Messages sent by the RK, I would later try to send exactly those messages to see if the Guitar Rig reacts, or if it move the expression pedal without needing to use “midi learn”

Hello Monti,

Correct me if I am wrong : You want to control Guitar Rig Software with a custom control board you have built ( based an Arduino ). Right?

By now, you have accomplish sending MIDI messages from Arduino to your PC ( running NI Guitar Rig Soft, most probably on top of MS Windows ) and the software recognize the commands, but only if you first configure the chosen controller using MIDI Learn, right ?

Now, you would like to move the pedal or footswitches on the virtual Rig Kontrol showed in the LIVE window of Guitar Rig software directly, in a “plug’n’play” manner - without having to go through MIDI learn on each of these controls mentioned before… yes?

OK, I think you need to undertsand the way GR Software communicates with the Rig Kontrol Hardware.
Here are some excerpts from the GR Documentation that may help you understand it better:

Rig Kontrol Rear Panel two 5-pin DIN connectors:
The RIG KONTROL features a MIDI interface with one input and one output. The RIG
KONTROL does not require MIDI to send controller messages to GUITAR RIG, but it is able to
send MIDI signals to other applications.

Switching Between MIDI Mode and GUITAR RIG Mode
You cannot switch between MIDI mode and GUITAR RIG mode from the RIG KONTROL 3. To
switch the RIG KONTROL 3 to MIDI mode:
► Simply start the Controller Editor.
Or, if the Controller Editor is already running:
► Use the Connect button in the Application Control Bar.
Inversely, if you want the RIG KONTROL 3 to control the GUITAR RIG software again (or one
of its instances), you need to re-connect it.

Visual Feedback on your Controller
Most control elements on your RIG KONTROL 3 are equipped with LEDs that inform you about
the assignment status of the control elements at any time. The fast bidirectional communication
between your RIG KONTROL 3 and the Hardware Service on the software side allows status
indications on your controller to be made in real time.

The Display
The LED Display of your RIG KONTROL 3 simply informs you about the current mode of your
Controller:
► In GUITAR RIG mode (i.e. if your Controller is connected to an instance of its dedicated
software), the LED Display shows you the number of the preset currently loaded.
► In MIDI mode (i.e. if your Controller is connected to the Controller Editor / NI Hardware
Service), the LED Display shows the letters “con” (for “Controller Editor”).

As stated in Controller Editor user’s manual, the Rig Kontrol hardware can be operated in two modes: MIDI mode or GUITAR RIG mode. The led feedback from RG Software to Rig Kontrol HW is only possible while in “Guitar Rig mode”, not in MIDI mode… but still happens throgh the NI Hardware Service, I guess…

If you want to get led status feedback, you should emulate the way the Rig Kontrol HW communicates to the GR Software in “Guitar Rig mode”( with your Arduino appearing as some kind of USB keyboard interface, similar to the way the Rig Kontrol HW does it in reality ).

Hope that helps Monti,
Regards :wink:

1 Like

Thank you very much for your answer fratto.
I’ve just realized this forum is about Mod Duo, I’m a bit out of topic here :smile: sorry, didn’t know about Mod Duo until now, it looks awesome.

You’re right, what I want to do is to send information to the GR software (using the Arduino) and that the Gr software thinks its the Rig Kontrol talking. This means… It will change the leds on the “live view”
The “pulg n play” you mention would be great, but its not a problem for me use the MIDI learn function, the problem is that MIDI learn is “external” even if I assign a footswitch to a switch already assigned to RK by default, the Live view will not change when I press it.

I can control everything on the software sending any midi message I want, but the live view never change, I’ve also tried sending the same MIDI you posted previously but it still dont react. Clearly the software its not waiting for MIDI from the controller.

I think there will be no problem using the Arduino as a USB keyboard (its an Arduino Leonardo which have this feature) but I don’t know what “key Events” (as I read here) is the software waiting… I’m thinking of making a program that sends every possibly key (ascii character) and see if the software do something. I’m not really sure what Key events are.

I’ve attached a picture of my controller just because I think it looks cool :sunglasses:

Thanks again!
Bye

Hello again fratto.
Im going to ask you a very big favor, if you dont mind😇. Is it possible to you to install some USB logger software on your PC to see what information the RK send? If you press each button and move the expression pedal, and send me the log, I could then send the same bytes using the arduino in Raw Hid mode, its like a generic usb, and the GR should think is the RK talking, and maybe I can even get information back from the guitar rig… So again if you please can do this, whenever you can, I would thank you for ever. tell me if I can do something for you. Thank you !

Is there any progress on this?
I still haven’t come around to selling my Rig Kontrol while still having problems (not stage ready/reliable) with my arduino device.