Author Topic: Injecting MIDI from Control Surface  (Read 8029 times)

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1676
Injecting MIDI from Control Surface
« on: September 24, 2015, 08:45:22 PM »
It is sometimes useful to send special MIDI messages to Sonar, like Program Changes, CC, etc. It is nice when your keyboard can be configured to send them directly, but even than it is not always practical. And what to do when your controller can not generate required messages at all? Here I am going to demonstrate how that can be done using AZ Controller.

Unfortunately, Control Surface (CS) API has no function to "inject" any MIDI from CS directly into Sonar. But plug-in can send arbitrary MIDI back to the device. So, if we send something to loopback MIDI software/hardware device, we can route its other end into Sonar! I am using loopMIDI, works great for me. But you can use any other solution.

In this example, I am going to send Program Changes to select one from 4 different instruments for TTS-1. Create simple project with TTS-1 track to test the result.

Insert AZ Controller into the Control Surfaces list, set its input to your controller and its output to the loopback device.

I start the explanation from the result of "Quick start" tutorial. Check that it works (it should move the first track volume by turning the knob).

In the Options tab, Create Software Set: in the Software Set section enter "Instrument" and press "Save". After that, replace "Default" with "1" and press "Save". In the Combo Box with "1" select "<Append state>", enter "2" and press "Save". The same way add "3" and "4". That is going to be the instrument to select, the number of States here will be the number of instruments we can select.

Change to the Logic Tab.
Select second ("Value") Action. Change "Strip" to "MIDI", "CC" to "PC" and leave "Number" 0 (Our first instrument will be Piano).
In the "Action conditions" select "Instrument" and replace "<Any>" by "1".
"Copy" the action, and press "Paste" 3 times.
Select "Strip" Action and move it to the top of the list (by "Move Up"). Change "Undefined" to "Set state", "Instrument" and change "<Next Step>" to "<Map MIDI Value">.
Select second MIDI Action, Change "1" in the "Action conditions" to "2" and "0" in the "Action Configuration" to 4 (that will be "E Piano").
Do the same with other 2 Actions for Instruments 3 and 4, select some other PC, for example 20 ("Reed organ") and 50 ("Syn strings").

You can now turn the knob and see the Instrument is changing.

This result is not good for recording, it sends MIDI every time you turn the knob, even when that does not change the Instrument. That can be solved, but that will complicate the example. And you probably is not going to use that for recording in any case, it will be better to assign separate button (or button combination!) for that.

It is possible just use MIDI value (0-127) from knob to send corresponding PC message, AZ Controller can construct arbitrary MIDI/SysEx messages dynamically. It is even possible to send messages to up to 4 different MIDI devices using Master/Slave feature of AZ Controller.

Thanks for reading!
If you have any questions, I am happy to answer them in the Discussion section.
« Last Edit: September 24, 2015, 10:00:58 PM by azslow3 »

Offline cbarn

  • Newbie
  • *
  • Posts: 5
Re: Injecting MIDI from Control Surface
« Reply #1 on: September 27, 2015, 10:55:24 PM »
You, sir, are a mind-reader.  I was just fighting with this today and couldn't figure out what was going on, then happened to check the forum and here this is!

I've used AZ Controller to customize a Korg nanoKontrol2 to work (I think) better with the SONAR X3 mixer than the default Korg plugin does - the left & right buttons shift which 7 tracks are being controlled, and the 8th fader column always controls the master.  Since I don't use the Solo button on the master, I wanted to map it to send CC 120 and CC 123 to all MIDI channels - very rarely (but always at a bad time!) my KX88 keyboard will stick a key, usually on a string or organ patch.  :-)  I've never been able to find a way to map SONAR's "Reset MIDI and Audio" to a controller button, and frankly that's not much use since it also resets all the controllers and kills the audio - being able to send the CC messages stops those stuck notes much more gracefully.  Using loopMIDI for the output (and all the synth modules listening on AllInputs on their respective channels) did the trick - that Solo button kills the notes without killing all the audio and resetting the controllers.

One additional tip, though:  since I'm controlling the mixer with the plugin, I had setup my original code to properly light (and track across channel changes) the mute, solo, and record buttons for each channel.  In order to make that still work after changing the output of AZ Controller to a loopMIDI port, I just had to add a MIDI track that takes the loopMIDI port (all channels) as input and outputs it to the nanoKontrol's port.