xm

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xm loads FastTracker 2 XM 1.04 modules and replays pitched PCM.

Index

Constants

View Source
const Profile = "FastTracker 2 XM 1.04 PCM"

Profile is the name of the supported playback profile.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Note, Instrument, Volume, Effect, Param uint8
}

Cell retains the XM note, instrument, volume-column and command bytes.

type ChannelState

type ChannelState struct {
	Instrument, Sample             uint8
	Period, Volume, PlaybackPeriod int
}

ChannelState reports a channel's selected instrument, sounding sample slot, native period and volume before applying the volume envelope.

type Envelope

type Envelope struct {
	Points                             []EnvelopePoint
	Sustain, LoopStart, LoopEnd, Flags uint8
}

Envelope preserves an instrument's native point list and loop indices.

type EnvelopePoint

type EnvelopePoint struct {
	Tick, Value int
}

EnvelopePoint is a native tick and level.

type Instrument

type Instrument struct {
	Name                                                 string
	Type                                                 uint8
	Keymap                                               [96]uint8
	Volume, Pan                                          Envelope
	VibratoType, VibratoSweep, VibratoDepth, VibratoRate uint8
	Fadeout                                              int
	Samples                                              []Sample
}

Instrument contains the note-to-sample map and native playback metadata.

type Module

type Module struct {
	Title, Tracker                                string
	Version, Restart, Channels, Flags, Speed, BPM int
	Orders                                        []uint8
	Patterns                                      []Pattern
	Instruments                                   []Instrument
}

Module contains an XM 1.04 song and its native timing and pitch flags.

func Load

func Load(r io.Reader) (*Module, error)

Load reads a module of at most 256 MiB.

func Parse

func Parse(data []byte) (*Module, error)

Parse validates XM 1.04 patterns, instruments and mono PCM.

func (*Module) Metadata

func (m *Module) Metadata() tag.Metadata

Metadata returns the tags parsed from the XM module.

type Pattern

type Pattern [][]Cell

Pattern stores rows in native channel order.

type Replay

type Replay[T audio.Sample] struct {
	// contains filtered or unexported fields
}

Replay implements the XM PCM profile.

func NewReplay

func NewReplay[T audio.Sample](m *Module) (*Replay[T], tracker.ReplayConfig[T], error)

NewReplay builds a typed bank of samples with their instrument envelopes.

func NewReplayWithOptions

func NewReplayWithOptions[T audio.Sample](m *Module, options ReplayOptions) (*Replay[T], tracker.ReplayConfig[T], error)

NewReplayWithOptions builds the XM sample bank and replay with the selected timing and native restart behavior.

func (*Replay[T]) AppendChannelStates

func (r *Replay[T]) AppendChannelStates(dst []ChannelState) []ChannelState

AppendChannelStates appends the state after the most recent tick.

func (*Replay[T]) Reset

func (r *Replay[T]) Reset() error

Reset clears channel state before a pass through the song.

func (*Replay[T]) StepTick

func (r *Replay[T]) StepTick(ctx *tracker.TickContext) error

StepTick applies XM row commands and advances slides on later ticks.

type ReplayOptions

type ReplayOptions struct {
	// FastTrackerWAV uses the reference WAV renderer's truncated tick lengths
	// and fixed-point pitch at the output rate, up to 48 kHz.
	FastTrackerWAV bool

	AdditionalPlays int // Extra passes from the native restart order, preserving playback state.
}

ReplayOptions selects FastTracker-specific playback behavior.

type Sample

type Sample struct {
	Name                          string
	Length, LoopStart, LoopLength int64
	Volume, Type, Pan, Reserved   uint8
	FineTune, RelativeNote        int8
	PCM                           audio.Buffer[float64]
}

Sample describes a delta-encoded mono slot. Length and loop fields are measured in bytes, as in the XM header. PCM holds decoded source frames.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL