Blame | Last modification | View Log | Download | RSS feed
Noisetracker/Soundtracker/Protracker Module Format--------------------------------------------------Credits: Lars Hamre, Norman Lin, Mark Cox, Peter Hanning,Steinar Midtskogen, Marc Espie, and Thomas Meyer(All numbers below are given in decimal)3rd RevisionModule Format:# Bytes Description------- -----------20 The module's title, padded with null (\0) bytes. OriginalProtracker wrote letters only in uppercase.(Data repeated for each sample 1-15 or 1-31)22 Sample's name, padded with null bytes. If a name begins with a'#', it is assumed not to be an instrument name, and isprobably a message.2 Sample length in words (1 word = 2 bytes). The first word ofthe sample is overwritten by the tracker, so a length of 1still means an empty sample. See below for sample format.1 Lowest four bits represent a signed nibble (-8..7) which isthe finetune value for the sample. Each finetune step changesthe note 1/8th of a semitone. Implemented by switching to adifferent table of period-values for each finetune value.1 Volume of sample. Legal values are 0..64. Volume is the lineardifference between sound intensities. 64 is full volume, andthe change in decibels can be calculated with 20*log10(Vol/64)2 Start of sample repeat offset in words. Once the sample hasbeen played all of the way through, it will loop if the repeatlength is greater than one. It repeats by jumping to thisposition in the sample and playing for the repeat length, thenjumping back to this position, and playing for the repeatlength, etc.2 Length of sample repeat in words. Only loop if greater than 1.(End of this sample's data.. each sample uses the same format and theyare stored sequentially)N.B. All 2 byte lengths are stored with the Hi-byte first, as is usualon the Amiga (big-endian format).1 Number of song positions (ie. number of patterns playedthroughout the song). Legal values are 1..128.1 Historically set to 127, but can be safely ignored.Noisetracker uses this byte to indicate restart position -this has been made redundant by the 'Position Jump' effect.128 Pattern table: patterns to play in each song position (0..127)Each byte has a legal value of 0..63 (note the Protrackerexception below). The highest value in this table is thehighest pattern stored, no patterns above this value arestored.(4) The four letters "M.K." These are the initials ofUnknown/D.O.C. who changed the format so it could handle 31samples (sorry.. they were not inserted by Mahoney & Kaktus).Startrekker puts "FLT4" or "FLT8" here to indicate the # ofchannels. If there are more than 64 patterns, Protracker willput "M!K!" here. You might also find: "6CHN" or "8CHN" whichindicate 6 or 8 channels respectively. If no letters are here,then this is the start of the pattern data, and only 15samples were present.(Data repeated for each pattern:)1024 Pattern data for each pattern (starting at 0).(Each pattern has same format and is stored in numerical order.See below for pattern format)(Data repeated for each sample:)xxxxxx The maximum size of a sample is 65535 words. Each sample isstored as a collection of bytes (length of a sample was givenpreviously in the module). Each byte is a signed value (-128..127) which is the channel data. When a sample is played at apitch of C2 (see below for pitches), about 8287 bytes ofsample data are sent to the channel per second. Multiply therate by the twelfth root of 2 (=1.0595) for each semitoneincrease in pitch eg. moving the pitch up 1 octave doubles therate. The data is stored in the order it is played (eg. firstbyte is first byte played). The first word of the sample datais used to hold repeat information, and will overwrite anysample data that is there (but it is probably safer to set itto 0).The rate given above (8287) conveys an inaccurate picture ofthe module-format - in reality it is different for differentAmigas. As the routines for playing were written to run offcertain interrupts, for different Amiga computers the rate tosend data to the channel will be different. For PAL machinesthe clock rate is 7093789.2 Hz and for NTSC machines it is7159090.5 Hz. When the clock rate is divided by twice theperiod number for the pitch it will give the rate to send thedata to the channel, eg. for a PAL machine sending a note atC2 (period 428), the rate is 7093789.2/856 ~= 8287.1369(Each sample is stored sequentially)Pattern Format:Each pattern is divided into 64 divisions. By allocating differenttempos for each pattern and spacing the notes across different amountsof divisions, different bar sizes can be accommodated.Each division contains the data for each channel (1..4) stored aftereach other. Channels 1 and 4 are on the left, and channels 2 and 3 areon the right. In the case of more channels: channels 5 and 8 are on theleft, and channels 6 and 7 are on the right, etc. Each channel's data inthe division has an identical format which consists of 2 words (4bytes). Divisions are numbered 0..63. Each division may be divided intoa number of ticks (see 'set speed' effect below).Channel Data:(the four bytes of channel data in a pattern division)7654-3210 7654-3210 7654-3210 7654-3210wwww xxxxxxxxxxxxxx yyyy zzzzzzzzzzzzzzwwwwyyyy (8 bits) is the sample for this channel/divisionxxxxxxxxxxxx (12 bits) is the sample's period (or effect parameter)zzzzzzzzzzzz (12 bits) is the effect for this channel/divisionIf there is to be no new sample to be played at this division on thischannel, then the old sample on this channel will continue, or at leastbe "remembered" for any effects. If the sample is 0, then the previoussample on that channel is used. Only one sample may play on a channel ata time, so playing a new sample will cancel an old one - even if therehas been no data supplied for the new sample. Though, if you are using a"silence" sample (ie. no data, only used to turn off other samples) itis polite to set its default volume to 0.To determine what pitch the sample is to be played on, look up theperiod in a table, such as the one below (for finetune 0). If the periodis 0, then the previous period on that channel is used. Unfortunately,some modules do not use these exact values. It is best to do a binary-search (unless you use the period as the offset of an array of notes..expensive), especially if you plan to use periods outside the "standard"range. Periods are the internal representation of the pitch, so effectsthat alter pitch (eg. sliding) alter the period value (see "effects"below).C C# D D# E F F# G G# A A# BOctave 1: 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453Octave 2: 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226Octave 3: 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113Octave 0:1712,1616,1525,1440,1357,1281,1209,1141,1077,1017, 961, 907Octave 4: 107, 101, 95, 90, 85, 80, 76, 71, 67, 64, 60, 57Octaves 0 and 4 are NOT standard, so don't rely on every tracker beingable to play them, or even not crashing if being given them - it's justnice that if you can code it, to allow them to be read.Effects:Effects are written as groups of 4 bits, eg. 1871 = 7 * 256 + 4 * 16 +15 = [7][4][15]. The high nibble (4 bits) usually determines the effect,but if it is [14], then the second nibble is used as well.[0]: ArpeggioWhere [0][x][y] means "play note, note+x semitones, note+ysemitones, then return to original note". The fluctuations arecarried out evenly spaced in one pattern division. They are usuallyused to simulate chords, but this doesn't work too well. They arealso used to produce heavy vibrato. A major chord is when x=4, y=7.A minor chord is when x=3, y=7.[1]: Slide upWhere [1][x][y] means "smoothly decrease the period of currentsample by x*16+y after each tick in the division". Theticks/division are set with the 'set speed' effect (see below). Ifthe period of the note being played is z, then the final periodwill be z - (x*16 + y)*(ticks - 1). As the slide rate depends onthe speed, changing the speed will change the slide. You cannotslide beyond the note B3 (period 113).[2]: Slide downWhere [2][x][y] means "smoothly increase the period of currentsample by x*16+y after each tick in the division". Similar to [1],but lowers the pitch. You cannot slide beyond the note C1 (period856).[3]: Slide to noteWhere [3][x][y] means "smoothly change the period of current sampleby x*16+y after each tick in the division, never sliding beyondcurrent period". The period-length in this channel's division is aparameter to this effect, and hence is not played. Sliding to anote is similar to effects [1] and [2], but the slide will not gobeyond the given period, and the direction is implied by thatperiod. If x and y are both 0, then the old slide will continue.[4]: VibratoWhere [4][x][y] means "oscillate the sample pitch using aparticular waveform with amplitude y/16 semitones, such that (x *ticks)/64 cycles occur in the division". The waveform is set usingeffect [14][4]. By placing vibrato effects on consecutivedivisions, the vibrato effect can be maintained. If either x or yare 0, then the old vibrato values will be used.[5]: Continue 'Slide to note', but also do Volume slideWhere [5][x][y] means "either slide the volume up x*(ticks - 1) orslide the volume down y*(ticks - 1), at the same time as continuingthe last 'Slide to note'". It is illegal for both x and y to benon-zero. You cannot slide outside the volume range 0..64. Theperiod-length in this channel's division is a parameter to thiseffect, and hence is not played.[6]: Continue 'Vibrato', but also do Volume slideWhere [6][x][y] means "either slide the volume up x*(ticks - 1) orslide the volume down y*(ticks - 1), at the same time as continuingthe last 'Vibrato'". It is illegal for both x and y to be non-zero.You cannot slide outside the volume range 0..64.[7]: TremoloWhere [7][x][y] means "oscillate the sample volume using aparticular waveform with amplitude y*(ticks - 1), such that (x *ticks)/64 cycles occur in the division". The waveform is set usingeffect [14][7]. Similar to [4].[8]: -- Unused --[9]: Set sample offsetWhere [9][x][y] means "play the sample from offset x*4096 + y*256".The offset is measured in words. If no sample is given, yet one isstill playing on this channel, it should be retriggered to the newoffset using the current volume.[10]: Volume slideWhere [10][x][y] means "either slide the volume up x*(ticks - 1) orslide the volume down y*(ticks - 1)". If both x and y are non-zero,then the y value is ignored (assumed to be 0). You cannot slideoutside the volume range 0..64.[11]: Position JumpWhere [11][x][y] means "stop the pattern after this division, andcontinue the song at song-position x*16+y". This shifts the'pattern-cursor' in the pattern table (see above). Legal values forx*16+y are from 0 to 127.[12]: Set volumeWhere [12][x][y] means "set current sample's volume to x*16+y".Legal volumes are 0..64.[13]: Pattern BreakWhere [13][x][y] means "stop the pattern after this division, andcontinue the song at the next pattern at division x*10+y" (the 10is not a typo). Legal divisions are from 0 to 63 (note Protrackerexception above).[14][0]: Set filter on/offWhere [14][0][x] means "set sound filter ON if x is 0, and OFF is xis 1". This is a hardware command for some Amigas, so if you don'tunderstand it, it is better not to use it.[14][1]: Fineslide upWhere [14][1][x] means "decrement the period of the current sampleby x". The incrementing takes place at the beginning of thedivision, and hence there is no actual sliding. You cannot slidebeyond the note B3 (period 113).[14][2]: Fineslide downWhere [14][2][x] means "increment the period of the current sampleby x". Similar to [14][1] but shifts the pitch down. You cannotslide beyond the note C1 (period 856).[14][3]: Set glissando on/offWhere [14][3][x] means "set glissando ON if x is 1, OFF if x is 0".Used in conjunction with [3] ('Slide to note'). If glissando is on,then 'Slide to note' will slide in semitones, otherwise willperform the default smooth slide.[14][4]: Set vibrato waveformWhere [14][4][x] means "set the waveform of succeeding 'vibrato'effects to wave #x". [4] is the 'vibrato' effect. Possible valuesfor x are:0 - sine (default) /\ /\ (2 cycles shown)4 (without retrigger) \/ \/1 - ramp down | \ | \5 (without retrigger) \ | \ |2 - square ,--, ,--,6 (without retrigger) '--' '--'3 - random: a random choice of one of the above.7 (without retrigger)If the waveform is selected "without retrigger", then it will notbe retriggered from the beginning at the start of each new note.[14][5]: Set finetune valueWhere [14][5][x] means "sets the finetune value of the currentsample to the signed nibble x". x has legal values of 0..15,corresponding to signed nibbles 0..7,-8..-1 (see start of text formore info on finetune values).[14][6]: Loop patternWhere [14][6][x] means "set the start of a loop to this division ifx is 0, otherwise after this division, jump back to the start of aloop and play it another x times before continuing". If the startof the loop was not set, it will default to the start of thecurrent pattern. Hence 'loop pattern' cannot be performed acrossmultiple patterns. Note that loops do not support nesting, and youmay generate an infinite loop if you try to nest 'loop pattern's.[14][7]: Set tremolo waveformWhere [14][7][x] means "set the waveform of succeeding 'tremolo'effects to wave #x". Similar to [14][4], but alters effect [7] -the 'tremolo' effect.[14][8]: -- Unused --[14][9]: Retrigger sampleWhere [14][9][x] means "trigger current sample every x ticks inthis division". If x is 0, then no retriggering is done (acts as ifno effect was chosen), otherwise the retriggering begins on thefirst tick and then x ticks after that, etc.[14][10]: Fine volume slide upWhere [14][10][x] means "increment the volume of the current sampleby x". The incrementing takes place at the beginning of thedivision, and hence there is no sliding. You cannot slide beyondvolume 64.[14][11]: Fine volume slide downWhere [14][11][x] means "decrement the volume of the current sampleby x". Similar to [14][10] but lowers volume. You cannot slidebeyond volume 0.[14][12]: Cut sampleWhere [14][12][x] means "after the current sample has been playedfor x ticks in this division, its volume will be set to 0". Thisimplies that if x is 0, then you will not hear any of the sample.If you wish to insert "silence" in a pattern, it is better to use a"silence"-sample (see above) due to the lack of proper support forthis effect.[14][13]: Delay sampleWhere [14][13][x] means "do not start this division's sample forthe first x ticks in this division, play the sample after this".This implies that if x is 0, then you will hear no delay, butactually there will be a VERY small delay. Note that this effectonly influences a sample if it was started in this division.[14][14]: Delay patternWhere [14][14][x] means "after this division there will be a delayequivalent to the time taken to play x divisions after which thepattern will be resumed". The delay only relates to theinterpreting of new divisions, and all effects and previous notescontinue during delay.[14][15]: Invert loopWhere [14][15][x] means "if x is greater than 0, then play thecurrent sample's loop upside down at speed x". Each byte in thesample's loop will have its sign changed (negated). It will onlywork if the sample's loop (defined previously) is not too big. Thespeed is based on an internal table.[15]: Set speedWhere [15][x][y] means "set speed to x*16+y". Though it is nowherenear that simple. Let z = x*16+y. Depending on what values z takes,different units of speed are set, there being two: ticks/divisionand beats/minute (though this one is only a label and not strictlytrue). If z=0, then what should technically happen is that themodule stops, but in practice it is treated as if z=1, becausethere is already a method for stopping the module (running out ofpatterns). If z<=32, then it means "set ticks/division to z"otherwise it means "set beats/minute to z" (convention says thatthis should read "If z<32.." but there are some composers out therethat defy conventions). Default values are 6 ticks/division, and125 beats/minute (4 divisions = 1 beat). The beats/minute tag isonly meaningful for 6 ticks/division. To get a more accurate viewof how things work, use the following formula:24 * beats/minutedivisions/minute = -----------------ticks/divisionHence divisions/minute range from 24.75 to 6120, eg. to get a valueof 2000 divisions/minute use 3 ticks/division and 250 beats/minute.If multiple "set speed" effects are performed in a single division,the ones on higher-numbered channels take precedence over the oneson lower-numbered channels. This effect has a large number ofdifferent implementations, but the one described here has thewidest usage.N.B. This document should be fairly accurate now, but as the moduleformat is more of an observation than a standard, a couple of effectscannot be relied upon to act exactly the same from tracker to tracker(especially if the tracker is not for the Amiga). It is probably betterto use this document as a guide rather than as a hard-and-fastdefinition of the module format. Oh.. and yes, I would normally givebytes as hex values, but it is easier to understand a consistentnotation.Andrew Scott (Adrenalin Software), INTERNET:ascott@tartarus.uwa.edu.auAuthor of MIDIMOD (MOD to MIDI converter), PTMID (MIDI to MOD converter)