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.

Are we alone?

Every so often, after too many cocktails, someone asks the question – “Do you think there are aliens out there in the cosmos?” My answer is always the same… “Probably not. At least not the kind of lifeform we could ever fathom in our wildest dreams.” The standard reply is, “But the universe is so big! You don’t think there’s a planet out there like Earth?” So then I clarify… to me it’s not about whether there’s a planet out there like Earth; I presume there are many planets in the universe capable of supporting life. The issue is, the random events required to turn ‘non-life’ into ‘life’ seem incredibly improbable. However, if a planet does somehow beat those odds and a tiny microbe springs forth from its muddy waters, evolution appears to proceed steadily towards entities with greater and greater complexity and intelligence. Eventually the planet will produce a being with human-like cognitive faculties, and once it does, it won’t take them very long to become extremely advanced. On a cosmological time-scale, it was merely a blink of an eye between the time humans crawled out of caves and into spaceships. There’s no telling what earth will be like when the eye finally opens in the next blink, but humans will be long-gone. Not because they went extinct per se, but because they transformed themselves into something we couldn’t comprehend… not in our wildest dreams.

I made a short animation to give you a better idea of what I mean when I say…

“a blink of an eye”

My Mac Hardware Upgrades and OSX Tricks (Part 1)

PowerBook G4

Tip #1: A SMARTER WAY TO SHOP FOR YOUR NEXT LAPTOP COMPUTER
When it comes to buying a new computer, here’s how to play it… If you want a desktop build your own PC (it’s easier than you think); but if you want a laptop, get an Apple.

  • Buy a refurbished Macbook Pro from the official apple store – the one with the 2nd fastest CPU currently available (super important note: none of this info applies to the new Retina models, because they’re impossible to upgrade – everything is soldered together) . After building my own computer I’ve gleaned that the price for computer parts scales linearly with performance, up until the “#1 best” part, which is always significantly more expensive than the 2nd best. For example if intel’s current line of CPUs included a 2.1, 2.2, 2.3, 2.4, and 2.5 GHz i7 CPU, the prices will be something like $100 $140 $180 $500. Don’t pay the “rich person” tax just to have the best one currently available – in a few months it will be 2nd best anyway. Instead, save that money and invest it in upgrades (described in the next post) that will make an actual difference in your laptop performance – I’m talking huge friggin differences. That said, definitely get the 2nd best CPU available (or the best one you can afford), it is the workhorse of your computer and it can’t be upgraded.
  • When you’re shopping for a new laptop only focus on two things: the CPU and GPU (graphics processing unit). Apple, Walmart, BestBuy, Fry’s, they are all guilty of it – their ads and employees make every effort to draw your attention away from these specs, and instead make you focus on things that don’t matter to us, like RAM and HDD (memory and hard disk drive storage) capacity. I think it’s amusing that computer ads never list the CPU or GPU specs (just: “Intel i5!“); instead they try to sell you on the RAM and HDD specs: Frys Computer AdThe reason they do this is because memory is cheap while CPU speed is expensive. So if they can convince you that a computer is worth $200 dollars more because it has a 750 GB HDD instead of a 500 GB HDD, they just scammed you out of $150 bucks. At the same time, they try to make you think an Intel 2.1 Sandy Bridge CPU is almost the same as an Intel 2.4 GHz Haswell CPU (in fact, they will never even mention the microarchitecture). Ohhh but they will indeed try to scam you. Walk into BestBuy, and ask Brendan to help you pick out a computer (there will be a BB employee named Brendan). Odds are, he’ll say something like “Hey man, think about it, 2.1 and 2.4 GHz is only 0.3 different so don’t even worry about that man, they’re basically the same. This other computer though, it has 250 gigabytes more memory, that’s a lot more bro! Do you like pictures? Yes?! Sir, trust me, you will need the one with more memory“. I of course, do the exact opposite of what Brendan suggests. In fact, when buying a laptop I care 0% about the amount of RAM and HDD capacity it has, and shop solely based on CPU and GPU specs. Why? Because I know I’m being overcharged for RAM and HDD capacity from the retailer, and will likely be upgrading both of those things anyway. So, the less RAM and HDD space it has off-the-shelf, the better; and the more cores and faster clock speed the CPU has and GPU have the better. Here’s my equation homebrew equation to help with this comparison – we’ll call it Brads Bang For Buck ( BBFB) score:

BLBB = (CPU + GPU) / (RAM * HDD)

To calculate the “BBFB” for the laptop you’re thinking about getting, first, you’ll need to look up the benchmarks for the GPU and CPU you’re considering. Go to notebookcheck.net and get the 3DMark06 Score for the GPU. Then head over to cpubenchmark and get the CPU PassMark score. Write those scores down here (along with the RAM and HDD capacity):

GPU 3DMark06: _________

CPU Passmark: _________

RAM Capacity: _________

HDD Capacity: _________

We’re looking to get a “BBFB” above 1.0 and the higher the better. Say you’re looking at a laptop with an Intel Core i7-4710MQ 2.50GHz CPU and an AMD Radeon HD 6770M GPU. Those scores would be …

GPU 3DMark06: __8023___

CPU Passmark: __10056__

RAM Capacity: ___12____ GB

HDD Capacity: ___750___ GB

Now we can finally calculate the BBFB using the standard equation:

BBFB = (CPU + GPU) / (RAM * HDD)

BBFB = 18079 / 9000

BBFB = 2.0

Finally, how interpret this value… If you’re looking at two different laptops, and they are both roughly the same price, get the one with the higher BBFB score! You’ll be glad you did.