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 bloatingYmPlayerGeneric - 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 - Timing control: Defaults to 44.1 kHz / 2 MHz but supports custom host sample rates; YM5/6 master clocks are applied automatically
- Optional Features: Streaming audio output
Install
Add the crate to your Cargo.toml:
[]
= "0.9"
Usage
Basic Playback
use ;
let data = read?;
let = load_song?;
// Use the unified ChiptunePlayer interface
player.play;
let samples = player.generate_samples;
// Access metadata
println!;
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 to provide better separation of concerns:
- ym2149-core: Pure YM2149 chip emulation
- ym2149-ym-replayer: YM file parsing and playback (this crate)
Migration from ym2149-core < 0.6
If you were using the deprecated modules from ym2149-core:
// Old (deprecated)
use Ym6Player;
use ym_loader;
// New (recommended)
use YmPlayer;
use loader;
Feature Flags
default: Includes effects, tracker, and digi-drums supporteffects: Enable YM6 effect processingtracker: Enable tracker mode supportdigidrums: Enable Mad Max digi-drumsexport-wav: Enable WAV file export (requireshound)
MP3 export was removed because the LAME/Autotools toolchain is fragile across environments. Export WAV and transcode externally (e.g.,
ffmpeg).
License
See the main ym2149-rs repository for license information.