K-Gater Ver. 3


I’m now up to K-Gater version 3. Version 1 was when I just started out and didn’t really understand the way the Kaossilator Pro behaves compared to the software synthesizer, and I didn ‘t have the Roland A-300 Pro midi controller keyboard. The code worked, but it wasn’t very efficient and it only sent data in one direction – out to one of the two players. With version two, I added the A-300, and moved some of the K-Pro receiver handling code out of the Change Instrument and Play Note methods. I also broke the initInstrument code in two, making the process of obtaining MidiDevice objects more modular. The next step was to figure out how to open transmitters to the A-300, set up the sequencer-sequence-track combinations, and then read incoming MIDI messages prior to interpreting them and passing the results to either the K-Pro or the software synth There were a few minor tweaks as well, such as making the metronome button flash red on the beat counts.

Version 3 was mostly intended to just add polyphony to the arpeggiator. It also ended up being a shake-out stage, where I had to do a lot of unexpected bug fixing. And I moved a few of the variables around to put them into a new class for recording NOTE_ON/NOTE_OFF events.

Originally, I just wanted to take MIDI NOTE_ON and NOTE_OFF messages from some keyboard device and convert them to CONTROL_CHANGE messages to send to the K-Pro. While I was at it, I figured I might as well add the arpeggiator ability. And that’s where a certain limitation crept in. I was only tracking one key at a time for ‘pegging, which sacrificed the polyphony (ability to play two or more notes at a time) supported by the A-300 and the software synth. Under most conditions, I expect that musicians won’t ‘peg chords, but it did make it difficult to smoothly transition from one note to another with the arp turned on. I had to release one key and wait a fraction of a second before pressing the next, and that produced a noticeable break in the ‘pegging.

The obvious solution was to convert the single variable to an ArrayList of key-NOTE_ON messages. To play the chords while ‘pegging or when changing preset voices, I just run through the array and send NOTE_ON for each key still being pressed. If a key is released, I remove that key from the ArrayList, and send a NOTE_OFF message to the instrument. This is fine in concept, but there’s a problem of losing notes when ‘pegging while changing instrument voices, so I turn all the notes off before changing the voice and then send new NOTE_ON messages afterward. Which brings me to the structure of the NOTE_ON message. We not only need to pass the number (0-127) of the note itself, but also the velocity (0-127). Velocity can either translate to “volume”, or it’s a measure of how hard the user hit the key on velocity-sensitive keyboards. If I’m sending NOTE_ON when ‘pegging or changing instrument voices, then I need to record the velocity with the note number. If I’m sending note off, I only need the note number, but now the velocity is associated with the note number within the keyPressed ArrayList and I need to mask it out when searching for the note number to be removed from that ArrayList. It’s not all that difficult to deal with, just kind of petty.

But, I found something else I didn’t quite like. When pressing a second or third key while ‘pegging, the notes get turned on or off in the middle of the arp note ON period and the result sounds sloppy. My solution was to buffer the NOTE_ON and NOTE_OFF events, storing them to their own ArrayLists, and then using removeBuffer() and addBuffer() methods to actually add and remove notes from the keyPressed ArrayList at the end of each arpeggiator time period. This results in a much smoother transition when ‘pegging from one key to another, but a new bug slipped in. Now, if you play a chord and both keys hit at the same time, one of the notes may get “stuck” in the buffer and the program will keep ‘pegging after you release all of the keys. The problem revolves around two NOTE_ON messages arriving at the PC at the exact same time and confusing the MIDI parsing process. So, I either don’t buffer and allow chord changes in the middle of an arp note on event; I buffer and try to avoid pressing 2 keys at the exact same time while ‘pegging; or I flush the keyPressed ArrayList when I turn the gate arp off (this is the work-around I settled on until I can fix the larger problem).

I haven’t decided what I’m going to do next. However, I’m spending more time on program debug than I am actually playing the keyboard. So I’m going to post the code now and come back to it again later when I have more time.

As I was going through the code, I realized also that the idea of a “base key” (jTextField2) for the arpeggiator was messing up my ability to change the keyboard bottom key and key spacing of the A-300 when driving the K-Pro. So I simplified the code and removed jTextField2. This gave me a little more room on the screen and I shortened the west, middle and east panels, and made the south panel taller. This gives me more room for displaying debug messages. Otherwise, the user interface is largely unchanged.

Formatted textfile.

 

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: