mod

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 11 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 mod loads four-channel M.K. modules and replays their PCM samples.

Index

Constants

View Source
const Profile = "four-channel M.K. MOD (PAL CIA)"

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 {
	Sample uint8
	Period uint16
	Effect uint8
	Param  uint8
}

Cell preserves the native sample number, period, and effect bytes.

type ChannelState

type ChannelState struct {
	Sample                uint8
	Period, Volume        int
	Offset, Length        int64
	LoopStart, LoopLength int64
}

ChannelState is a read-only snapshot of a MOD replay's sample selection and effect registers. Sample is the selected one-based slot. The sample may differ from the currently sounding voice when a cell selects a slot without triggering a note.

type Module

type Module struct {
	Title      string
	SongLength uint8
	Restart    uint8
	Orders     [128]uint8
	Patterns   []Pattern
	Samples    [slots]Sample
}

Module contains the song header, patterns and one-based sample slots.

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 and decodes an M.K. module.

func (*Module) Metadata

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

Metadata returns the tags parsed from the MOD module.

type Pattern

type Pattern [rows][channels]Cell

Pattern stores rows in native channel order.

type Replay

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

Replay implements the M.K. PAL CIA PCM profile.

func NewReplay

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

NewReplay builds the PCM bank and tracker configuration for a parsed module.

func (*Replay[T]) ChannelStates

func (r *Replay[T]) ChannelStates() [channels]ChannelState

ChannelStates reports the native registers after the most recent tick.

func (*Replay[T]) ClockState

func (r *Replay[T]) ClockState() (speed, bpm uint8)

ClockState reports the speed and BPM currently in effect. The scheduled CIA interval changes at the tick following an Fxx tempo command.

func (*Replay[T]) Reset

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

Reset clears channel and timing state before a pass through the song.

func (*Replay[T]) StepTick

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

StepTick applies ProTracker 2 row commands and later-tick slides.

type Sample

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

Sample describes a signed 8-bit PCM slot. Lengths and loop positions are measured in source frames, and FineTune uses eighths of a semitone.

Jump to

Keyboard shortcuts

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