Advertisement
Guest User

Untitled

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