home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / MUS_FORM.DOC < prev    next >
Text File  |  1996-01-04  |  15KB  |  327 lines

  1.  
  2.                               MUS File Format
  3.                               ═══════════════
  4.  
  5. Written by: Vladimir Arnost, QA-Software
  6. Date:       August 10, 1995
  7. Version:    1.3
  8. Internet:   xarnos00@dcse.fee.vutbr.cz
  9. FIDO:       2:423/36.2  (wladows@fidonet.at)
  10.  
  11.  
  12. 1. General Description
  13. ──────────────────────
  14.  
  15.    A .MUS file is a simple clone of .MID file. It uses the same instruments,
  16.    similar commands and the same principle: a list of sound events.
  17.    It consists of two parts: header and body.
  18.  
  19.  
  20. 2. MUS File Header
  21. ──────────────────
  22.  
  23.    The MUS header has the following structure:
  24.  
  25.         struct MUSheader {
  26.                 char    ID[4];          // identifier "MUS" 0x1A
  27.                 WORD    scoreLen;
  28.                 WORD    scoreStart;
  29.                 WORD    channels;    // count of primary channels
  30.                 WORD    sec_channels;    // count of secondary channels
  31.                 WORD    instrCnt;
  32.                 WORD    dummy;
  33.         // variable-length part starts here
  34.                 WORD    instruments[];
  35.         };
  36.  
  37.    NOTE: WORD is a 16-bit unsigned integer (little-endian)
  38.  
  39.    The header has two parts: the fixed-length and the variable-length part.
  40.    The former contains file identifier, score start and length, number of
  41.    channels and number of used instruments. The latter part is actually
  42.    a list of used instruments. The instruments are stored as numbers which
  43.    are arranged in this fashion:
  44.  
  45.     Instrument Number      Meaning
  46.         0 - 127           standard MIDI instruments
  47.       135 - 181           standard MIDI percussions (notes 35 - 81)
  48.  
  49.    `scoreStart' is the absolute file position of the score and `scoreLen' is
  50.    its length in bytes. Usage of 16-bit number as length limits .MUS file
  51.    size to 64KB.
  52.  
  53.    `channels' tells you how many channels are utilized in the song. The
  54.    channel number 15 (percussions) is not included in the sum.
  55.  
  56.  
  57. 3. MUS File Body
  58. ────────────────
  59.  
  60.    Unlike MID files, MUS body contains only one track. File body is
  61.    a sequence of sound events and time records. A sound event consists of
  62.    one or more bytes encoded as follows:
  63.  
  64.    1st byte -- event descriptor:
  65.          ╓──7─┬──6─┬──5─┬──4─┬──3─┬──2─┬──1─┬──0─╖
  66.          ║Last│  Event type  │  Channel number   ║
  67.          ╙────┴────┴────┴────┴────┴────┴────┴────╜
  68.  
  69.              `Event type' is one of these:
  70.                0 - release note
  71.                1 - play note
  72.                2 - pitch wheel (bender)
  73.                3 - system event (valueless controller)
  74.                4 - change controller
  75.                5 - ???
  76.                6 - score end
  77.                7 - ???
  78.  
  79.              `Channel number' determines which channel this event refers to.
  80.              Channels provide only logical score division. Every channel
  81.              carries its own settings (instrument #, panning, volume) and the
  82.              channel number specifies only which settings to use. In general,
  83.              the channel number itself is almost irrelevant and may be chosen
  84.              arbitrarily within the interval 0 to 14. The only exception is
  85.              the channel number 15, which is dedicated ONLY to percussions.
  86.  
  87.              `Last' - if set, the event is followed by time information. This
  88.              means that this is the last event in a group of events which
  89.              occur at the same time. The time information is a number of
  90.              ticks to wait before processing next event. One tick is usually
  91.              1/140 sec (in Doom I, II and Heretic; Raptor uses 1/70 sec).
  92.  
  93.              Time information can be read in this way:
  94.                1. time = 0
  95.                2. READ a byte
  96.                3. time = time * 128 + byte AND 127
  97.                4. IF (byte AND 128) GO TO 2
  98.                5. RETURN time
  99.              The time info is a series of 7-bit chunks. The 8th bit is set
  100.              until the last byte whose 8th bit is zero. This scheme allows
  101.              small numbers occupy less space than large ones.
  102.  
  103.    Event  Type
  104.    ────────────────────
  105.      0    Release note
  106.           ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖
  107.           ║ 0 │    Note number 0 - 127    ║
  108.           ╙───┴───┴───┴───┴───┴───┴───┴───╜
  109.  
  110.      1    Play note
  111.           ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖  ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖
  112.           ║Vol│    Note number 0 - 127    ║  ║ 0 │    Note volume 0 - 127    ║
  113.           ╙───┴───┴───┴───┴───┴───┴───┴───╜  ╙───┴───┴───┴───┴───┴───┴───┴───╜
  114.  
  115.           `Note volume' is present only if `Vol' bit is set. Otherwise the
  116.           previous value is used and the second byte is not present.
  117.           NOTE: Each channel keeps track of its own last volume value.
  118.                 More than one note can be played at once in one channel.
  119.           Channel 15 is dedicated to drums and percussions. `Note number'
  120.           acts as an instrument selector there. See Appendix C
  121.  
  122.      2    Pitch wheel
  123.           ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖
  124.           ║       Pitch wheel value       ║
  125.           ╙───┴───┴───┴───┴───┴───┴───┴───╜
  126.  
  127.           Sets pitch wheel (bender) value of a channel. Some handy values are
  128.           shown in the table (all values in the range 0-255 can be used):
  129.  
  130.           ┌───────┬───────────────────────┐
  131.           │ Value │  Pitch change         │
  132.           ├───────┼───────────────────────┤
  133.           │    0  │  two half-tones down  │
  134.           │   64  │  one half-tone down   │
  135.           │  128  │  normal (default)     │
  136.           │  192  │  one half-tone up     │
  137.           │  255  │  two half-tones up    │
  138.           └───────┴───────────────────────┘
  139.  
  140.      3    System event
  141.           ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖
  142.           ║ 0 │          Number           ║
  143.           ╙───┴───┴───┴───┴───┴───┴───┴───╜
  144.  
  145.           Number  MIDI ctrl   Description
  146.             10    120 (78h)   All sounds off
  147.             11    123 (7Bh)   All notes off
  148.             12    126 (7Eh)   Mono
  149.             13    127 (7Fh)   Poly
  150.             14    121 (79h)   Reset all controllers
  151.  
  152.           NOTE: The second column (MIDI ctrl) lists the corresponding MIDI
  153.                 controller number. It is not needed unless you want to
  154.                 convert MUS file data to MIDI.
  155.  
  156.      4    Change controller
  157.           ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖  ╓─7─┬─6─┬─5─┬─4─┬─3─┬─2─┬─1─┬─0─╖
  158.           ║ 0 │     Controller number     ║  ║ 0 │      Controller value     ║
  159.           ╙───┴───┴───┴───┴───┴───┴───┴───╜  ╙───┴───┴───┴───┴───┴───┴───┴───╜
  160.  
  161.           Number  MIDI ctrl   Description
  162.             0       N/A       Instrument (patch, program) number
  163.             1      0 or 32    Bank select: 0 by default
  164.             2      1 (01h)    Modulation pot
  165.             3      7 (07h)    Volume: 0-silent, ~100-normal, 127-loud
  166.             4     10 (0Ah)    Pan (balance) pot: 0-left, 64-center (default),
  167.                               127-right
  168.             5     11 (0Bh)    Expression pot
  169.             6     91 (5Bh)    Reverb depth
  170.             7     93 (5Dh)    Chorus depth
  171.             8     64 (40h)    Sustain pedal (hold)
  172.             9     67 (43h)    Soft pedal
  173.  
  174.           NOTE: MUS controller 0 has no equivalent MIDI controller, but
  175.                 is encoded as MIDI event 0Cxh--patch change (`x' is the
  176.                 channel number)
  177.  
  178.      5    Unknown
  179.           Not known what data (if any) this command takes.
  180.  
  181.      6    Score end
  182.           No data.
  183.  
  184.           Marks the end of score. Must be present at the end, otherwise the
  185.           player may go off the rails. In DOOM this command restarts playing.
  186.  
  187.      7    Unknown
  188.           Not known what data (if any) this command takes.
  189.  
  190.  
  191. APPENDIX A - Note numbers
  192. ─────────────────────────
  193.  
  194.    ╔════════╦═════╤════╤════╤════╤════╤════╤════╤════╤════╤════╤════╤════╗
  195.    ║ Octave ║  C  │ C# │ D  │ D# │ E  │ F  │ F# │ G  │ G# │ A  │ A# │ B  ║
  196.    ╠════════╬═════╪════╪════╪════╪════╪════╪════╪════╪════╪════╪════╪════╣
  197.    ║    0   ║   0 │  1 │  2 │  3 │  4 │  5 │  6 │  7 │  8 │  9 │ 10 │ 11 ║
  198.    ║    1   ║  12 │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 ║
  199.    ║    2   ║  24 │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ 32 │ 33 │ 34 │ 35 ║
  200.    ║    3   ║  36 │ 37 │ 38 │ 39 │ 40 │ 41 │ 42 │ 43 │ 44 │ 45 │ 46 │ 47 ║
  201.    ║    4   ║  48 │ 49 │ 50 │ 51 │ 52 │ 53 │ 54 │ 55 │ 56 │ 57 │ 58 │ 59 ║
  202.    ║    5   ║  60 │ 61 │ 62 │ 63 │ 64 │ 65 │ 66 │ 67 │ 68 │ 69 │ 70 │ 71 ║
  203.    ║    6   ║  72 │ 73 │ 74 │ 75 │ 76 │ 77 │ 78 │ 79 │ 80 │ 81 │ 82 │ 83 ║
  204.    ║    7   ║  84 │ 85 │ 86 │ 87 │ 88 │ 89 │ 90 │ 91 │ 92 │ 93 │ 94 │ 95 ║
  205.    ║    8   ║  96 │ 97 │ 98 │ 99 │100 │101 │102 │103 │104 │105 │106 │107 ║
  206.    ║    9   ║ 108 │109 │110 │111 │112 │113 │114 │115 │116 │117 │118 │119 ║
  207.    ║   10   ║ 120 │121 │122 │123 │124 │125 │126 │127 │    │    │    │    ║
  208.    ╚════════╩═════╧════╧════╧════╧════╧════╧════╧════╧════╧════╧════╧════╝
  209.  
  210.  
  211. APPENDIX B - Instrument Patch Map
  212. ─────────────────────────────────
  213.  
  214.    Block 0-7  PIANO                    Block 8-15  CHROM PERCUSSION
  215.      0  Acoustic Grand Piano             8  Celesta
  216.      1  Bright Acoustic Piano            9  Glockenspiel
  217.      2  Electric Grand Piano            10  Music Box
  218.      3  Honky-tonk Piano                11  Vibraphone
  219.      4  Rhodes Paino                    12  Marimba
  220.      5  Chorused Piano                  13  Xylophone
  221.      6  Harpsichord                     14  Tubular-bell
  222.      7  Clavinet                        15  Dulcimer
  223.  
  224.    Block 16-23  ORGAN                  Block 24-31  GUITAR
  225.     16  Hammond Organ                   24  Acoustic Guitar (nylon)
  226.     17  Percussive Organ                25  Acoustic Guitar (steel)
  227.     18  Rock Organ                      26  Electric Guitar (jazz)
  228.     19  Church Organ                    27  Electric Guitar (clean)
  229.     20  Reed Organ                      28  Electric Guitar (muted)
  230.     21  Accordion                       29  Overdriven Guitar
  231.     22  Harmonica                       30  Distortion Guitar
  232.     23  Tango Accordion                 31  Guitar Harmonics
  233.  
  234.    Block 32-39  BASS                   Block 40-47  STRINGS
  235.     32  Acoustic Bass                   40  Violin
  236.     33  Electric Bass (finger)          41  Viola
  237.     34  Electric Bass (pick)            42  Cello
  238.     35  Fretless Bass                   43  Contrabass
  239.     36  Slap Bass 1                     44  Tremolo Strings
  240.     37  Slap Bass 2                     45  Pizzicato Strings
  241.     38  Synth Bass 1                    46  Orchestral Harp
  242.     39  Synth Bass 2                    47  Timpani
  243.  
  244.    Block 48-55  ENSEMBLE               Block 56-63  BRASS
  245.     48  String Ensemble 1               56  Trumpet
  246.     49  String Ensemble 2               57  Trombone
  247.     50  Synth Strings 1                 58  Tuba
  248.     51  Synth Strings 2                 59  Muted Trumpet
  249.     52  Choir Aahs                      60  French Horn
  250.     53  Voice Oohs                      61  Brass Section
  251.     54  Synth Voice                     62  Synth Brass 1
  252.     55  Orchestra Hit                   63  Synth Bass 2
  253.  
  254.    Block 64-71  REED                   Block 72-79  PIPE
  255.     64  Soprano Sax                     72  Piccolo
  256.     65  Alto Sax                        73  Flute
  257.     66  Tenor Sax                       74  Recorder
  258.     67  Baritone Sax                    75  Pan Flute
  259.     68  Oboe                            76  Bottle Blow
  260.     69  English Horn                    77  Shakuhachi
  261.     70  Bassoon                         78  Whistle
  262.     71  Clarinet                        79  Ocarina
  263.  
  264.    Block 80-87  SYNTH LEAD             Block 88-95  SYNTH PAD
  265.     80  Lead 1 (square)                 88  Pad 1 (new age)
  266.     81  Lead 2 (sawtooth)               89  Pad 2 (warm)
  267.     82  Lead 3 (calliope)               90  Pad 3 (polysynth)
  268.     83  Lead 4 (chiffer)                91  Pad 4 (choir)
  269.     84  Lead 5 (charang)                92  Pad 5 (bowed glass)
  270.     85  Lead 6 (voice)                  93  Pad 6 (metal)
  271.     86  Lead 7 (5th sawtooth)           94  Pad 7 (halo)
  272.     87  Lead 8 (bass & lead)            95  Pad 8 (sweep)
  273.  
  274.    Block 96-103  SYNTH EFFECTS         Block 104-111  ETHNIC
  275.     96  FX 1 (rain)                    104  Sitar
  276.     97  FX 2 (soundtrack)              105  Banjo
  277.     98  FX 3 (crystal)                 106  Shamisen
  278.     99  FX 4 (atmosphere)              107  Koto
  279.    100  FX 5 (brightness)              108  Kalimba
  280.    101  FX 6 (goblin)                  109  Bag Pipe
  281.    102  FX 7 (echo drops)              110  Fiddle
  282.    103  FX 8 (star-theme)              111  Shanai
  283.  
  284.    Block 112-119  PERCUSSIVE           Block 120-127  SOUND EFFECTS
  285.    112  Tinkle Bell                    120  Guitar Fret Noise
  286.    113  Agogo                          121  Breath Noise
  287.    114  Steel Drums                    122  Seashore
  288.    115  Woodblock                      123  Bird Tweet
  289.    116  Taiko Drum                     124  Telephone Ring
  290.    117  Melodic Tom                    125  Helicopter
  291.    118  Synth Drum                     126  Applause
  292.    119  Reverse Cymbal                 127  Gun Shot
  293.  
  294.  
  295. APPENDIX C - Percussion Key Map
  296. ───────────────────────────────
  297.  
  298.    In channel #15, the note number does not affect the pitch but
  299.    the instrument type. The default pitch for percussions is 60 (C-5).
  300.  
  301.    Note Instrument                     Note Instrument
  302.  
  303.     35  Acoustic Bass Drum              59  Ride Cymbal 2
  304.     36  Bass Drum                       60  High Bongo
  305.     37  Slide Stick                     61  Low Bango
  306.     38  Acoustic Snare                  62  Mute High Conga
  307.     39  Hand Clap                       63  Open High Conga
  308.     40  Electric Snare                  64  Low Conga
  309.     41  Low Floor Tom                   65  High Timbale
  310.     42  Closed High-Hat                 66  Low Timbale
  311.     43  High Floor Tom                  67  High Agogo
  312.     44  Pedal High Hat                  68  Low Agogo
  313.     45  Low Tom                         69  Cabasa
  314.     46  Open High Hat                   70  Maracas
  315.     47  Low-Mid Tom                     71  Short Whistle
  316.     48  High-Mid Tom                    72  Long Whistle
  317.     49  Crash Cymbal 1                  73  Short Guiro
  318.     50  High Tom                        74  Long Guiro
  319.     51  Ride Cymbal 1                   75  Claves
  320.     52  Chinses Cymbal                  76  High Wood Block
  321.     53  Ride Bell                       77  Low Wood Block
  322.     54  Tambourine                      78  Mute Cuica
  323.     55  Splash Cymbal                   79  Open Cuica
  324.     56  Cowbell                         80  Mute Triangle
  325.     57  Crash Cymbal 2                  81  Open Triangle
  326.     58  Vibraslap
  327.