Programming the Pocket Miku, Details, Part 5

Not all SysEx messages follow the exact same format. What they do share in common is that they start with “F0” (start of SysEx) and end with “F7” (end of SysEx).

The following information is taken from Polymoog’s NSX-39 MIDI Guide (in Japanese). The SysEx messages here are used to directly take advantage of the Pocket Miku hardware (specifically, changing lyrics strings, and using the Miku as a MIDI controller. The format is:

F0 – start of message
43 – Manufacturer ID (Yamaha)
790911 – Code to access the NSX-39 lyrics system
do d1 d1… – data
F7 – end of message

Or, in string format (remove the spaces before using in Java):

F0 43 79 09 11 do d1 d2 d3 d4 d5 … F7
Example: F0 43 79 09 11 01 F7  // Get Version

Contents of the data string are:

Request Version Data          d0=0x01 d1=N/A
Version Data Reply            d0=0x11 d1=NSX-39 version data
Lyrics Entry                  d0=0x0A d1=lyrics slot number   d2=character data
Request Command Slot Details  d0=0x0B d1=command slot number
Command Slot Reply            d0=0x1B d1=command
Change Command Slot           d0=0x0C d1=command slot number  d2=command
Command Direct Entry          d0=0x0D d1=command
Lyric Number Data Request     d0=0x0E d1=N/A
Lyric Number Data Reply       d0=0x1E d1=Slot number          d2=Slot data
Lyric Details Request         d0=0x0F d1=Slot number
Lyric Details Reply           d0=0x1F d1=character count      d2=character 1, etc.
Switch State                  d0=0x20 d1=000000ih             d2=0gfedcba
NSX-39 Status                 d0=0x21 d1=Status


Using SysEx to upload new lyrics to the NSX-39

There are 16 lyrics slots, numbered 0x00 to 0x0F, and slots 1-15 can hold up to 64 characters (15*64=960 characters total) each. (Slot 0 sends the lyrics to the USB port as MIDI OUT).) The data is written to Flash memory so the lyrics will be recalled on power On.

d0 = 0A
d1 = slot number (1-15)
d2-d65 = phoneme number data
Example: Writing “Konnichiwa Arigato” to the “A” button (slot 1) (Mistake in NSX-39 MIDI Guide on page 8.)

F0 43 79 09 11 0A 01 09 01 7B 40 36 77 00 70 0A 2D 02 F7

You don’t write to slot 0, since it’s used to transfer data to CPU RAM.
Slot 0 isn’t selectable from the NSX-39 front panel.

Slots 1-15 are stored to FLASH ROM. Writing to these slots can take several milliseconds, during which time the NSX-39 can not respond to MIDI messages.

During the write, the SysEx message status will read: F0 43 79 09 11 21 01 F7 (i.e. – Busy)
When writing is complete, it will change to: : F0 43 79 09 11 21 00 F7 (Not busy)

Slot 1-5: “A”, “I”, “U”, “E”, “O”
Slot 6-10: SHIFT+”A” – SHIFT+”O”
Slot 11-15: “VIBRATO”+”A” – “VIBRATO”+”O”

The phoneme list appears on page 10 of the MIDI Guide. You can have up to 64 characters per slot. The character numbers are 2-character pairs, and the data string is terminated with “F7”.
When the string is written to the NSX-39, the playback pointer will default to the first character in the list (position 0).


Using SysEx to Enter Commands

The Pocket Miku uses a 28-bit instruction format to customize the front panel buttons and keyboard operations.

d0 = 0D
d1-d4 = command (d1=bits 27-21, d2=b20-b14, d3=b13-b7, d4=b6-b0)

The full command table is on page 23 of Polymoog’s MIDI Guide.

Norma Model: 0A 08 00 00
Do Rei Mi Mode: 0A 08 01 00
Slot Select: 09 03 00 00 09 03 00 (slot number)
Slot select lets you change data for that slot.
Lyric Playback Location Select: 09 02 00 00 09 02 00 (location)
Changes the playback pointer to (location)
Note ON: 08 09 00 00 08 09 (Note #) (Velocity)
Note OFF: 08 08 00


Programming the Command Slots

The command slots are numbered 0-127, but only 0-119 are writable.
One slot can contain up to 255 characters.
Command slots are messages that are sent when a specific event occurs, such as pressing the SHIFT key or releasing VIBRATO+”A”. Each slot corresponds to one event.

d0 = 0C
d1 = Slot number
d2-d5 = 4-byte command

If an incorrect command is issued, the status message F0 43 79 09 11 21 02 F7 will indicate the error status (21 02 = error).

You can reset the command slot with F0 43 79 09 11 0C slot number F7

To clear the command slot: F0 43 79 09 11 0C slot number F7 0C 01 00 00 F7

The command slot table is on pages 28-30 of Polymoog’s MIDI guide.


Reading the Command Slots, Misc.

d0= 0B / 1B

To read a command slot, send F0 43 79 09 11 0B F7
The results will be returned on F0 43 79 09 11 1B …. F7

In a related fashion, getting version information (01), Lyric Number (0E) and Lyric Data (0F) have matching send/receive pairs (01/11), (0E/1E) and (0F/1F). In Java, to receive data from the NSX-39, you have to open up a transmitter, attach a sequencer to the transmitter, then read the track object to see if any data has arrived. It’s very convoluted.

The command slot table is on pages 28-30.


Reading the Switches

d0 = 20
d1 = 000000ih
d2 = 0gfedcba

bits 0-1 of d1 show the states of switches SW8 and SW9. bits 0-6 of d2 show switches SW1-SW7. When the user presses one of the front panel buttons, the associated bit will toggle between 1 and 0. This seems to be a read-only command.

SW1 = A
SW2 = I
SW3 = U
SW4 = E
SW5 = O
SW6 = Vibrato
SW7 = Shift
SW8 = Vol. Up
SW9 = Vol. Down

The following is transmitted by the NSX-39 when the “A” button is pressed.

F0 43 79 09 11 20 00 01 F7


System Status

The system status message indicates the current MIDI status of the NSX-39. This is automatically returned by the NSX-39, so to read it in Java, you need to open a Transmitter and read Sequencer Track data.

d0 = 21
d1 = status
(status: 00 = Not busy, 01 = Busy, 02 = Error)

Received error status:

F0 43 79 09 11 21 02 F7


Customizing the NSX-39 (Using the 0D command mode)

Certain operations can only be performed if the Pocket Miku is in NSX-1 Compatibility Mode, while other commands only work if Compatibility Mode is off. This mode can be switched using the SysEX command entry message (0D).

ON – 0A 06 01 00
OFF – 0A 06 00 00
MIDI Reset – 0A 07 00 00

Example, turning Compatibility Mode ON:

F0 43 79 09 11 0D 0A 06 01 00 F7

Example, turning Compatibility Mode OFF:

F0 43 79 09 11 0D 0A 06 00 00 0A 07 00 00 F7

If you want to use the NSX-39 stylus to control an external device without the unit making sounds itself, first switch to Normal mode:

F0 43 79 09 11 0D 0A 08 00 00 F7

Then, tell the NSX-39 to send the character data to Lyrics Slot 0:

F0 43 79 09 11 0A 00 mm F7

where “mm” is the Japanese phoneme character list you want to play, up to 64 characters. Now, when you touch the stylus to the carbon keyboard, the character data will go out to the external MIDI device.

While playing a lyrics string to an external device, you can decide to reposition the “current character pointer” to jump to a different point in the string. The commands are:

Set pointer: 09 05 00 00
Revoice: 08 01 00 00
Pointer increment: 09 01 00 00

Full string example:

F0 43 79 09 11 0D 09 05 00 00 08 01 00 00 09 01 00 00 F7

Adding a “click” sound when you press a button

The following is an example of the DIRECT_MIDI_3 command mode coupled with changing the instructions stored at a specific command slot. Command slots generally refer to push button status, such as switch 1 pressed, or SHIFT+ switch 2 released. In this mode, you send three 8-bit characters as four 7-bit characters with padded leading 0’s. For example, say you want to play the Open Triangle instrument from the Drum Kit sound bank when you press the SHIFT key. The normal three 8-bit string would be:

99 51 65

Where 99 = NOTE ON for channel 9
51 = note number for the Open Triangle
65 = The value to use for velocity

Removing bit 8 of each of the 3 bytes and padding with leading 0’s gives you the equivalent four 7-bit string of:

04 65 22 65

Then, to specify SHIFT pressed, use CS_SW_7D (11) from the table on page 28 in Polymoog’s MIDI guide as follows:

F0 43 79 09 11 0C 11 04 65 22 65 F7

To return the SHIFT key to normal, use:

F0 43 79 09 11 0C 11 00 F7

(0C = Change Command Slot)
(11 = Slot #11 : CS_SW_7D : SHIFT key pressed)


Previous Post
Leave a comment

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: