Guest User

Untitled

a guest
Jul 24th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.23 KB | None | 0 0
  1. The "Complete" XM module format specification v0.81
  2. ============================================= -----
  3. Compiled and written by Matti "ccr" Hamalainen of TNSP 2000-2001
  4.  
  5. Contact ccr/TNSP at:
  6. www : http://www.tnsp.org/
  7.  
  8. NEWS/CHANGES FROM V0.75
  9. -----------------------
  10. - Typofixes
  11. - Info about Vibrato,
  12. - Info about other programs than FT2 that support XM
  13. and discussion about how they differ from FT.
  14. - Player processing info
  15. - More info about other effects
  16.  
  17. TO-DO LIST
  18. ----------
  19. - Research workings of the rest of the effects.
  20. - Do a complete check of accuracy to this doc.
  21. (e.g. test all info that is said here.)
  22.  
  23. ============================================================================
  24.  
  25. DESCRIPTION
  26. -----------
  27. NOTICE: I DON'T claim that the information in this document is
  28. errorfree, so use common sense if you encounter something that
  29. does not match! I am constantly improving this doc, send your
  30. reports to me and I'll see if I can figure out what went wrong. :)
  31.  
  32.  
  33. This documentation was written due to lack of 'complete' guide to
  34. the XM format. In 2000 I used the modified XM document by Sahara
  35. Surfers when I started writing XM loader/player for "J Sound System".
  36. It was good, but still lacked some crucial information. During the
  37. development of J Sound System I have gathered some additional
  38. information (and still continue to do so). This document is the
  39. result of that work.
  40.  
  41. Remember - the information contained herein is based on tests on
  42. REAL XM files and REAL FT2 :)
  43.  
  44. If you have any questions, fixes or suggestions (to add info about
  45. something, for example), e-mail me.
  46.  
  47. ============================================================================
  48.  
  49. SOURCE MATERIAL AND ADDITIONAL CREDITS
  50. --------------------------------------
  51. - Lots of empirical and systematic testing in FT2. Hours and
  52. hours of "to-FT2-shell-to-DOS-write-doc-back-to-FT2-...",
  53. beer, coffee, swearing, XXX, etc.
  54. - Investigating PT 3.61 internals.
  55. - Testing of J Sound System's XM player.
  56. - Testing of other players to see the common pitfalls ;)
  57.  
  58. This document is based on the original XM format description:
  59. (C) Copyright 1994 by Mr.H of Triton productions
  60. (Distributed in public domain)
  61.  
  62. Some information is from the enchanged XM description
  63. written by Guru and Alfred of Sahara Surfers in 1995:
  64. "Not copyrighted, released into public domain (at least the
  65. additions by us). Feel free to do what you wish. Credits please."
  66.  
  67. Some bug information from ODE2PTK.MOD's documentation
  68. written and gathered by Chipaux Sylvain aka Asle/Lithium^ReDoX
  69.  
  70. Greetings also to:
  71. - My friends who have beared me talking about FT2's "features"
  72. and swearing the bugs in "Other Players", etc.
  73.  
  74. - All TNSP members: fgcl, mdx, sind., delfine, ssad.
  75.  
  76. - All demoscene people over the world, demo on! (But please
  77. try not to make 3D stuff only, it's boring :-)
  78.  
  79. ============================================================================
  80.  
  81. DISCLAIMER
  82. ----------
  83. You can use this information in any way you wish as long as it
  84. is distributed freely and no payment is taken for distributing it
  85. (maybe except a minimal fee for the physical copying process).
  86. Also the authors may not be held responsible for anything
  87. including but not excluding damages, loss of profit or similar.
  88.  
  89. This information is provided in hope that it is useful, but there
  90. are no warranties of any kind that the information contained in
  91. this document is in any way correct or usable. The responsibility
  92. for consequences when using the information is entirely on the user.
  93.  
  94. ============================================================================
  95.  
  96. ********************
  97. * General layout *
  98. ********************
  99.  
  100. The layout of a typical XM is like this:
  101.  
  102. XM header (up to and excluding header size field, now 60 bytes)
  103. Rest of the header (length including header size field)
  104. Pattern 0 header (length in header)
  105. Pattern 0 data (length in header)
  106. Pattern 1 header (length in header)
  107. Pattern 1 data (length in header)
  108. ... (* number of patterns)
  109. Instrument 0 header (length in size field is this and next one together)
  110. if (numSample > 0)
  111. Extra header
  112. Sample 0 header (size in instrument extra header)
  113. Sample 1 header (size in instrument extra header)
  114. ... (* number of samples in instrument)
  115. Sample 0 data (length in sample header)
  116. Sample 1 data (length in sample header)
  117. ... (* number of samples in instrument)
  118. Instrument 1 header (length in size field is this and next one together)
  119. ... (* number of instruments)
  120.  
  121.  
  122. ******************************
  123. * The XM file structure: *
  124. ******************************
  125.  
  126. HEADER
  127. ======
  128.  
  129. Offset|Length| Type | Description
  130. ------+------+--------+--------------------------------------------
  131. 0 | 17 | (char) | ID text: 'Extended Module: '
  132. | | | (The last character is space, i.e. $20)
  133. 17 | 20 | (char) | Module name, padded with zeros.
  134. 37 | 1 | (char) | Always $1a
  135. 38 | 20 | (char) | Tracker name
  136. 58 | 2 | (word) | Version number, hi-byte major and low-byte minor
  137. | | | The current format is version $0104. Format
  138. | | | versions below $0104 have a LOT of differences.
  139. | | | Remember to check this field! Your loader will
  140. | | | probably crash if you don't!
  141. | | |
  142. 60 | 4 | (dword)| Header size
  143. | | | Calculated FROM THIS OFFSET, NOT from
  144. | | | the beginning of the file!
  145. +4 | 2 | (word) | Song length (in pattern order table)
  146. +6 | 2 | (word) | Song restart position
  147. +8 | 2 | (word) | Number of channels (2, 4, 6, 8, 10, ..., 32)
  148. +10 | 2 | (word) | Number of patterns (max 256)
  149. | | | NOTICE: This might not include all patterns used!
  150. | | | If empty patterns are used at the end of the song
  151. | | | they are NOT saved to the file!!
  152. +12 | 2 | (word) | Number of instruments (max 128)
  153. +14 | 2 | (word) | Flags field:
  154. | | | bit0: 0 = Amiga frequency table
  155. | | | 1 = Linear frequency table
  156. +16 | 2 | (word) | Default tempo
  157. +18 | 2 | (word) | Default BPM
  158. +20 | 256 | (byte) | Pattern order table
  159.  
  160. PATTERNS
  161. ========
  162.  
  163. Offset|Length| Type | Description
  164. ------+------+--------+--------------------------------------------
  165. ? | 4 | (dword)| Pattern header length
  166. +4 | 1 | (byte) | Packing type (always 0)
  167. +5 | 2 | (word) | Number of rows in pattern (1..256)
  168. +7 | 2 | (word) | Packed patterndata size
  169. | | | << Note! This is zero if the pattern is
  170. | | | completely empty and no pattern data
  171. | | | follows! >>
  172. | | |
  173. ? | ? | | Packed pattern data.
  174.  
  175. INSTRUMENTS
  176. ===========
  177.  
  178. Offset|Length| Type | Description
  179. ------+------+--------+--------------------------------------------
  180. ? | 4 | (dword)| Instrument HEADER size (SEE THE NOTICE BELOW)
  181. +4 | 22 | (char) | Instrument name
  182. +26 | 1 | (byte) | Instrument type (always 0)
  183. | | | << In reality, this seems pretty random,
  184. | | | so DON'T assume that it's zero. >>
  185. | | |
  186. +27 | 2 | (word) | Number of samples in instrument.
  187.  
  188. NOTICE: The "Instrument HEADER Size" field tends to be more than the actual
  189. size of the structure documented here (it includes also the
  190. extended instrument sample header below). So remember to check
  191. it and skip the additional bytes before the first sample header!
  192.  
  193. If the number of samples is greater than zero, then this will follow:
  194. (if it is zero, nothing will follow!)
  195.  
  196. Offset|Length| Type | Description
  197. ------+------+--------+--------------------------------------------
  198. +29 | 4 | (dword)| Sample header size
  199. +33 | 96 | (byte) | Sample number for all notes
  200. +129 | 48 | (byte) | Points for volume envelope
  201. +177 | 48 | (byte) | Points for panning envelope
  202. +225 | 1 | (byte) | Number of volume points
  203. +226 | 1 | (byte) | Number of panning points
  204. +227 | 1 | (byte) | Volume sustain point
  205. +228 | 1 | (byte) | Volume loop start point
  206. +229 | 1 | (byte) | Volume loop end point
  207. +230 | 1 | (byte) | Panning sustain point
  208. +231 | 1 | (byte) | Panning loop start point
  209. +232 | 1 | (byte) | Panning loop end point
  210. +233 | 1 | (byte) | Volume type: bit 0: On; 1: Sustain; 2: Loop
  211. +234 | 1 | (byte) | Panning type: bit 0: On; 1: Sustain; 2: Loop
  212. +235 | 1 | (byte) | Vibrato type
  213. +236 | 1 | (byte) | Vibrato sweep
  214. +237 | 1 | (byte) | Vibrato depth
  215. +238 | 1 | (byte) | Vibrato rate
  216. +239 | 2 | (word) | Volume fadeout
  217. +241 | 2 | (word) | Reserved
  218.  
  219.  
  220. Envelope format
  221. ---------------
  222. The envelope-data (for both Volume and Panning envelope)
  223. is formatted as follows:
  224.  
  225. Data for ONE envelope point:
  226.  
  227. Offset|Length| Type | Description
  228. ------+------+--------+--------------------------------------------
  229. ? | 1 | (word) | Frame number of the point (X-coordinate)
  230. ? | 1 | (word) | Value of the point (Y-coordinate)
  231.  
  232. Since one envelope point takes 2 words (2*2 bytes), the total
  233. maximum number of points in envelope is (48/4) = 12 points.
  234. So in practice, you have:
  235.  
  236. #define MAX_ENVELOPE_POINTS 12
  237.  
  238. typedef {
  239. WORD nframe;
  240. WORD value;
  241. } t_envelope_point;
  242.  
  243. t_envelope_point volume_envelope[MAX_ENVELOPE_POINTS];
  244. t_envelope_point panning_envelope[MAX_ENVELOPE_POINTS];
  245.  
  246. Envelope frame-counters work in range 0..FFFFh (0..65535 dec).
  247. BUT! FT2 only itself supports only range 0..FFh (0..255 dec).
  248. Some other trackers (like SoundTracker for Unix), however, can
  249. use the full range 0..FFFF, so it should be supported.
  250.  
  251. !!TIP: This is also a good way to detect if the module has been
  252. made with FT2 or not. (In case the tracker name is brain-
  253. deadly left unchanged!)
  254.  
  255. Of course it does not help if all instruments have the
  256. values inside FT2 supported range.
  257.  
  258. The value-field of the envelope point is ranged between
  259. 00..3Fh (0..64 dec).
  260.  
  261. SAMPLE HEADERS
  262. ==============
  263. "Number of samples" of these will follow after the instrument header.
  264. See also the XM file general layout in the beginning of this file to
  265. understand better/get the big picture.
  266.  
  267. Offset|Length| Type | Description
  268. ------+------+--------+--------------------------------------------
  269. ? | 4 | (dword)| Sample length
  270. +4 | 4 | (dword)| Sample loop start
  271. +8 | 4 | (dword)| Sample loop length
  272. +12 | 1 | (byte) | Volume
  273. +13 | 1 | (byte) | Finetune (signed byte -16..+15)
  274. +14 | 1 | (byte) | Type of sample, bit meanings:
  275. | | | 0-1: 00 = 0 dec = No loop,
  276. | | | 01 = 1 dec = Forward loop,
  277. | | | 11 = 2 dec = Ping-pong loop;
  278. | | | 4: 16-bit sampledata
  279. +15 | 1 | (byte) | Panning (0-255)
  280. +16 | 1 | (byte) | Relative note number (signed byte)
  281. +17 | 1 | (byte) | Reserved
  282. +18 | 22 | (char) | Sample name
  283.  
  284. NOTICE: Note! After the instrument header the file contains
  285. ALL sample headers for the instrument followed by the
  286. sample data for all samples.
  287.  
  288. Also note that it is possible that samples have loops with
  289. length zero. In that case the loops just have to be skipped.
  290.  
  291.  
  292. Sample data
  293. -----------
  294. Sample data is stored as signed values:
  295.  
  296. * 8-bit sample : char in C if char is 8bit, ShortInt in Pascal.
  297. * 16-bit sample: int in C, Integer in Pascal.
  298.  
  299. The saved data uses simple delta-encoding to achieve better
  300. compression ratios (when compressed with pkzip, etc.)
  301.  
  302. Pseudocode for converting the delta-coded data to normal data,
  303. for 8-bit samples:
  304.  
  305. signed byte old, new;
  306.  
  307. old = 0;
  308. for i = 0 to data_len {
  309. new = sample[i] + old;
  310. sample[i] = new;
  311. old = new;
  312. }
  313.  
  314. NOTICE: 16-bit samples are encoded in same way,
  315. except that the datatype is 16-bit.
  316.  
  317. ============================================================================
  318.  
  319. ***********************
  320. * Pattern format: *
  321. ***********************
  322.  
  323. The patterns are stored as ordinary MOD patterns,
  324. except that each note is stored as 5 bytes:
  325.  
  326. ? 1 (byte) Note (1 - 96, 97 = KEY-OFF)
  327. +1 1 (byte) Instrument (1-128)
  328. +2 1 (byte) Volume column byte (see below)
  329. +3 1 (byte) Effect type
  330. +4 1 (byte) Effect parameter
  331.  
  332. A simple packing scheme is also applied, so that the patterns do
  333. not get TOO large: Since the MSB in the note value is never used,
  334. it is used for the compression. If the bit is set, then the other
  335. bits are interpreted as follows:
  336.  
  337. bit 0 set: Note follows
  338. 1 set: Instrument follows
  339. 2 set: Volume column byte follows
  340. 3 set: Effect follows
  341. 4 set: Effect parameter follows
  342.  
  343. It is very simple, but far from optimal. If you want to get better
  344. compression, you can always repack the patterns in your loader.
  345.  
  346. PSEUDOCODE:
  347.  
  348. ...
  349.  
  350. dbyt = getbyte();
  351.  
  352. if (dbyt AND 0x80) {
  353. if (dbyt AND 0x01) c_note = getbyte();
  354. if (dbyt AND 0x02) c_inst = getbyte();
  355. if (dbyt AND 0x04) c_vol = getbyte();
  356. if (dbyt AND 0x08) c_effect = getbyte();
  357. if (dbyt AND 0x10) c_param = getbyte();
  358.  
  359. } else {
  360. c_note = dbyt;
  361. current_row++;
  362. }
  363.  
  364. ...
  365.  
  366. ============================================================================
  367.  
  368. *************************
  369. * Player Processing: *
  370. *************************
  371.  
  372. This information is almost straight from XMP's technical
  373. documents (see "other docs" section for more info), and
  374. it explains how FT2 handles the different playing events:
  375.  
  376. Play = Play new note with new default volume
  377. Switch = Play new note with current volume
  378. OldVol = Don't play sample, set old default volume
  379. Cut = Stop playing sample
  380. Cont = Continue playing sample
  381.  
  382. ---------- INSTRUMENT -----------
  383. Event | None | Same | Valid | Invalid
  384. ---------------+--------+--------+--------+----------------------
  385. New Note | Switch | Play | Play | Cut (1)
  386. New Instrument | - | OldVol | OldVol | OldVol
  387. Tone Porta | Cont | OldVol | OldVol | OldVol
  388.  
  389. (1) This means that if There was NO instrument, FT2 Switches.
  390. And if it is Same as currently playing instrument, FT2 Plays, etc.
  391.  
  392. ============================================================================
  393.  
  394. ********************
  395. * Instruments: *
  396. ********************
  397. INTRODUCTION
  398. ------------
  399. Instruments are a way to have more special control over playing of
  400. the sample(s) and "combining" several samples into one "package"
  401. that can be used in similar way to a normal sample. This means that,
  402. numerous (16 in XM format) samples from one "realworld" instrument
  403. could be taken in various pitches, and then, using instrument editor,
  404. combined into a good simulation of the real-world one.
  405.  
  406. Why would you want to do that? You could have just one sample and
  407. save memory? And the envelopes could be done with effect commands?
  408.  
  409. Yes, but many times it is much better to have several samples of one
  410. real-world instrument since if just one sound sample is used, the
  411. sound gets more distorted as the playing pitch gets further from the
  412. original sampling pitch. Using envelopes gives more flexible and general
  413. control of the instrument and you can still use the effects if you want.
  414.  
  415. This is just one reason for using instruments, there are many more
  416. (tips: chiptunes, drumsets), just look around.
  417.  
  418. IN XM-FORMAT
  419. ------------
  420. In XMs, a instrument combines a maximum of 16 samples to one
  421. package with certain parameters. (NOTICE that the _internal_
  422. representation in FT2 is not exactly same, you can notice that
  423. by looking the value-ranges in here, sample-header structures
  424. and in FT2's instrument editor...)
  425.  
  426. Value Range
  427. - Instrument volume | 00..3F
  428. - Panning | 00..FF
  429. - Tuning | -128..127
  430. - Fade-out | 000..FFF
  431.  
  432. - Auto-Vibrato:
  433. * Speed | 00..3F
  434. * Depth | 00..0F
  435. * Sweep | 00..FF (In other trackers may be 0..FFFF !)
  436.  
  437. - Envelopes:
  438. * Volume
  439. * Panning
  440.  
  441. All of these parameter settings apply to every sample in the
  442. instrument. Envelopes and auto-vibrato are discussed further
  443. in below.
  444.  
  445. ******************************
  446. * Volumes and envelopes: *
  447. ******************************
  448. First some mathematical stuff, explanations follow below...
  449.  
  450. The volume formula
  451. ==================
  452.  
  453. FinalVol = (FadeOutVol/65536)*(EnvelopeVol/64)*(GlobalVol/64)*(Vol/64)*Scale;
  454.  
  455. The panning formula
  456. ===================
  457.  
  458. FinalPan = Pan + ( (EnvelopePan-32)*(128-Abs(Pan-128)) / 32 );
  459.  
  460. NOTICE: The panning envelope values range
  461. from 0...64, not -128...+127
  462.  
  463.  
  464. Fadeout
  465. =======
  466. The FadeOutVol is originally 65536 (after the note has been triggered) and
  467. is decremented by "Instrument.Fadeout" each tick after note is released
  468. (with KeyOff Effect or with KeyOff Note)
  469.  
  470. NOTICE: Fadeout is not processed if Volume Envelope is DISABLED.
  471. (This means that the FadeOutVol stays at 65536)
  472.  
  473. Panning Envelope does not affect Fadeout.
  474.  
  475. Envelopes
  476. =========
  477. An excerpt from original XM documentation:
  478.  
  479. >> The envelopes are processed once per frame, instead of every
  480. >> frame where no new notes are read. This is also true for the
  481. >> instrument vibrato and the fadeout. Since I am so lazy and the
  482. >> tracker is rather self-explaining I am not going to write any
  483. >> more for the moment.
  484.  
  485. Introduction to envelopes
  486. -------------------------
  487. Envelopes are a simple, yet ingenious way to achieve more versatile
  488. control over the instrument's volume/panning abilities with much
  489. less effort than using conventional ways (effects, volume-changes).
  490.  
  491. Describing all the possibilities of envelopes (or instruments as whole!)
  492. would be impossible effort! Envelopes and instruments have been widely
  493. used in all imaginable and unimaginable ways in XMs... This is why it
  494. is important to implement these features correctly in a module-player.
  495.  
  496. General information
  497. -------------------
  498. As stated above, envelopes are processed on each "frame". The
  499. frame is quite much similar to our familiar friend "tick". Frames,
  500. however, are separate from ticks and are only reset on "envelope
  501. reset", whereas ticks are reset on every new row.
  502.  
  503. In practice, the envelope processing routine should increase a
  504. "frame_counter" integer value for all envelopes (_separately_ for
  505. both volume & panning envelopes!) and for every playing instrument.
  506. This frame-counter is then used when interpolating between the
  507. envelope points.
  508.  
  509. Envelope is reset (or "triggered") when:
  510. - A new note is set
  511. - A new instrument is set
  512. - A Lxx-effect is issued (See Lxx-effect description below!!)
  513. (Lxx resets both envelopes, volume and panning.)
  514.  
  515. Envelope reset means that frame_counter of the envelope is
  516. set to zero or other value (in case of Lxx), the envelope
  517. is ACTIVATED and other possible internal values are initialized.
  518.  
  519. PSEUDOCODE
  520. ----------
  521. !! NOTICE: SEE XM-structure descriptions in above sections for info on the
  522. !! envelope-points!
  523.  
  524. if (envelope_enabled) then
  525.  
  526. PROCESS_ENVELOPE_FRAME:
  527.  
  528. frame_counter = 0..65535, triggered/reset appropriately.
  529.  
  530. current_point = [get the point number 0..MAX_ENVELOPE_POINTS-1
  531. which has (nframe < frame_counter), BUT where
  532. current_point+1 point has (nframe > frame_counter)
  533. ]
  534.  
  535. !! NOTICE: You don't need to worry about the first point's nframe-value,
  536. !! it will be always ZERO. (If not, then it's a buggy module :-)
  537.  
  538. point_d = (env_pnts[current_point+1].nframe - env_pnts[current_point].nframe);
  539. value_d = (env_pnts[current_point+1].value - env_pnts[current_point].value);
  540.  
  541. cval = (current_frame - env_pnts[current_point].nframe);
  542.  
  543. final_env_output = env_pnts[current_point].value +
  544. ((value_d * cval) / point_d);
  545.  
  546. This is how it works approximately, the interpolation could be made
  547. more efficient and you also have to take into account all the other
  548. things about envelopes, like triggering, etc. <ADVERTISEMENT>
  549. Check out J Sound System if you want to see how ;) </ADVERTISEMENT>
  550.  
  551. I'll try to write more about this when I feel so :-)
  552.  
  553.  
  554. Autovibrato
  555. -----------
  556. [Information about autovibrato may not be too accurate, I'll
  557. try to fix this when I get my tests finished on this subject.]
  558.  
  559. The instrument autovibrato works like the normal vibrato effect,
  560. except that it is applied on EVERY frame of instrument and uses
  561. it's own parameters.
  562.  
  563. - Vibrato is applied even if envelope(s) are not enabled. This
  564. means that you need to do the autovibrato separately from
  565. envelope processing.
  566.  
  567. - The Vibrato Sweep is a parameter that describes the speed when
  568. the "full power of vibrato" is reached. After reaching the
  569. maximum value, it stays on it.
  570.  
  571. - It SEEMS (or rather like "hears") that the vibrato sweep actually
  572. stays on the value it had when KeyOff was received. I am not 100%
  573. sure about this, but I it really sounds like it. I have added this
  574. to the pseudocode below.
  575.  
  576. - Other parameters work as in normal vibrato effect.
  577.  
  578. This is the formula that I have developed for the vibrato
  579. depth calculation:
  580.  
  581. Range definitions:
  582. vib_speed = [0..3F]
  583. vib_depth = [0..F]
  584. vib_sweep = [0..FF]
  585. curr_frame= [0..FFFF]
  586.  
  587. Calculations:
  588.  
  589. if (keyoff = FALSE) {
  590. if (curr_frame < vib_sweep)
  591. tmp = curr_frame;
  592. else
  593. tmp = vib_sweep;
  594. }
  595.  
  596. final_depth = (tmp * vib_depth) / vib_sweep;
  597.  
  598. [!!!!! NOT FINISHED YET !!!!!]
  599.  
  600. ********************************
  601. * Periods and frequencies: *
  602. ********************************
  603.  
  604. PatternNote ranges in 1..96
  605. 1 = C-0
  606. 96 = B-7
  607. 97 = Key Off (special 'note')
  608.  
  609. FineTune ranges between -128..+127
  610. -128 = -1 halftone,
  611. +127 = +127/128 halftones
  612.  
  613. RelativeTone is then in range -96..95, so in
  614. effect a note with RelativeTone value 0 is the
  615. note itself.
  616.  
  617. Formula for calculating the real, final note value is:
  618.  
  619. >> RealNote = PatternNote + RelativeTone;
  620.  
  621. So the range of RealNote is 1..119, where
  622.  
  623. 1 = C-0
  624. 119 = A#9
  625.  
  626. NOTICE: This is higher than the max for PatternNote (96)!
  627.  
  628. Linear frequency table
  629. ======================
  630. The formulas for calculating period and frequency for
  631. Linear frequency table, are as follows:
  632.  
  633. > Period = (10*12*16*4) - (Note*16*4) - (FineTune/2)
  634. > Frequency = 8363*2^((6*12*16*4 - Period) / (12*16*4))
  635.  
  636. Which naturally can be simplified to:
  637.  
  638. > Period = 7680 - (Note * 64) - (FineTune / 2)
  639. > Frequency = 8363 * 2^((4608 - Period) / 768)
  640.  
  641. NOTICE: The values are reasonable. With note 119
  642. and finetune of +128, we get:
  643.  
  644. > x = 7680 - (119*64) - (128/2)
  645. > x = 64 - 64
  646. > x = 0
  647.  
  648.  
  649. Amiga frequency table
  650. =====================
  651. The formulas for calculating period and frequency for
  652. Amiga (logarithmic) frequency table, are as follows:
  653.  
  654. Period = (PeriodTab[(Note MOD 12)*8 + FineTune/16]*(1-Frac(FineTune/16)) +
  655. PeriodTab[(Note MOD 12)*8 + FineTune/16]*(Frac(FineTune/16)))
  656. *16/2^(Note DIV 12);
  657.  
  658. (The period is interpolated for finer finetune values)
  659.  
  660. Frequency = 8363*1712/Period;
  661.  
  662. << NOTICE FROM Sahara Surfers:
  663.  
  664. The interpolation code above doesn't work because of several reasons:
  665.  
  666. 1. It does not interpolate. (Try adding 1 to the
  667. PeriodTab index in the second line)
  668.  
  669. 2. It may go past the table beginning for negative
  670. finetune values.
  671.  
  672. Write your own interpolation routine instead - it's not that hard.
  673. >>
  674.  
  675.  
  676. PeriodTab = Array[0..12*8-1] of Word = (
  677. 907,900,894,887,881,875,868,862,856,850,844,838,832,826,820,814,
  678. 808,802,796,791,785,779,774,768,762,757,752,746,741,736,730,725,
  679. 720,715,709,704,699,694,689,684,678,675,670,665,660,655,651,646,
  680. 640,636,632,628,623,619,614,610,604,601,597,592,588,584,580,575,
  681. 570,567,563,559,555,551,547,543,538,535,532,528,524,520,516,513,
  682. 508,505,502,498,494,491,487,484,480,477,474,470,467,463,460,457);
  683.  
  684. << Note! The period table is made for 1-based note numbers, so in
  685. practise it contains the period values for B-3 to G#4. Fun. >>
  686.  
  687.  
  688. *************************
  689. * Standard effects: *
  690. *************************
  691.  
  692. ##| Eff | Info | Description
  693. --+-----+------+------------------------------
  694. 00: 0 | | Arpeggio
  695. 01: 1 | (*) | Porta up
  696. 02: 2 | (*) | Porta down
  697. 03: 3 | (*) | Tone porta
  698. 04: 4 | (*) | Vibrato
  699. 05: 5 | (*) | Tone porta+Volume slide
  700. 06: 6 | (*) | Vibrato+Volume slide
  701. 07: 7 | (*) | Tremolo
  702. 08: 8 | | Set panning
  703. 09: 9 | | Sample offset
  704. 10: A | (*) | Volume slide
  705. 11: B | | Position jump
  706. 12: C | | Set volume
  707. 13: D | | Pattern break
  708. 14: E1 | (*) | Fine porta up
  709. --: E2 | (*) | Fine porta down
  710. --: E3 | | Set gliss control
  711. --: E4 | | Set vibrato control
  712. --: E5 | | Set finetune
  713. --: E6 | | Set loop begin/loop
  714. --: E7 | | Set tremolo control
  715. --: E9 | | Retrig note
  716. --: EA | (*) | Fine volume slide up
  717. --: EB | (*) | Fine volume slide down
  718. --: EC | | Note cut
  719. --: ED | | Note delay
  720. --: EE | | Pattern delay
  721. 15: F | | Set tempo/BPM
  722. 16: G | | Set global volume
  723. 17: H | (*) | Global volume slide
  724. 20: K | | Key off (Also note number 97)
  725. 21: L | | Set envelope position
  726. 24: P | (*) | Panning slide
  727. 26: R | (*) | Multi retrig note
  728. 28: T | | Tremor
  729. 31: X1 | (*) | Extra fine porta up
  730. --: X2 | (*) | Extra fine porta down
  731.  
  732. (*) = If the effect PARAMETER byte is zero, the last nonzero
  733. byte for the effect should be used. (This means that the
  734. effect "remembers" it's parameters!)
  735.  
  736. This also applies to E1x/E2x, EAx/EBx, X1x/X2x, where the
  737. "x" is checked for zero, if it is zero, then use last non-zero.
  738.  
  739. SEE ALSO THE INDIVIDUAL EFFECT NOTES BELOW!
  740. (For more information and bugs + specialties)
  741.  
  742.  
  743. In general, the commands are reasonably Protracker compatible
  744. although not all PT "features" (some might call them replay
  745. routine bugs) are implemented.
  746.  
  747.  
  748. **************************
  749. * Effect descriptions: *
  750. **************************
  751.  
  752. This is the effect info section. All the information contained
  753. here is based on my (ccr) experiments on FT2 and XM format.
  754. I have only added notes for the effects that need some attention,
  755. the ones left out should be implemented as in PT MOD.
  756.  
  757. 1xx - Porta up (*)
  758. -------------------
  759. Bends the frequency of channel/sample UP by PERIODS.
  760.  
  761. NOTICE! Parameters (and their saved values) are SEPARATE from
  762. values of effect 2xx (Porta down) and 3xx (Tone porta)!!
  763.  
  764. 2xx - Porta down (*)
  765. ---------------------
  766. Bends the frequency of channel/sample DOWN by PERIODS.
  767.  
  768. NOTICE! Parameters (and their saved values) are SEPARATE from
  769. values of effect 1xx (Porta up) and 3xx (Tone porta)!!
  770.  
  771. 3xx - Tone porta (*)
  772. ---------------------
  773. Bends the frequency of channel/sample to the given
  774. and saved note value by PERIODS.
  775.  
  776. NOTICE#1! Parameters (and their saved values) are SEPARATE from
  777. values of effect 1xx (Porta up) and 2xx (Porta down)!!
  778.  
  779. NOTICE#2! If a new note is got, but porta speed (parameter) is
  780. 0, the new note is ignored.
  781.  
  782. NOTICE#3! The NOTICE#2 also applies to new instrument number!
  783. (This does not work as in Impulse Tracker!)
  784.  
  785. SEE ALSO: Volume column Tone porta.
  786.  
  787. 4xy - Vibrato (*)
  788. ------------------
  789.  
  790. SEE ALSO: Volume column vibrato.
  791.  
  792. --------------------========================
  793. 5xx - Tone porta+Volume slide (*)
  794. 6xx - Vibrato+Volume slide (*)
  795. 7xy - Tremolo (*)
  796. 8xx - Set panning
  797. --------------------========================
  798.  
  799. 9xx - Sample offset (*)
  800. ------------------------
  801. Set sample offset to parameter * 256 units (aka bytes
  802. or 16-bit words, depending on the sample format).
  803.  
  804. NOTICE#1! Unlike stated in original XM documentation, this
  805. effect DOES remember it's parameters, aka last non-zero
  806. parameter is used.
  807.  
  808. NOTICE#2! If there is no instrument set on the same row,
  809. this effect is ignored:
  810.  
  811. C-4 01 -- 950 >> Plat from offset 256*50H <--+
  812. ... .. -- 000 |
  813. C-4 01 -- 000 >> Play from offset 0 |
  814. ... .. -- 000 |
  815. C-4 01 -- 900 >> Play from offset 256*50H ---+
  816. ... .. -- 910 >> No instrument, 9xx IGNORED! |
  817. C-4 01 -- 900 >> Play from offset 256*50H ---+
  818.  
  819.  
  820. Axy - Volume slide (*)
  821. -----------------------
  822. Remembers it's parameters, but is NOT connected
  823. with the volume column effect volume slides.
  824.  
  825. SEE ALSO: Volume column Volume slide.
  826.  
  827. Cxx - Set volume
  828. -----------------
  829. The volume column effects are not supported by this command,
  830. so don't use the same routine as the "main" volume setting
  831. for this (IF you use that for vol.col. effect checking too!).
  832.  
  833. Dxx - Pattern break
  834. --------------------
  835. Works like in S3M/MOD. The parameter is in BCD format,
  836. and the final row for jump is calculated as follows:
  837.  
  838. jump_to_row = (paramY*10 + paramX)
  839.  
  840.  
  841. E1x - Fine portamento Up
  842. ------------------------
  843. ...
  844.  
  845. E2x - Fine portamento Down
  846. --------------------------
  847. ...
  848.  
  849. E6x - Set loop begin/loop
  850. --------------------------
  851. This effect may SEEM TO USUALLY work, BUT:
  852.  
  853. 1) If a loop is set on pattern N in row R (with E60), and no
  854. pattern jump/break effects are used after that, FT2 will
  855. start playing the next pattern (N+1) from row R instead
  856. of row 0!
  857.  
  858. a) Pattern Jump and Pattern Break reset this. Bug only
  859. occurs if PJ or PB have NOT been used.
  860.  
  861. a) Affects also MOD-files made with FT2! So MOD-players
  862. should also support this "feature".
  863.  
  864. [Tested with: 2.04, 2.06 and 2.08]
  865.  
  866. 2) If two or more pattern loop commands are on the same row
  867. (on different channels), strange behaviour occur: FT2 may
  868. jump to a random row, or perform the loop random times or
  869. even do the effect right, but at least v2.08 did all these
  870. just randomly without any reproducable pattern!
  871.  
  872. NOTICE: This is a REAL BUG in FT2 and the working of the
  873. effects is random and cannot be reproduced. (So you don't
  874. need to bother to implement this.)
  875.  
  876. NOTICE TO TRACKERS: Avoid using two or more Pattern Loops
  877. on same row as this effect is buggy and results are undefined!
  878. (It may first SEEM that it works right, but try to play it
  879. 5-10 times [with Play Song/Play Pattern] and you will see that
  880. it does strange things.)
  881.  
  882. [Tested with: 2.06 and 2.08]
  883.  
  884. ADDITIONAL: The Loop Position is NOT zeroed when the pattern
  885. changes, so if set to row X previously, and on some other pattern
  886. does not re-set it, a loop effect will loop to the same row.
  887.  
  888. (In Scream Tracker 3 S3M-format, the loop-position is reset to 0
  889. always when the pattern changes! Impulse Tracker [2.14 at least] is
  890. similar to FT2, it also uses the latest parameter.)
  891.  
  892. E9x - Retrig note
  893. ------------------
  894. ...
  895.  
  896. EEx - Pattern delay
  897. --------------------
  898. This effect works otherwise normally, BUT:
  899.  
  900. FT2 simply forgets to play/update other effects on
  901. the row when there's a Pattern Delay:
  902.  
  903. 01|--- -- EB1|--- -- EE5|...
  904.  
  905. The Fine Volume Slide Down (EB1) won't be played here,
  906. thought it should be updated five times (EE5)!
  907.  
  908. [Tested with: 2.04, 2.06 and 2.08]
  909.  
  910. Fxx - Set Speed / Tempo
  911. ------------------------
  912. if (Param > 0) then
  913. if (Param <= $1F)
  914. then Speed = Param;
  915. else Tempo = Param;
  916.  
  917. As you notice, a zero parameter should be ignored.
  918.  
  919. Kxx - Key Off ( also note number 97 )
  920. --------------------------------------
  921. The parameter of this effect does not have any meaning.
  922. (At least any that I would be aware of)
  923.  
  924. This effect does the same as note-number 97 dec, in practice,
  925. it "releases" the virtual "key" or note. See description of
  926. Instruments and Envelopes above for more info.
  927.  
  928. Lxx - Set envelope position
  929. ----------------------------
  930. Set the current position in the envelopes to FRAME
  931. number XX, between 00-FFh. (See also Envelope-description
  932. section for more information)
  933.  
  934. This command also re-triggers the ENVELOPES (not the note/sample
  935. though), so if the envelope had stopped, it will be reset (and
  936. set to the given offset position.)
  937.  
  938. UNKNOWN: (TO-DO-list)
  939. - Does it reset other than framepos? (e.g. fadeout?)
  940.  
  941. Pxx - Panning slide (*)
  942. ------------------------
  943. ...
  944.  
  945. Rxx - Multi retrig note (*)
  946. ----------------------------
  947. ...
  948.  
  949. Txx - Tremor
  950. -------------
  951. ...
  952.  
  953.  
  954. *********************************
  955. * Effects in volume column: *
  956. *********************************
  957.  
  958. All effects in the volume column should work as the standard effects.
  959. The volume column is interpreted before the standard effects, so
  960. some standard effects may override volume column effects.
  961.  
  962. Value | Meaning
  963. ---------+-----------------------------
  964. 0 | Do nothing
  965. $10-$50 | Set volume (Value-$10)
  966. : | : :
  967. : | : :
  968. $60-$6f | Volume slide down
  969. $70-$7f | Volume slide up
  970. $80-$8f | Fine volume slide down
  971. $90-$9f | Fine volume slide up
  972. $a0-$af | Set vibrato speed
  973. $b0-$bf | Vibrato
  974. $c0-$cf | Set panning
  975. $d0-$df | Panning slide left
  976. $e0-$ef | Panning slide right
  977. $f0-$ff | Tone porta
  978.  
  979.  
  980. ****************************************
  981. * Volume column effect descriptions: *
  982. ****************************************
  983. Here are some notes on the volume column effects:
  984. (See also the WARNINGS in the normal effect explanation section!)
  985.  
  986. 1) Volume slides (normal and fine) DO NOT remember
  987. their parameters and are NOT connected with the
  988. "normal volume effects". Examples:
  989.  
  990. C-4 01 -- 000 >> Starts playing inst #1 at C-4
  991. ... .. -1 000 >> Lowers volume of channel by 1
  992. ... .. -0 000 >> Does not do ANYTHING!
  993. ... .. -- 000 >>
  994.  
  995. The above applies to all volume column volume slide effects.
  996.  
  997.  
  998. 2) Vibrato effect DOES REMEMBER it's parameters and
  999. IS connected (shares saved parameters) with
  1000. "normal effect vibrato". Examples:
  1001.  
  1002. C-4 01 S5 000 >> S5 sets vibrato speed to 5
  1003. ... .. V1 000 >> V1 starts vibrating with speed 5 and depth of 1
  1004. ... .. V0 000 >> continues vibrating witht depth of 1
  1005. ... .. V0 000 >> and same as above..
  1006. ... .. 00 400 >> !! still vibrates with same params!
  1007. ... .. 00 400 >> !! and same as above..
  1008. ... .. V0 400 >> !! _doubles_ the vibration (as expected)
  1009.  
  1010. This means that volume column effects "Sx" with "Vy" are
  1011. equal to normal effect "4xy"!
  1012.  
  1013.  
  1014. 3) Tone portamento effect DOES REMEMBER it's parameters and
  1015. IS connected (shares saved parameters) with "normal porta
  1016. effect" parameter. (See also notes about the effect 3xx!)
  1017. Examples:
  1018.  
  1019. C-4 01 -- 000 >> Starts playing inst #1 at C-4
  1020. ... .. -- 000
  1021. C-6 01 M1 000 >> M1 starts bending to C-6 with speed of 1
  1022. ... .. -- 000
  1023. ... .. M0 000 >> continues bending to C-6 with speed of 1
  1024. ... .. -- 000
  1025. ... .. -- 300 >> !! continues bending to C-6 with speed of 1
  1026.  
  1027. This means that volume column effect "Mx" is
  1028. equal to normal effect "30x"!
  1029.  
  1030.  
  1031. **************************
  1032. * Bugs/Features of FT2 *
  1033. **************************
  1034. There are few known "features" in FT2's player system, which
  1035. could be considered "bugs", but since we are thinking only
  1036. about playing an XM correctly, they should be considered features
  1037. which need to be implemented.
  1038.  
  1039. Here's a list of these features:
  1040.  
  1041. - Pattern Loop replay features.
  1042. See description of effect E6x for more information.
  1043.  
  1044. - Pattern Delay replay feature.
  1045. See description of effect EEx for more information.
  1046.  
  1047. Here is a list of REAL BUGS which should be attributed
  1048. by the FastTracker 2 maintainers:
  1049.  
  1050. - Effect parameters not initialized/zeroed when playing starts.
  1051.  
  1052. During my tests on FT2 I found out that on effects that "remember"
  1053. their parameters (e.g. save the previous non zero parameter), FT2
  1054. DOES NOT CLEAR THE SAVE VALUES when it starts playing!
  1055. This means that if you use this kind effect with zero before using
  1056. non zero value on that effect and channel, results are UNDEFINED!
  1057. This may affect the playing of some modules! (Tested on FT2.08/2.06)
  1058.  
  1059. - Bugs in Pattern Loop effect.
  1060. See description of effect E6x for more information.
  1061.  
  1062.  
  1063. **********************************
  1064. * Other trackers and detecting *
  1065. **********************************
  1066. Aside from the programs mentioned here, there are number of conversion
  1067. utilities and other trackers that are capable of saving to XM-format.
  1068. Some of those don't do it properly and might set the identification
  1069. tags (TrackerName, format version) identical to FT2, etc.
  1070.  
  1071. SoundTracker
  1072. ------------
  1073. An "FT2 clone" for Unixes, a GNU GPL licensed tracker running
  1074. under X Window System and Gtk+ toolkit. Supports at least x86
  1075. based platforms.
  1076.  
  1077. Platform : Linux and other UNIX-type OS
  1078. Author : Michael Krause
  1079. Available : http://www.soundtracker.org/
  1080. TrackerName TAG: "rst's SoundTracker "
  1081. (last empty characters are spaces, ASCII 32 dec)
  1082.  
  1083. Provides also extra effects:
  1084. Qxx - Set LP Filter Resonance
  1085. Zxx - Set LP Filter Cut-Off Frequency
  1086.  
  1087. These effects are also supported by OpenCP player, from which the
  1088. player code has been taken from to SoundTracker. (More info about
  1089. these effects can be got from SoundTracker and/or OpenCP sourcecode
  1090. which are available under GNU GPL license)
  1091.  
  1092. DigiTrakker
  1093. -----------
  1094. A quite tracker in it's own, Shareware. I don't know whether it
  1095. is maintained anymore.
  1096.  
  1097. Platform : DOS (at least)
  1098. Author : prodatron/n-Factor
  1099. Available : ??? (search the Internet)
  1100. TrackerName TAG: Changes
  1101.  
  1102. This is a quite special case. DigiTrakker misuses the TrackerName
  1103. TAG and puts the name of the composer there, if there is any set.
  1104. This behavior makes it very hard to detect XMs made with DigiTrakker.
  1105.  
  1106. IT2XM
  1107. -----
  1108. Not really a tracker, but a Impulse Tracker (.IT) to XM
  1109. format converter.
  1110.  
  1111. Platform : DOS
  1112. Author : Andy Voss (Phoenix/Hornet)
  1113. Available : ???
  1114. TrackerName TAG: Identical to FT2
  1115.  
  1116. Due to differences in IT's XM-replay and differences in IT/XM
  1117. formats in general, it is not possible to accurately replay
  1118. an converted XM. And since the trackername-tag is identical to
  1119. FT2's, abandon all hope...
  1120.  
  1121.  
  1122. **********************
  1123. * Other documents? *
  1124. **********************
  1125. I highly recommend that you also read other material available,
  1126. even the ones for other formats since they might help you to understand
  1127. the design choices behind FT2. Here is a list of docs I have read and
  1128. found useful in creation of JSS and this document:
  1129.  
  1130. - Extended Module Player (XMP)'s technical documents
  1131. by Claudio Matsuoka and Hipolito Carraro Jr.
  1132. [http://xmp.helllabs.org/]
  1133. - Firelight's (Brett Paterson) FMODDOC (and FS3MDOC)
  1134. - ProTracker 2.1A player source and v3.61 format documentation.
  1135. - And of course the documents mentioned in the "credits"
  1136. section of this file. They contained valuable information
  1137. that I used as a very basis of this doc.
  1138.  
  1139. Thanks to the writers of above docs, it would not have been possible
  1140. to write JSS or this doc without you!
  1141.  
  1142. All the documents are available at the J Sound System's homepage:
  1143. http://jss.sf.net/moddoc/
  1144.  
  1145. *****************
  1146. * Final Words *
  1147. *****************
  1148. That's it. 'nuff said. Too much talk, far too less deeds done.
  1149.  
  1150. Questions? Send me some e-mail.
Advertisement
Add Comment
Please, Sign In to add comment