ym2149-ym-replayer
YM file format parser and music replayer for YM2149 PSG chips.
This crate provides comprehensive support for parsing and playing back YM chiptune files, including YM2/3/5/6 formats, tracker modes, and various hardware effects.
Features
- YM Format Support: YM2, YM3, YM5, YM6 file formats with LHA decompression
- Tracker Modes: YMT1 and YMT2 tracker format support
- Format Profiles:
FormatProfiletrait encapsulates format quirks (YM2 drum mixing, YM5 effect encoding, YM6 sentinel handling) so new formats plug in without bloatingYm6PlayerGeneric - Frame Sequencer: Dedicated
FrameSequencerstores frames + timing and exposes seek/loop APIs - Effects Pipeline:
EffectsPipelinewraps the low-levelEffectsManager, tracking SID/digidrum state for visualization/metadata - Hardware Effects:
- Mad Max digi-drums
- YM6 SID voice effects
- Sync buzzer effects
- Backend Agnostic: Works with any
Ym2149Backendimplementation - Optional Features: Streaming audio output
Install
Add the crate to your Cargo.toml:
[]
= "0.6"
Usage
Basic Playback
use ;
let data = read?;
let = load_song?;
player.play?;
// Generate audio samples
let samples = player.generate_samples;
Loading from Files
use loader;
// From file path
let frames = load_file?;
// From bytes
let data = read?;
let frames = load_bytes?;
Format Profiles & Effects Pipeline
Internally the player is split into three layers:
- FrameSequencer – Owns the register frames, loop point, and PAL/NTSC timing and offers seek/loop APIs.
- FormatProfile – Trait implemented per format (YM2/YM5/YM6/basic) so register preprocessing and effect decoding live behind
FormatModestrategies instead ofis_ym*_modeflags. - EffectsPipeline – Wraps the low-level
EffectsManager, tracks which SID/digidrum voices are active, and feeds the backend every sample.
load_song automatically selects the right profile, and custom loaders can create a profile via ym2149_ym_replayer::player::create_profile. Metadata and Bevy visualizers now query effect state through the pipeline.
Architecture
This crate was extracted from ym2149-core v0.6.0 to provide better separation of concerns:
- ym2149-core: Pure YM2149 chip emulation
- ym2149-ym-replayer: YM file parsing and playback (this crate)
- ym2149-softsynth: Experimental synthesizer backend (workspace helper; not published)
Migration from ym2149-core < 0.6
If you were using the deprecated modules from ym2149-core:
// Old (deprecated)
use Ym6Player;
use ym_loader;
// New
use Ym6Player;
use loader;
Feature Flags
default: Includes effects, tracker, and digi-drums supporteffects: Enable YM6 effect processingtracker: Enable tracker mode supportdigidrums: Enable Mad Max digi-drumsstreaming: Enable real-time audio output (requiresrodio) - for CLI/standalone use; Bevy integration uses native audioexport-wav: Enable WAV file export (requireshound)export-mp3: Enable MP3 file export (requiresmp3lame-encoder)softsynth: Workspace-only hook for experimental software synthesizer backends (requires providing your ownym2149-softsynthvia[patch])
License
See the main ym2149-rs repository for license information.