README
¶
Module replay
Play the opening of Beethoven's "Ode to Joy" as four native tracker modules. Each version uses PCM waves generated for this demo. The complete playlist then plays the authored Korobeiniki arrangement with FM lead, pitched PCM, and 808-style and 909-style kick samples.
CGO_ENABLED=0 go run ./internal/test/tracker/module-replay
CGO_ENABLED=0 go run ./internal/test/tracker/module-replay -out module-replay.wav
CGO_ENABLED=0 go run ./internal/test/tracker/module-replay -format xm
Live playback opens the default CoreAudio or ALSA sink. WAV output is 48 kHz
stereo 16-bit PCM. Use -native-only to play all four modules without the
authored score. Use -sample clip.wav -root-hz 220 to hear a file-backed PCM
instrument in the Korobeiniki answer. The command prints the start time,
profile and output rate for each replay.
Loader and replay API
The packages tracker/mod, tracker/xm, tracker/s3m and tracker/it
expose Load(io.Reader) and Parse([]byte). Each returns its own *Module
with native orders, pattern commands, instrument headers, and normalized
planar PCM. Keep the parsed song read-only while any replay uses it. Allocate
a separate replay for each player. A load reads at most 256 MiB of input.
XM, S3M and IT also limit the decoded PCM budget to 16 million values.
m, err := xm.Load(reader)
if err != nil {
return err
}
replay, config, err := xm.NewReplay[float32](m)
if err != nil {
return err
}
player, err := tracker.NewReplayPlayer(sink.PCMFormat(), replay, config)
if err != nil {
return err
}
Read PCM through player.ReadFrames or pass the player to a mixer as a
source. Every replay builds a typed bank and derives its sample steps from
TickContext.RateHz(). Set config.RepeatCount before opening the player to
repeat the entire playable order list. S3M and IT expose PlayableOrders,
which maps replay order positions back to their native order table.
Coverage checklist
| Feature | Public API | Passage and check |
|---|---|---|
| MOD periods, signed PCM, forward loops, PAL CIA timing and LRRL stereo | mod.Load, mod.NewReplay, mod.Profile |
The melody starts on the left and a lower accompaniment plays on the right. Tests check period and finetune fields, the CIA command and duration, both channels, and pitch through the loop. |
| XM keymaps, 8-bit and 16-bit delta PCM, sample pan, volume column and tick envelopes | xm.Load, xm.NewReplay, xm.Profile |
The lower notes play a left reed and upper notes switch to a brighter right reed. The level holds, then drops following key-off. Tests check the decoded keymap, pitch, pan, sustain level and release. |
| S3M order skips, PCM, stereo and native timing | s3m.Load, s3m.NewReplay, s3m.Profile |
A skipped order precedes the melody. Two unsigned 16-bit PCM planes have distinct timbres. Tests check the native order map, speed command, channel levels and harmonics. |
| IT PCM sample mode, packed field reuse and volume-column pan | it.Load, it.NewReplay, it.Profile |
Repeated notes reuse the packed note and sample fields. The melody moves from left to right and ends with a note cut. Tests check reuse, source pitch, pan, volume and silence at the ending. |
| Module decoding, rate and replay lifecycle | Parse, tracker.NewReplayPlayer, Position, Restart, ReadFrames |
Tests reject truncated files and corrupt fields, check a deferred command's replay error, and verify sustained pitch and matching restart PCM at 44.1 and 48 kHz. |
| Authored editing, preview, voice replacement, pattern flow, effects, repeat and duration-based sequencing | tracker.NewSong, PreviewInstrument, NewSongPlayer, NewReplayPlayer, synth.NewSequencer |
Korobeiniki follows the four modules. Its trace checks the playhead and restart. The authored demo checklist gives each passage and check. |
| Tone, sine, FM, one-shot samples, source offsets and loop modes | synth.NewTone, Sine.NewVoice, FM.NewVoice, NewPCMInstrument, LoadPCMInstrument, ADSR, PointEnvelope |
The authored preview and score include the synth controls and the PCM answer, with distinct 808-style and 909-style kick attacks and tails. Tests check the FM sideband, answer pitches, kick attacks and tails, and WAV headroom. Use -sample for file-backed PCM. |
Profile limits
The demo opens the four original loader fixtures. See the baseline effect matrix for the currently supported native commands and the archive song verification.
MOD requires the four-channel M.K. tag. XM loads 1.04 mono PCM instruments and supports volume and pan envelopes. S3M supports uncompressed mono and stereo PCM instruments. IT supports mono and stereo PCM in sample and instrument modes, including IT compressed samples. The format-specific guides cover the native commands and playback options. XM verification and IT verification.
Fixture provenance
The demo uses the public-domain melody from Beethoven's Ninth Symphony.
The arrangement, PCM waves and encoded modules were made for this repository
and are distributed under its license. Regenerate the fixtures with
python3 internal/test/tracker/module-replay/testdata/generate.py.
Format references include OpenMPT's MOD loader, XM loader, S3M loader, IT loader, and the ProTracker CIA timer.