This is a short example written in Sibelius 7 and exported as a SMF.
The Sibelius and Standard MIDI File versions of this file are in the course common folder.
MThd is SMF Header Marker
MTrk is Track Header Marker
Number of bytes to follow
FF2F00 is End of Track Marker
Copy the 04ClassExamople60bpm.mid file from the Course Common folder to the iMac desktop.
Execute these commands in the terminal.
Hold down the Option key and select the data shown in grey.
Paste back into a new TextWrangler window.
Use grep to convert a space to a tab.
These are the delta times used in the MIDI file.
Delta Times | PPQ |
81 70 | 240 |
83 60 | 480 |
87 40 | 960 |
Optional:
Here's how to figure out what 81 70 means. This example is specific to two byte delta times.
Aren't you glad you don't have to do this! | ||||
Delta time | 81 |
70 |
||
Get the first hex byte (8 bits) | 81 |
|||
Convert to Binary | 1000 0001 |
|||
Bit And 81 with 0111 1111 (7F) | 0000 0001 |
|||
Bit Shift result left by 7 bits |
1000 0000 |
|||
Add second hex byte (70) to this value | 1000 0000 |
+ |
0111 0000 | |
Equals = |
1111 0000 | |||
Convert to hex. This is PPQ in hex. | F0 |
|||
PPQ in decimal is | 240 |
Here's how to figure out what 83 60 means. This example is specific to two byte delta times.
Delta time | 83 |
60 |
||
Get the first hex byte (8 bits) | 83 |
|||
Convert to Binary | 1000 0011 |
|||
Bit And 83 with 0111 1111 (7F) | 0000 0011 |
|||
Bit Shift result left by 7 bits |
0001 1000 0000 |
|||
Add second hex byte (60) to this value | 0001 1000 0000 |
+ |
0110 0000 | |
Equals = |
0001 1110 0000 | |||
Convert to hex. This is PPQ in hex. | 1E0 |
|||
PPQ in decimal is | 480 |
Here's how to figure out what 87 40 means. This example is specific to two byte delta times.
Delta time | 87 |
40 |
||
Get the first hex byte (8 bits) | 87 |
|||
Convert to Binary | 1000 0111 |
|||
Bit And 87 with 0111 1111 (7F) | 0000 0111 |
|||
Bit Shift result left by 7 bits |
0011 1000 0000 |
|||
Add second hex byte (70) to this value | 0011 1000 0000 |
+ |
0100 0000 | |
Equals = |
0011 1100 0000 | |||
Convert to hex. This is PPQ in hex. | 3C0 |
|||
PPQ in decimal is | 960 |
Track two should be in this form.
Delete rows 14, 15, 22, and 41.
Use the Excel DEC2HEX command to convert all hexadecimal numbers in data1 and data2 columns to decimal.
Left column used this Excel formula: =HEX2DEC( C14 )
Right column used this Excel formula: =HEX2DEC( D14 )
Paste Special by Values to replace data1 and data2 hex values with decimal values.
Copy data into MIDIDisplay. Set the Time Base to PPQ. Set the PPQ value to 480.
Play.
debugSMF is a MIDI tool I wrote to help you find errors in your standard MIDI file.
Execute this command in Terminal.
Formatted with tabs for display in Excel: Header: Format: 1 Tracks: 3 PPQ Division: 480 Start of Track 1 Time signature: 4/2/24/8 Key signature: 2, 0 Tempo: f4240 1000000 [M.M. = 60] End of Track FF 2F 00 Start of Track 2 MTrk 00 00 00 6e [Length = 110] PPQ Status Data1 Data2 0 PrgC 73 OK 0 Ctrl 121 OK 0 Ctrl 64 OK 0 Ctrl 91 OK 0 Ctrl 10 OK 0 Ctrl 7 OK ;Text: 3 0 NON 62 OK 240 NOF 62 0 0 NON 64 OK 240 NOF 64 0 0 NON 66 OK 240 NOF 66 0 0 NON 67 OK 240 NOF 67 0 0 NON 69 OK 240 NOF 69 0 0 NON 71 OK 240 NOF 71 0 0 NON 73 OK 240 NOF 73 0 0 NON 69 OK 240 NOF 69 0 0 NON 74 OK 960 NOF 74 0 End of Track FF 2F 00 Start of Track 3 MTrk 00 00 00 4a [Length = 74] PPQ Status Data1 Data2 0 PrgC 70 OK 0 Ctrl 121 OK 0 Ctrl 64 OK 0 Ctrl 91 OK 0 Ctrl 10 OK 0 Ctrl 7 OK ;Text: 3 0 NON 54 OK 480 NOF 54 0 0 NON 50 OK 480 NOF 50 0 0 NON 49 OK 480 NOF 49 0 0 NON 45 OK 480 NOF 45 0 0 NON 50 OK 960 NOF 50 0 End of Track FF 2F 00
See Reference page, Unit4, for free Hex editor downloads for Mac and Windows.
Address |
Hex Data |
ASCII data |
1. Change Instruments - Patch Change message Cn data1
2. Change Pan values - Control message Bn 10 data2
3. Change Volume - Control message Bn 7 data2
3. Change Tempo - Track 1 Meta Event FF 51 03 tt tt tt
Revised John Ellinger, January - September 2013