K-Gater, Part 2


Some ground work:

The Korg K-Pro is what’s called a phrase synthesizer, or loop recorder.  It has the x-y grid touchscreen, the gate arp, 8 programmable voice buttons, 200 voices (184 voices and 16 vocorder effects that require an external mike or sound source) and 4 recording pads.  It’s monophonic, meaning you can only play one note at a time, and the basic idea is that you lay down loops to one of the 4 recorder channels; generally each loop is 2 seconds long, and you can have as many sounds one atop the other as you like (although, after 4 or 5 sounds, it all blends together and you can’t edit individual layers).  If you don’t want to make loops, you can still use the K-Pro as a monophonic instrument, one instrument at a time (using the 8 programmable preset voice buttons to quickly switch instruments on the fly).

The K-Pro only has one MIDI IN and one MIDI out port, as well as a USB port.  No MIDI THRU.  In MIDI controller mode, most of the controls can be mapped using the separate K-Pro MIDI editor software.   In MIDI IN mode, the K-Pro only recognizes touchpad notes, volume change, BPM change (beats per minute, for the loop recorders), the 4 recorder channel on/offs, and changing voice programs.  Changing volume and instrument voice are regular MIDI messages, but just about everything else uses CC codes.

Since there are 200 voices, and MIDI can only select between 0 to 127, you need to select one of two banks.  I implemented this in 3 messages as follows:

myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 0, nbank);    // Select the lower bank
rcvr.send(myMsg, timeStamp);
myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 32, bank);    // Select the upper bank
rcvr.send(myMsg, timeStamp);
myMsg.setMessage(ShortMessage.PROGRAM_CHANGE, midiPorts.kProChannelNo, voice, 0);       // Change voice

nbank is just the opposite of bank.  If bank = 1, nbank = 0 and vice versa.  The two CC messages changes the bank, and PROGRAM_CHANGE selects a voice from 0 to 127.

Selecting a note on the x-y pad requires 3 CC messages:

myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 12, row);
rcvr.send(myMsg, timeStamp);
myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 13, col);
rcvr.send(myMsg, timeStamp);
myMsg.setMessage(ShortMessage.CONTROL_CHANGE, midiPorts.kProChannelNo, 92, onOff);
rcvr.send(myMsg, timeStamp);

As the code indicates, the first message selects the row (from 0 to 127), the second the column (0-127), and the third sets the note as either on or off (1 or 0). Turning on a new note turns off whatever is already playing.  To do an “all off”, just pick a note at random and set it to 0.

—-

One of the drawbacks I encountered with using Java on a Win 7 PC is that the system never updates if you turn on the K-Pro after starting the Java app.  That is, when you start the app, Java gets a list of all MIDI devices running AT THE TIME. If you turn on the K-Pro later, Java won’t see it.  According to some of the people on the Java forums, system refresh is supposed to occur every 60 seconds, but you can set it to be shorter.  After 5 minutes, Java still didn’t see the K-Pro.  I exited the app and started it again right away, and the system then recognized the existence of the K-Pro.  I’ll think about making a workaround for this later.

And, for those of you that have laptops without MIDI connectors, don’t worry.  The USB interface works pretty much the same as having physical MIDI plugs.  You just need to give the laptop time to start up the USB driver.

—-

I figured that if I was going to go this far in creating a gate arp for the K-Pro, that I might as well implement the default Java software synth at the same time.  That way, if I don’t have the K-Pro out, I can still make noises with the arp and the default synth.  So, I assigned 8 buttons in my app to K-Pro voices, and another 12 to the default synth voices.  As mentioned above, the K-Pro only supports one note for one instrument at a time, so I just have it on channel 1 (channel 0 in Java).  All 8 K-Pro voice buttons go to Java channel 0.  As for the default synth, I simplified things by having each instrument on its own MIDI channel.  This way, I can set the voice once, and simply select it as part of the MIDI Note_On/Note_Off message when I specify the channel number for the note.  I decided to stay monophonic for this version of K-Gater.  Later, I might support having multiple notes playing at one time.

(I noticed just recently that I called the software synth preset buttons “channel 2”, “channel3”, etc., but that I allow the user to reassign the starting synth channel numbers to 0 through 3.  Originally, I had the starting channel hardcoded to 2.  What I should do is change the button names to Voice 1, Voice 2, etc.)

I did make the channel numbers software selectable, to an extent, and I left room for adding the Roland keyboard.

I’m assuming that the following restriction was a deliberate decision on Korg’s part, but, when you get the list of MIDI info from System, it doesn’t identify the K-Pro as a synthesizer.  That is, when you ask for all of the MIDI devices currently running, you can query to see if they belong to the synthesizer or sequencer classes.  If so, you can create an object of the synthesizer class, open a receiver to the device, and use all of that object’s methods for doing things like getting the sound bank, checking channel numbers, etc. Unfortunately, the K-Pro doesn’t support the synthesizer class, so it must be opened as just a MidiDevice.  With a MidiDevice object, your only options are: getting the name, getting the description, getting the vendor name, getting the version, and sending MIDI messages.  If you want to display a list of instrument names from a combo box, you have to get that from the user manual, type it up, and hardcode it into your app.  I guess Korg’s decision was that since most everything is controlled by CC messages, there was no point in implementing the synthesizer class support into the windows driver.

—-

Finally, a comment on Java timers.  Java has a couple different timer classes (util, swing) and all of them clobber each other if you want to set up two or more timer objects with independent methods. At least, I was never able to get two different timer objects to run simultaneously without interfering with each other, and the people I talked to in the Java forums indicated that they didn’t know of a way to make this work, either.  I want to have a metronome, and I want the gate arp.  The metronome can tick off between 1 and 4 times a second, while the arp timer needs to go anywhere between 1ms and 4 seconds.  After messing with this problem for way too long, I settled on the simplest solution: Use one timer, set it to 1ms, and then just increment counters.  When a given counter reaches the specified count, call one of two methods.  Again, I’m not a professional Java programmer – I just want something that works so that I can play with the K-Pro – so, I’ll settle for the solution I can get working first.

Advertisements
Previous Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: