Using Matlab with a KORG padKONTROL USB MIDI Input Device

In Matlab, the KORG padKONTROL midi studio controller can be used as a versatile multipurpose input device. It has 16 velocity-sensitive (pressure-sensitive) tap pads, two twist knobs, an X-Y modulation touch pad, and various other features. It has drivers available for both mac and pc operating systems, and a tool called padKONTROL Editor Librarian that allows for customization of each trigger pad (and other elements) using a nice GUI interface:

padKONTROL Editor Librarian

The latest drivers and software for this I/O usb midi controller are freely avalable to download here on the KORG website. As you’ll notice, there are 16 different “Scenes” that can be edited; once these scenes are loaded onto the device, they can be made active live, directly from the padKONTROL machine itself (without the need to reset anything in the Editor Librarian or in Matlab). To start the pad assignment process, simply click on one of the pads in the Editor, which opens this Parameter Edit Window:

padKONTROL Parameter Window Pad

From my initial tinkering, here’s what I can tell you about each of the ‘Parameter Edit Window’ options…

TYPE:

For any input to be recognized by Matlab, the trigger pad TYPE must be set to CONTROL CHANGE in the dropdown window. From what I’ve gleaned this is the case, at least, for USB input. I’m not sure whether an actual (non-emulated) MIDI input would allow the NOTE inputs to be recognized; regardless I don’t think there is much to be gained using the NOTE input-type anyway.

CC#:

The CC# corresponds to part of the ControlNumber1 identified by Matlab. When Matlab attempts to identify I/O devices connected through a USB port, it needs for the device to send a signal — just a little something to know it’s out there, a twist, a tap, anything will do. To evoke this process, the midiid Matlab command is used…

      >> [ctl, device]=midiid
      Move the control you wish to identify; type ^C to abort.
      Waiting for control message...
      Waiting for control message... done (after pressing one of the KORG padKONTROL pads)
      >> |

After twisting a knob on the padKONTROL (or tapping one of the pads, but note that the pads will only work for this after the trigger pad TYPE is set to CONTROL CHANGE as noted above). If the USB device is sending signals, Matlab should recognize this. As soon as you twist the knob, the console will print done. As you see, the midiid function returns two pieces of info, (1) the name of the device (e.g. padKONTROL) is now saved in the variable device, and the ID of the knob/pad that sent the signal, saved in the variable ctl. You can set the TYPE parameter to any value 1 through 127 using the padKONTROL Editor Librarian. Just enter a number within this range and press enter. Sometimes it will say something like “Volume Control” after then number (e.g. 1 – Modulation), but don’t worry about that – any specific preset feature (perhaps recognized by mixing software like Ableton Live Studio) will be ignored by Matlab. Also, Matlab automatically adds 10000 to any number you set for that particular control trigger. So for example if you assign “1” to a tap pad, the value stored in ctl will be “10001”, if you assign “28” to a tap pad, the value stored in ctl will be “10028”. NBD right? right. These individual control trigger assignments will be important later when I touch on the ‘midisync(ctl,v)’ function.

The SWITCH TYPE can be set to Momentary or Toggle. When set to Momentary the trigger will briefly switch from it’s ON VALUE to the RELEASE VALUE then reset back to the ON VALUE (the specific values of which can be set below). On the other hand, when the SWITCH TYPE is set to Toggle, the trigger will switch from it’s initial ON VALUE to the RELEASE VALUE, and stay there until the pad is pressed again, at which point it will switch back to the ON VALUE.

ON VALUE:

Just as the TYPE parameter can be set to any value 1 through 127 using the padKONTROL Editor Librarian, so can the ON VALUE. Note that the TYPE and ON VALUE need not be the same. This value will be the initial value set to the control trigger upon initialization. The switching behavior of this value I already talked about above.

RELEASE VALUE:

Just as both the TYPE and RELEASE VALUE parameters can be set to any value 1 through 127, so can the RELEASE VALUE. The RELEASE VALUE and ON VALUE may or may not be set to the same value (there are reasons for doing either). I’ve already covered pretty much everything there is to know about this value above.

MIDI CH:

The MIDI CH can be set an integer 1 through 16, though, I don’t think this actually does anything. In my testing I’ve had pads set to all different channels and there is no perceptible difference in how they perform or how Matlab sees them.

PORT:

Lastly, the PORT parameter can be set to PORT A or PORT B. This value should be set to the output port of the padKONTROL. By now you should know what this is because in order to transmit and receive info between the padKONTROL and the padKONTROL Editor Librarian software, these had to be set in the padKONTROL Editor Librarian settings menu…

padKONTROL PORT

1. ControlNumbers are integer valued double-precision numbers. Each control on the MIDI device has a specific integer assigned to it by the device manufacturer. If ControlNumbers is , then the midicontrols object responds to any control on the MIDI device. As a result, midiread returns a double scalar.