Saturday, March 29, 2014

Working with MT-32 & Yamaha FB-01 MIDI Files and Patches

1.  Description of the MT-32's Capabilities

The MT-32 consists of eight instrument parts and one rhythm/percussion part.  It calls them Parts 1-8 and R.  Any part can be assigned to any of MIDI channels 1-16.  The default is that parts 1-8 are assigned to MIDI channels 2-9.  There is a setting to change this to MIDI channels 1-8.  The rhythm/percussion part is always assigned to MIDI channel 10 by default.

These parts share 32-voices/notes of polyphony, but the dynamic allocation of polyphony is not efficient over 22-24 voices, especially on a first generation unit.  The MT-32 does support an Overlow Assign mode where excess polyphony can be sent to a second MT-32 unit, but operation in practice is unreliable with first generation units.

A patch, which contains all the essential information for an instrument, is assigned to each part. Each patch can require up to 4 voices/notes to play, so there are restrictions on the sounds that can be played from the module. The use of multiple parts enables the MT-32 to be called Multi-Timbral, hence the name.  This is done via a Program Change MIDI message, and the MT-32 contains built-in 128 instrument patches and 30 rhythm patches.  A patch is made up of a timbre plus the patch parameter.  Timbres are made up of up to four partials and common parameter setting for all partials.  Each partial has many settings which can be individually controlled. Each partial takes one polyphony note/voice and can use either a waveform (square, rectangle or sawtooth) or a 16-bit PCM sample (128 available) as the basis of its sound.

A patch can call on four timbre banks, A, B, M & R.  Timbre bank A corresponds to the first 64 built-in patches of the MT-32, bank B the second 64 built-in patches, bank R corresponds to the 30 percussion patches of the rhythm section (and the 33 sound effects of the LAPC-I/CM-32L), and bank M corresponds to an area where up to 64 user-created timbres are stored.

The MT-32 is a synthesizer because user created patches can be stored and recalled from memory.  The SC-55, by contrast, is not a synthesizer.  While each of the patches used by the 16 parts of the SC-55 can be adjusted similarly to an MT-32 timbre, there is much less flexibility and you can only modify the active patch.  While the SC-55 is battery backed, this is intended to store the general settings of the module.

To dump or send custom patch/timbre data to the MT-32, System Exclusive MIDI messages are required. The sysex messages for patch/timbre data are unique to the MT-32 series and sequencers do not understand what they do.  Moreover, most sequencer programs assume that Program Changes correspond to General MIDI instrument assingments, but the MT-32 has very different assignments.

2.  Format of MT-32 Patches

The structure of an MT-32 patch, as contained in a sysex file, is as follows :

Length in Bytes (Decimal) MT-32 Area Sysex Receive String
33 System Area F0 41 10 16 11 10 00 00 00 00 17 59 F7
154 Patch Temporary Area F0 41 10 16 11 03 00 00 00 01 10 6C F7
266 Rhythm Setup Temporary Area F0 41 10 16 11 03 01 10 00 02 00 6A F7
360 Rhythm Setup Temporary Area (CM-32L) F0 41 10 16 11 03 01 10 00 02 54 16 F7
1064 Patch Memory F0 41 10 16 11 05 00 00 00 08 00 73 F7
17024 Timbre Memory F0 41 10 16 11 08 00 00 02 00 00 76 F7

The various areas can be in any order, since each area is separate and independent in the MT-32's memory. The temporary areas may not be required to be transmitted.

The MT-32 sends and receives data in packets no larger than 256 bytes (really 128 bytes, see below).  In order to send or receive bytes to the MT-32's various memory areas, System Exclusive messages are required.  Each message adds 10 bytes to the data to be transmitted.  By doing the math, up to 71 (MT-32) or 72 (CM-32L) System Exclusive messages may be sent at the start of a game to a LA synthesizer.  The structure of a system exclusive message is as follows :

F0 - Begin System Exclusive Message

41 - Manufacturer ID (Roland)

10 - Device ID/Unit # (Default is Unit 17)

16 - Model ID (Roland LA Device)

11 - Command ID (Request Data 1/RQ1)

This is sent from the computer to the synthesier to tell it to send the data in a memory area to the computer.  Command ID 12 is Data Set 1/DT1, and it is used when writing data to the synthesizer.

10 00 00 - The address of the area of memory to be addressed

00 00 17 - The number of bytes of data to be requested with RQ1.  With DT1, this can be up to 256 bytes with a single sysex command.

59 - Checksum

F7 - End of System Exclusive Message

The sysex files from Quest Studios also include an MT-32 Display Message at the beginning and at the end of the sysex file, adding approximately 58 bytes to the file.  The format of these commands is as follows :

F0 41 10 16 12 20 00 00 xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx ck F7

The Display of the MT-32 supports 20 characters, but the command data need not include all twenty character places.  Text is encoded in 7-bit ASCII.  You will have to calculate the checksum for the message.  You can find a Windows program that will avoid that tedious business here :

http://www.bwalk.com.au/Convert/Convert.html

This program can be used to convert text file containing command strings into a syx or a mid file :

http://www.bwalk.com.au/MidiUtil/FileConvert.html

Note that addresses and data never use a value above 7F, this is because these bytes are actually 7-bit bytes, not 8-bit bytes, the high bit is never used.  The above program can convert decimal and hexadecimal to the 7-bit values the MT-32 uses.

With a rev. 0 MT-32, there must be a 40 microsecond delay between the sending of system exclusive messages.  Thus it will take a minimum of three seconds to send a full patch bank to the MT-32.  The rev. 1 MT-32 and all other MT-32 compatible LA synthesizers do not have this limitation.

There is no reason why you cannot send more than one dump receive request at one time.  You can combine all the above dump receive commands into one file and use the file to obtain all the data at once.  The resulting file size for the MT-32 will be 18,541 bytes.  For the CM-32L, it will be 18,635 bytes.  After accounting for the text messages, this dump will be 16 bytes larger than the Quest Studio's dumps. This is because QS missed the temporary patch area for the rhythm part.

Yamaha FB-01 and IBM Music Feature Card

The Yamaha FB-01 FM Sound Generator supports seven patch/voice banks.  Each bank can hold up to 48 patches.  Banks 1 and 2 are RAM banks and this is where users can store their custom patches.  Banks 3-7 are ROM banks and have 48 patches each.  As its name suggests, these are the built-in patches.  Unlike the MT-32, there is no distinction between instrument and percussion channels/patches.  Thus the device supports 240 built-in patches and 96 user-created patches.

A Program Change command only works with numbers 0-47, essentially confining the non-FB-01 aware device to a small subset of its available patches.  To change the patch/voice bank requires a System Exclusive command to change the configuration parameters.  This is how another voice bank is selected.  The FB-01 has 16 RAM and 4 ROM choices for its Configuration Memory, which assigns MIDI channels, polyphony reserve, channel volume and the like.

The FB-01 receives 8 MIDI channels (8 parts), and by default uses MIDI channel 1-8.  It only supports 8 simultaneous note playback (8 note polyphony).  Each instrument patch can take from 1-8 notes.  The core of the device is the Yamaha YM2614 FM Operator Type-P, which is musicially and (almost) functionally identical to the YM2151 chip found in many, many arcade machines.  This chip supports 4-operator FM synthesis.

Sierra's games store custom patches in both RAM banks, so both will need to be dumped.  The FB-01 can only receive System Exclusive messages on the MIDI channel assigned to a specific module (thus up to 16 modules can be supported via the MIDI channels) The default is channel 0/1.  The system exclusive commands to do this are as follows :

F0 43 75 00 20 00 00 F7 (Voice Bank 0)
F0 43 75 00 20 00 01 F7 (Voice Bank 1)

Each resulting file will be 6,363 bytes.

Additionally, you may also need to dump the configuration memory.  The command to dump all configuration memory is :

F0 43 75 00 20 03 00 F7

The file will be 2,616 bytes.

Sierra's games also use System Exclusive messages to change instruments and voice banks and adjust certain events like Note On and Note Off with a finer degree of control than possible with a standard message.  This sysex is not generally large, but must be included to obtain an accurate rendition of the song.

This method works with either the IBM Music Feature Card or the FB-01.  The makers of the FB-01 helpfully also decided to allow you to also send data from the module using the front panel buttons, but using the sysex above allows for saving the resulting data in one step.

The IBM Music Feature Card defaults to the memory protection function to off.  It does not have a battery.  The FB-01 defaults memory protection to on and has a spot-welded CR2032 battery.  It needs to be set to off for custom patch data to be received by the FB-01.  The IBM Music Feature Card's power on defaults allow all MIDI messages to pass from the MIDI IN (with the breakout box) to the music hardware on the card.

When the FB-01 or IBM card receives patch/configuration dumps, it will send back the following sysex : F0 43 60 0x F7.  The 02 indicates an ACK, 03 indicates error, and 04 usually means you forgot to set the memory protection to off.  The FB-01 will also show dump/received!! for a good dump, a dump/error for a bad dump and memory/protect if the memory protection is on.  If you send all three sets of data, you will see the above sysex three times in the monitor.

If you want to send one sysex file to dump all three areas, put the configuration memory command first, then followed by the voice bank commands.  I have found that the FB-01 will not acknowledge the configuration memory dump if it immediately follows a voice bank dump command.  If it still doesn't work, send the dump commands as separate sysex files.  A complete sysex file with all three areas will be 15,342 bytes, and should have the configuration memory sent first.

Capturing MT-32 or FB-01 Music

In order to obtain MT-32 or FB-01 song data, the following steps must be accomplished :

1.  Capture the custom patches, if any

Not all games that support the MT-32 use custom patches.  Games like King's Quest IV, Police Quest II, LOOM, The Secret of Monkey Island and Ultima VI do not use custom patches.  However, they may still use a modest amount of sysex to modify existing patch and device parameters.  Most games only load patches once, but some games like Ultima VII and Serpent Isle load three sets of patches, and each must be captured to capture all the music.

Fortunately, most games do not send an MT-32 reset once the player quits them.  Additionally, MIDI cables are hot-swappable, so there are many ways to cut off a game and preserve its patches.  So the first task is to start a game and let load its patches, then quit.  The patches will be kept in the MT-32's memory.

The next step is to obtain those patches.  If you are looking to dump a Sierra game's patches, the work has probably already been done and you can skip this step.  Download the Sierra MT-32 Sound Library here : http://www.midimusicadventures.com/queststudios/mt32-resource/utilities/

The way I present here is a slightly tedious process, but typically you need only do it once per game.  It requires a windows-compatible MIDI interface and the MIDI-OX program.  The module will need to have its MIDI in and MIDI out cables connected to the interface.  I found that an rev. 0 MT-32 did not send all the data to MIDI-OX, but a CM-32L did.  The idea is to send sysex commands requesting that the module send the data in its memory.  You will need one command for each section of memory, then you will need to save the resulting data to a file and perhaps convert it from text to a binary sysex file.

MIDI-OX is good because it has command called "Send/Receive Sysex", which will automatically save your data to a .syx file.

Note that an LAPC-I will not work to capture patches in this way. The LAPC-I is equilavent to an MPU-401 connected to a CM-32L by a MIDI OUT cable only.  As there is no MIDI IN connection, the synthesizer has no way of sending data to the MPU-401 and thus the computer has no way to read it.  The SCC-1 and all wavetable daughterboards have the same issue, but typically patch information is not requested from those devices.

When capturing a dump, do not use a crappy UART MPU-401 compatible interface like the ones found on a Sound Blaster 16.  They failed to complete transfers of the MT-32's timbre banks.

2.  Record the MIDI as played in a game

DOSBox is extremely useful for recording MIDI via its Capture Raw MIDI function.  It saves all MIDI data to a MID file for easy editing in just about any sequencer.

You can also do this via a sequencer, which should be able to record MIDI data.  This works best with two computers.  In this case, connect the MIDI IN from your interface on computer one to the MIDI THRU of your MT-32.  Computer two, preferably the older machine, will play the game and connect its interface to the MIDI IN of your MT-32.

3.  Edit MIDI in Sequencer

In order to work with any MIDI file, you need a Sequencer.  The best two sequencers back in the day were Voyetra Sequencer Plus Gold and Cakewalk Pro.  Since we are talking to the MT-32, it is best to use vintage sequencers, and Quest Studios provides Voyetra's software for DOS and Cakewalk for Windows 3.1  Find them here :

http://www.midimusicadventures.com/queststudios/mt32-resource/utilities/

Both work in DOSBox, but because DOSBox does not implement the MIDI IN function, their functionality is somewhat crippled.  Personally I prefer Cakewalk Pro.

MIDI files can be edited in a Sequencer similarly to how audio files are edited in an audio editing program.  In this case, however, you will want to remove all the patch data that DOSBox captured.  For the MT-32, DOSBox will fill all 256 banks (and they are not enough) with the patch data.  Delete all of it with the Event List View.  Do not delete any other sysex.  For the FB-01, DOSBox will not completely capture the voice bank data, but you must only delete the sysex banks with the size 1024.

One thing you will want to do is to mute or delete any channels other than 2-10 for the MT-32.  In Sierra's early SCI games, for example, channel 1 contains PC speaker data and channels 11-15 contains Adlib data.  A CM-64 and CM-500 use channels 11-16 for their CM-32P and thus unintended sound will play on these channels if you are using those modules.

Cakewalk has the ability to play MIDI files, and you should avail yourself of this functionality. However, before you play a file, make sure to transmit the sysex patch bank with the Sysx view first.  Find an empty bank and send it.

4.  Embed patch to MIDI file (optional)

Cakewalk Pro uses .syx files to load patch banks in its bank manager.  Load the .MID, go into the Sysex View page and load the sysex bank.  Click on the Auto button and save your MID file.  That is it!  Additionally, it may be advisable to also embed an MT-32 reset sysex command so that you are sure you are not using any leftover data from any MIDI you played on the device prior.  Finally, you may want to add a few extra measures of silence at the beginning of the song.

I do not believe that embedding is the best way to present these files.  Many MIDI players have difficulty with large files or files with lots of sysex in it.  Windows Media Player does not have any such issues, nor does DOSmid.

No comments: