MODPlay

Last week-end I wrote a MOD player.

MOD files were used to store music on the Amiga. As was common at the time, the format separates “instruments” (i.e., the encoding of the sounds used in the file) from the “score” (basically, which sound to play when).

MOD files contain the following types of information:

  • Samples: wavetables in 8-bit PCM audio, storing the sounds of each instrument. To produce different pitches, the samples are simply played back at different speeds.
  • Patterns: these are 64-by-4 tables, with each line corresponding to a time division, and each column to a channel. Each cell in that table can indicate a sample to play, its pitch, and an effect’s parameters. Effects can be audio effects like slide, vibrato, volume changes, etc. but are also used to set the player’s speed, jump to song positions, loop some sections, etc.
  • Pattern Table: a list of patterns to play at each song position.

Since sounds are generally short and reused a lot, and score information is sparse, this kind of format saves a lot of space. It was also fast to decode and play on the dedicated “Paula” sound chip of the Amiga.