Programming the Pocket Miku, Details, Part 3


SysEx

System Exclusive messages are not part of the standard MIDI spec, and are specific to each given machine. That means that if you use SysEx messages in the sequencer in your song, they won’t have the same effect if you play the song on anything other than the Pocket Miku.

SysEx messages are like the other MIDI messages in Java, in that you use “setMessage()” to prep the data you want to send to the synth. But you use an object of the SysexMessage class to do it:

String s = “F0….F7”; // NO SPACES BETWEEN CHARACTERS!!!

byte[] byteMsg        = new byte[nLengthInBytes];
SysexMessage sysexMessage = new SysexMessage();

for (int i = 0; i < nLengthInBytes; i++) {
byteMsg[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
}

sysexMessage.setMessage(byteMsg, byteMsg.length);
nsxRcvr.send(sysexMessage, -1);

byteMsg is a byte string, meaning that you have to convert the SysEx message from a regular character string to a byte array. I stole the byte conversion code from the jsresources page.

NSX-1 SysEx messages have several patterns, but the rules are that they all have to start with “F0” and end with “F7”. In between those two markers you will probably have a 3-byte address (Most-Significant Byte, Middle-Significant Byte and Least-Significant Byte), a SysEx “type” identifier, and one or two bytes of data. In some cases, data is variable length, as when you’re programming the eVocaloid “song” string in a lyrics slot.

Yamaha divides SysEx into: Universal Real Time Messages, Universal Non-Real Time Messages, XG messages and eVocaloid messages.

Universal Real Time Messages (URTM):

The first three messages duplicate some of the earlier parameter messages: changing master volume and master fine and coarse tuning.

After this, we get Reverb, Chorus, After-Touch and Control Change.

The format for Reverb is:

F0 7F 0N 04 05 01 01 01 01 01 PP VV … F7

F0 7F – Fixed.
0N – N is the channel number.
04 05 01 01 01 01 01 – Fixed.
PP – Parameter number (00 = Reverb Type, 01 = Reverb Time, etc.)
VV – Value (00 = Room S, 01 = Room M, etc., for Reverb Type)
VV – Value (0-127 = 0-11s, for Reverb Time)
F7 – Fixed.

The format for Chorus is:

F0 7F 0N 04 05 01 01 01 01 02 PP VV … F7

All that changes is the the last “01” becomes “02”. Plus, there’s a few more parameters available (Chorus Type, Mod Rate, Mod Depth, Feedback, etc.)

Channel Pressure (Aftertouch):

F0 7F 0N 09 01 0M PP RR … F7

0M – M = Channel number (0-15).
PP – Parameter number (00 = Pitch, 01 = Filter Cutoff, 02 = Amplitude, etc.)
VV – 00 to 7F, effect depends on the parameter selected.

Control Change:

F0 7F 0N 09 03 0M CC PP RR … F7

Key-Based Instrument Control:

F0 7F 0N 0A 01 0M KK CC VV … F7

To be honest, I haven’t done anything with Control Change or Key-Based Instrument Control because they look like too much work. While they both require a “CC” value (the controller number), the only place where controller numbers are defined is in the table for Key-Based Instrument Control (0x07 = Volume, 0x0A = Pan, 0x5B = Reverb, 0x5D = Chorus).
Universal Non-Real Time Messages

Now we get to the messages that really matter. The first and foremost is turning General MIDI On and Off.

As mentioned previously, several of the Control Change and NRPN messages only work with GM ON (such as Reverb and Drum Cutoff Frequency). You can turn GM on and off from the Pocket Miku front panel by pressing Volume Up and Down, and “U” simultaneously (you’ll hear a little “click” sound if you do it right. This is not convenient if you want to change modes in the middle of a song.

The better way is to send a SysEx message:

F0 7E 00 09 01 F7  // GM On

F0 7E 00 09 02 F7  // GM Off

Note that while the MIDI spec shows “F0 7F XN”, “X” is ignored, and I find that “N=0” works fine.

I haven’t bothered with Scale/Octave Tuning. It just seems easier to use the sequencer or keyboard to shift scales.

 

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: