TuningFork.Mus (TuningFork v0.1.12)

Copy Markdown View Source

Reads DMX MUS, the music format of Doom and its engine's other games, into the same TuningFork.Midi value a MIDI file reads into, so it plays the same way.

lump
|> TuningFork.Mus.parse!()
|> TuningFork.Gm.score()
|> TuningFork.Score.render(44_100)

MUS runs at 140 ticks a second; the result is one track at 140 ticks a beat and sixty beats a minute, so its ticks are MUS's own. MUS channel 15, the percussion channel, becomes MIDI channel 9 and channels 9 to 14 move up one to make room. A note played without a volume takes the channel's last one. Instrument changes become program changes; volume, pan, expression and the pedals become their MIDI controllers; system events and the end-of-measure marker carry nothing a score uses and are dropped.

Summary

Functions

Parse a MUS lump: {:ok, midi}, or {:error, :not_mus} or {:error, :truncated}.

Parse a MUS lump, raising ArgumentError where parse/1 would fail.

Functions

parse(lump)

@spec parse(binary()) :: {:ok, TuningFork.Midi.t()} | {:error, :not_mus | :truncated}

Parse a MUS lump: {:ok, midi}, or {:error, :not_mus} or {:error, :truncated}.

parse!(lump)

@spec parse!(binary()) :: TuningFork.Midi.t()

Parse a MUS lump, raising ArgumentError where parse/1 would fail.