ControlSurface-Daemon: A Mapper Daemon for Novation Control Surfaces and others where management is needed.A daemon that exports an ALSA midi client that speaks over a private USB connection to a studio control surface.
The source code for this mini-project is here. Please let me know if you find it useful or enhance it. My apologies for its quality: it was written very quickly: LINK: Source Code Download.
The Novation series of control surfaces, such as the "ZeRO II" that I have ship with a separate program called "Automap" which is not supported for Linux.
The control surface can be used with and without Automap, but without it there is no simple way to control any of the LEDs on the control surface. The other control surfaces I own, which include a Korg NanoKontrol2, a Yamaha 02R (DAW layer) and a Bheringer BCF2000 all simply respond to control change information sent to them to update their status LEDs, encoder rings and motorised flying faders (or pickup points for non-motorised faders).
When using the Novation device in its 'advanced mode', which means without using the Automap program on an ancillary computer, it will update its leds and indicators as you adjust the associated local buttons. But as these are commonly used for track cuts and solos and record readys and so on, that are updated from other places as well, such as the GUI of a DAW or an automation track on a sequencer, they will soon become meaningless if they cannot be remotely controlled.
To solve this problem I contacted Novation by phone and email a few times. It was not clear to me that the person who handled my question understood the problem, but he did kindly send me a Novation internal document that describes the Automap protocol between the surface and the required external program. I soon realised I could quickly write my own basic version of the Automap program, sufficient to bring the Novation product up to the same basic operational level of my other control surfaces. It turned out that very little information was needed from the protocol description document, since all the basic exchanges are completely straightforward control change midi commands. However, there are several exclusive messages that would have had to be extracted using a USB sniffer program in the absence of the document. The exclusives I ended up using were to update the LCD display on the control surface and to put it into Automap mode automatically (although the latter can be done with a front panel hard button and also with a particular control change message too).
When you run 'lsusb -v' to list the details of the Novation controller it reports three endpoints: two of these are the 'MIDI 1' and 'MIDI 2' ports that show up under Alsa (e.g. can be seen with the command "amidi -l") and the third is what Novation refers to as the 'hidden port'. Alsa connects perfectly and automatically to the two native ports and leaves the hidden port alone and unclaimed. Hence my mapper daemon connects to that endpoint and it then exports its own Alsa Midi port which DAWs etc must connect to, leaving the native pair of ports unused.
Control surfaces have various behaviours for the buttons: momentary, latching and so on. The most useful one, given a reasonably flexible DAW, is that they emit a CC message on both the push and release edge and that the associated LED indicator is in 'manual' mode. The word 'manual' is used on the Korg nanoKontrol but this is the mode that is sadly missing from the Novation controller and which needs the daemon to be running elsewhere.
For the infinite shaft encoders, relative output is the primary output form, sending a small +ve or -ve number as record of a rotation. I decided to integrate these inside the daemon and report a 0 to 127 absolute value to ALSA, but this is easily changed if desired.
I implemented four 'soft contexts' whereby each physical controller on the surface could have up to four mappings to actual controllers. For instance, it is then relatively easy to control 32 channels with the 8 actual channel strips on a controller. One knob is reserved to change context. On the Novation ZeRO II I used the central 'speed dial' for this adjuster. Of course, flying fader pickup points and track LED status information continues to be received while a context is not active and when that context is next selected the current settings are pushed down to the surface. For the non-motorised faders on the ZeRO II this essentially means they enter pickup mode if their physical position is wrong.
A fader that has been remotely 'moved' but which has no motor and so cannot actually move needs to enter 'pickup mode'. In pickup mode, when the user moves it, some LEDs flash and no events are sent on to the controlled target. The LEDs indicate which direction the user must move it to catch up with the current value and when it is put there it exits pickup mode.
On the Novation we have five LEDs down the left side - we use the lower two for 'too high/move down' indication and the upper two for 'too low/move up' indication. We can flash the middle one briefly when the pickup point is reached.
Further work...TODO: Hot plug reconnection Instructions on how to make it autoload. I may have some time at Easter to describe these. Best regards for a happy 2014!