the_mus_file_format
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
the_mus_file_format [2011/11/06 18:26] – javapimp | the_mus_file_format [2023/08/18 18:15] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ====== MUS File Format ====== | ||
+ | |||
+ | //Vladimir Arnost//, QA-Software\\ | ||
+ | Updated: | ||
+ | Version: | ||
+ | Internet: | ||
+ | FIDO: | ||
+ | |||
+ | |||
+ | ===== 1. General Description ===== | ||
+ | |||
+ | A .MUS file is a simple clone of .MID file. It uses the same instruments, | ||
+ | |||
+ | NOTE: All numerical values mentioned in this document are zero-based. If not specified otherwise, all numbers are given in decimal. | ||
+ | |||
+ | ===== 2. MUS File Header ===== | ||
+ | |||
+ | The MUS header has the following structure: | ||
+ | |||
+ | <code cpp> | ||
+ | struct MUSheader { | ||
+ | char ID[4]; | ||
+ | WORD scoreLen; | ||
+ | WORD scoreStart; | ||
+ | WORD channels; | ||
+ | WORD sec_channels; | ||
+ | WORD instrCnt; | ||
+ | WORD dummy; | ||
+ | // variable-length part starts here | ||
+ | WORD instruments[]; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | NOTE: WORD is a 16-bit unsigned integer (little-endian) | ||
+ | |||
+ | The header has two parts: the fixed-length and the variable-length part. The former contains file identifier, score start and length, number of channels and number of used instruments. The latter part is actually a list of used instruments. The instruments are stored as numbers which are arranged in this fashion: | ||
+ | |||
+ | ^ Instrument Number ^ Meaning ^ | ||
+ | | 0 - 127 | standard MIDI instruments | | ||
+ | | 135 - 181 | standard MIDI percussions (notes 35 - 81) | | ||
+ | |||
+ | `scoreStart' | ||
+ | |||
+ | `channels' | ||
+ | |||
+ | |||
+ | ===== 3. MUS File Body ===== | ||
+ | |||
+ | Unlike MID files, MUS body contains only one track. File body is a sequence of sound events and time records. A sound event consists of one or more bytes encoded as follows: | ||
+ | |||
+ | 1st byte -- event descriptor: | ||
+ | < | ||
+ | +--7----6----5----4----3----2----1----0-+ | ||
+ | |Last| | ||
+ | +---------------------------------------+ | ||
+ | </ | ||
+ | `Event type' is one of these: | ||
+ | 0 - release note | ||
+ | 1 - play note | ||
+ | 2 - pitch wheel (bender) | ||
+ | 3 - system event (valueless controller) | ||
+ | 4 - change controller | ||
+ | 5 - ??? | ||
+ | 6 - score end | ||
+ | 7 - ??? | ||
+ | |||
+ | `Channel number' | ||
+ | |||
+ | `Last' - if set, the event is followed by time information. This means that this is the last event in a group of events which occur at the same time. The time information is a number of ticks to wait before processing next event. One tick is usually 1/140 sec (in Doom I, II and Heretic; Raptor uses 1/70 sec). | ||
+ | |||
+ | Time information can be read in this way: | ||
+ | 1. time = 0 | ||
+ | 2. READ a byte | ||
+ | 3. time = time * 128 + byte AND 127 | ||
+ | 4. IF (byte AND 128) GO TO 2 | ||
+ | 5. RETURN time | ||
+ | |||
+ | The time info is a series of 7-bit chunks. The bit #7 is set until the last byte whose bit 7 is zero. This scheme allows small numbers occupy less space than large ones. | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | +-7---6---5---4---3---2---1---0-+ | ||
+ | | 0 | Note number 0 - 127 | | ||
+ | +-------------------------------+ | ||
+ | |||
+ | | ||
+ | +-7---6---5---4---3---2---1---0-+ | ||
+ | |Vol| Note number 0 - 127 | | 0 | Note volume 0 - 127 | | ||
+ | +-------------------------------+ | ||
+ | |||
+ | `Note volume' | ||
+ | previous value is used and the second byte is not present. | ||
+ | NOTE: Each channel keeps track of its own last volume value. | ||
+ | More than one note can be played at once in one channel. | ||
+ | Channel 15 is dedicated to drums and percussions. `Note number' | ||
+ | acts as an instrument selector there. See Appendix C | ||
+ | |||
+ | | ||
+ | +-7---6---5---4---3---2---1---0-+ | ||
+ | | Pitch wheel value | | ||
+ | +-------------------------------+ | ||
+ | |||
+ | Sets pitch wheel (bender) value of a channel. Some handy values are | ||
+ | shown in the table (all values in the range 0-255 can be used): | ||
+ | |||
+ | +-------------------------------+ | ||
+ | | Value | Pitch change | ||
+ | |-------+-----------------------| | ||
+ | | 0 | two half-tones down | | ||
+ | | | ||
+ | | 128 | normal (default) | ||
+ | | 192 | one half-tone up | | ||
+ | | 255 | two half-tones up | | ||
+ | +-------------------------------+ | ||
+ | |||
+ | | ||
+ | +-7---6---5---4---3---2---1---0-+ | ||
+ | | 0 | Number | ||
+ | +-------------------------------+ | ||
+ | |||
+ | Number | ||
+ | 10 120 (78h) All sounds off | ||
+ | 11 123 (7Bh) All notes off | ||
+ | 12 126 (7Eh) Mono | ||
+ | 13 127 (7Fh) Poly | ||
+ | 14 121 (79h) Reset all controllers | ||
+ | |||
+ | NOTE: The second column (MIDI ctrl) lists the corresponding MIDI | ||
+ | controller number. It is not needed unless you want to | ||
+ | convert MUS file data to MIDI. | ||
+ | |||
+ | | ||
+ | +-7---6---5---4---3---2---1---0-+ | ||
+ | | 0 | | ||
+ | +-------------------------------+ | ||
+ | |||
+ | Number | ||
+ | 0 | ||
+ | 1 0 or 32 Bank select: 0 by default | ||
+ | 2 1 (01h) Modulation pot (frequency vibrato depth) | ||
+ | 3 7 (07h) Volume: 0-silent, ~100-normal, | ||
+ | 4 10 (0Ah) Pan (balance) pot: 0-left, 64-center (default), | ||
+ | 127-right | ||
+ | 5 11 (0Bh) Expression pot | ||
+ | 6 91 (5Bh) Reverb depth | ||
+ | 7 93 (5Dh) Chorus depth | ||
+ | 8 64 (40h) Sustain pedal (hold) | ||
+ | 9 67 (43h) Soft pedal | ||
+ | |||
+ | NOTE: MUS controller 0 has no equivalent MIDI controller, but | ||
+ | is encoded as MIDI event 0Cxh--patch change (`x' is the | ||
+ | channel number) | ||
+ | |||
+ | | ||
+ | Not known what data (if any) this command takes. | ||
+ | |||
+ | | ||
+ | No data. | ||
+ | |||
+ | Marks the end of score. Must be present at the end, otherwise the | ||
+ | player may go off the rails. In DOOM this command restarts playing. | ||
+ | |||
+ | | ||
+ | Not known what data (if any) this command takes. | ||
+ | </ | ||
+ | |||
+ | APPENDIX A - Note numbers | ||
+ | ------------------------- | ||
+ | |||
+ | | ||
+ | | Octave | C | C# | D | D# | E | F | F# | G | G# | A | A# | B | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | APPENDIX B - Instrument Patch Map | ||
+ | --------------------------------- | ||
+ | |||
+ | Block 0-7 PIANO Block 8-15 CHROM PERCUSSION | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Block 16-23 ORGAN Block 24-31 GUITAR | ||
+ | 16 Hammond Organ | ||
+ | 17 Percussive Organ 25 Acoustic Guitar (steel) | ||
+ | 18 Rock Organ 26 Electric Guitar (jazz) | ||
+ | 19 Church Organ 27 Electric Guitar (clean) | ||
+ | 20 Reed Organ 28 Electric Guitar (muted) | ||
+ | 21 Accordion | ||
+ | 22 Harmonica | ||
+ | 23 Tango Accordion | ||
+ | |||
+ | Block 32-39 BASS Block 40-47 STRINGS | ||
+ | 32 Acoustic Bass | ||
+ | 33 Electric Bass (finger) | ||
+ | 34 Electric Bass (pick) | ||
+ | 35 Fretless Bass | ||
+ | 36 Slap Bass 1 | ||
+ | 37 Slap Bass 2 | ||
+ | 38 Synth Bass 1 46 Orchestral Harp | ||
+ | 39 Synth Bass 2 47 Timpani | ||
+ | |||
+ | Block 48-55 ENSEMBLE | ||
+ | 48 String Ensemble 1 | ||
+ | 49 String Ensemble 2 | ||
+ | 50 Synth Strings 1 | ||
+ | 51 Synth Strings 2 | ||
+ | 52 Choir Aahs 60 French Horn | ||
+ | 53 Voice Oohs 61 Brass Section | ||
+ | 54 Synth Voice | ||
+ | 55 Orchestra Hit | ||
+ | |||
+ | Block 64-71 REED Block 72-79 PIPE | ||
+ | 64 Soprano Sax | ||
+ | 65 Alto Sax 73 Flute | ||
+ | 66 Tenor Sax | ||
+ | 67 Baritone Sax 75 Pan Flute | ||
+ | 68 Oboe 76 Bottle Blow | ||
+ | 69 English Horn 77 Shakuhachi | ||
+ | 70 Bassoon | ||
+ | 71 Clarinet | ||
+ | |||
+ | Block 80-87 SYNTH LEAD Block 88-95 SYNTH PAD | ||
+ | 80 Lead 1 (square) | ||
+ | 81 Lead 2 (sawtooth) | ||
+ | 82 Lead 3 (calliope) | ||
+ | 83 Lead 4 (chiffer) | ||
+ | 84 Lead 5 (charang) | ||
+ | 85 Lead 6 (voice) | ||
+ | 86 Lead 7 (5th sawtooth) | ||
+ | 87 Lead 8 (bass & lead) 95 Pad 8 (sweep) | ||
+ | |||
+ | Block 96-103 | ||
+ | 96 FX 1 (rain) | ||
+ | 97 FX 2 (soundtrack) | ||
+ | 98 FX 3 (crystal) | ||
+ | 99 FX 4 (atmosphere) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Block 112-119 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | APPENDIX C - Percussion Key Map | ||
+ | ------------------------------- | ||
+ | |||
+ | In channel #15, the note number does not affect the pitch but | ||
+ | the instrument type. The default pitch for percussions is 60 (C-5). | ||
+ | |||
+ | Note Instrument | ||
+ | |||
+ | 35 Acoustic Bass Drum 59 Ride Cymbal 2 | ||
+ | 36 Bass Drum | ||
+ | 37 Slide Stick | ||
+ | 38 Acoustic Snare 62 Mute High Conga | ||
+ | 39 Hand Clap | ||
+ | 40 Electric Snare 64 Low Conga | ||
+ | 41 Low Floor Tom | ||
+ | 42 Closed High-Hat | ||
+ | 43 High Floor Tom 67 High Agogo | ||
+ | 44 Pedal High Hat 68 Low Agogo | ||
+ | 45 Low Tom | ||
+ | 46 Open High Hat | ||
+ | 47 Low-Mid Tom | ||
+ | 48 High-Mid Tom 72 Long Whistle | ||
+ | 49 Crash Cymbal 1 73 Short Guiro | ||
+ | 50 High Tom 74 Long Guiro | ||
+ | 51 Ride Cymbal 1 | ||
+ | 52 Chinses Cymbal | ||
+ | 53 Ride Bell | ||
+ | 54 Tambourine | ||
+ | 55 Splash Cymbal | ||
+ | 56 Cowbell | ||
+ | 57 Crash Cymbal 2 81 Open Triangle | ||
+ | 58 Vibraslap | ||
+ | |||
+ | TABLE 3 - General MIDI Minimum Sound Module Specifications | ||
+ | |||
+ | Voices: | ||
+ | A minimum of either 24 fully dynamically allocated voices available simultaneously for both melodic and percussive sounds or 16 dynamically allocated voices for melody plus eight for percussion. | ||
+ | |||
+ | Channels: | ||
+ | General MIDI mode supports all sixteen MIDI channels. Each channel can play a variable number of voices (polyphony). Each channel can play a different instrument (timbre). Keybased Percussion is always on Channel 10. | ||
+ | |||
+ | Instruments: | ||
+ | A minimum of sixteen different timbres playing various instrument sounds. A minimum of 128 preset for Intruments (MIDI program numbers). | ||
+ | |||
+ | Note on/Note off: | ||
+ | Octave Registration: | ||
+ | |||
+ | Controllers: | ||
+ | Controller # | ||
+ | Description | ||
+ | 1 Modulation | ||
+ | 7 Main Volume | ||
+ | 10 Pan | ||
+ | 11 Expression | ||
+ | 64 Sustain | ||
+ | 121 Reset All Controllers | ||
+ | 123 All Notes Off | ||
+ | |||
+ | Registered | ||
+ | Parameter # | ||
+ | Description | ||
+ | 0 Pitch Bend Sensitivity | ||
+ | 1 Fine Tuning | ||
+ | 2 Coarse Tuning | ||
+ | |||
+ | Additional Channel Messages: | ||
+ | Channel Pressure (Aftertouch) | ||
+ | Pitch Bend | ||
+ | |||
+ | Power-Up Defaults: | ||
+ | Pitch Bend Amount = 0 | ||
+ | Pitch Bend Sensitivity = +-2 semitones | ||
+ | Volume = 90 | ||
+ | All Other Controllers = reset | ||