Understanding MIDI Sample Dump (Yamaha SU-10, etc.)

After losing almost another entire day due to erroneous information on the interwebz, I decided to write a small guide to help you understand (and convert) this old dinosaur known as “MIDI Sample Dump”, sometimes referred as MSD or MDSD.

Now, a quick crash course/refresher about Decimals, Hexadecimal and Binary formats.

Decimal is the system we all use, numbers going from 0 to 9 and so on and so forth.

Hexadecimal is actually pretty similar.
Numbers are expressed as two bytes and up to 09 they are identical to the Decimal system.
The difference is that where Decimal goes from 0 to 9, Hexadecimal goes from 0 to F.

Let’s make a misleading example with 10.
You might be tempted to say that this is 10 in Decimal as well, but it is actually 16.
Let’s count (hex and dec):
00 (0), 01 (1), 02 (2), 03 (3), 04 (4), 05 (5), 06 (6), 07 (7), 08 (8), 09 (9), 0A (10!), 0B (11!), 0C (12!), 0D (13!), 0E(14!), 0F (15!), 10 (16!)

As you can see, as stated, everything is normal up to 9, but then the counting changes because Hex has A, B, C, D, E and F, in addition to the traditional numbers.

Another misleading example could be 23 as you might again be tempted to say that it’s 23 in Dec as well.
Let’s count again (but not from the start):
[...] 10 (16) - 20 (32), 21 (33), 22, (34), 23 (35)

Just because the number in Hex seems like a Decimal it doesn’t mean it’s the same!
Always make sure to count (or use an online converter).

Let’s now double down with another refresher about Binary format.
The only values are 0s and 1s so how do we express big numbers? By stringing them together.
Starting from right to left, each number represents a power of 2, starting with 0.
2 to the power of 0 is 1
2 to the power of 1 is 2
2 to the power of 2 is 4
2 to the power of 3 is 8
2 to the power of 4 is 16
2 to the power of 5 is 32
2 to the power of 6 is 64

So this binary is the equivalent to 36:

0100010

Because, starting from left to right:
0 * (2 ^ 6) = 0
1 * (2 ^ 5) = 32
0 * (2 ^ 4) = 0
0 * (2 ^ 3) = 0
1 * (2 ^ 2) = 4
0 * (2 ^ 1) = 0
0 * (2 ^ 0) = 0

So 32 + 4 = 36

Simple, right?

Now, time to get our hands dirty.

The gist is this: a MIDI Sample Dump is a sysex dump like many others, as such it has a header holding several information about the sysex content and is made of the following bits:

F0 7E cc 01 ss ss ee ff ff ff gg gg gg hh hh hh ii ii ii j j F7

What’s most important to us is understanding the bit depth and sample rate of our dump, which are ee and ff ff ff.

You can read what the rest do here (and ONLY THAT, because most other information there is incorrect).

ee represents the bit depth
ff ff ff are three bytes which represent the bit depth expressed in nanoseconds

To get the MIDI Sample Dump from your sampler, you can use a software like Sysex Librarian, making sure to choose “Record Many” and not “Record One”

Let’s make an example: F07E0001 0C001017 1F057A27 00000000 7927007F F7

Getting the bit depth of the dump is pretty easy: it’s ee.
Our ee is 10 which means that our dump is 16 bit.
Now, onto the real mess: getting the frequency of our dump.
It is made of 3 hexes (hence 3 bytes) and they are IN REVERSE ORDER.

Our ff ff ff is 17 1F 05 which we will analyze to determine the frequency.

Let’s break it down.

As said already, the bytes are inverted.

First byte (17) represents the last seven bits (14-20)
Second byte (1F) represents the second seven bits (7-13)
Third byte (05) represents the first seven bits (0-6)

Conversion
(Hex to decimal to binary)

First seven bits: 05 = 5 = 0000101
Second seven bits: 1F = 31 = 0011111
Third seven bits: 17 = 23 = 0010111

Result

0000101 0011111 0010111

Clear highest bit (MSB) and right align

10100111110010111

Convert to decimal

10100111110010111 = 85911 ( = 85,911ns = 0,000085911s)

Convert to frequency

1 / 0,000085911s = 11639,952974589983Hz ~ 11.64Khz

…and there you have it.

Now, after the sysex header, the actual waveform data is transmitted in chunks of 127 bytes, 7 of those are the header of the chunk and has the following format:

F0 7E cc 02 kk <120 bytes> mm F7

cc is the MIDI channel number where the data is being transferred
kk is the packet count to order the packets being transferred. It starts from 0 and goes up to 127 and then warps back to 0
mm is the checksum of the packet

You can easily code in Bash or whatever language you’re most comfortable with a script that:

  1. Detects the bit depth
  2. Calculates the frequency
  3. (Optional) Calculates all the other parameters such as loop point, etc.
  4. Strips the file of the MIDI Dump Sysex header
  5. Strips the chunks of their header and extracts the data
  6. Concatenate all the extracted data into a single file
  7. Converts it to format of your choice using SoX, ffmpeg, etc, by feeding it the information you got from the first two points
  8. Profit

Hopefully that has shed light on how this ancient format works and has improved your understanding of it.

Thank you for reading!

P.S.: I almost forgot.
Instead of doing all of this nonsense, you can just load the .syx dump onto Audacity and be done with it. Audacity automatically recognizes all the parameters.
Sorry.

Leave a Comment