Expand description
§ym2149-sndh-replayer
SNDH file parser and Atari ST machine emulation for YM2149 chiptune playback.
This crate provides playback support for SNDH files, a popular format for Atari ST chiptune music. It includes:
- SNDH Parser: Parses SNDH file headers and metadata
- ICE Depacker: Decompresses ICE! 2.4 packed SNDH files
- 68000 CPU Emulation: Via the
m68000crate for executing SNDH drivers - MFP68901 Timer Emulation: For accurate timer-based effects (SID voice, etc.)
- Atari ST Machine: Memory-mapped I/O emulation for YM2149 and timers
§Example
ⓘ
use ym2149_sndh_replayer::{SndhPlayer, load_sndh};
use ym2149_common::ChiptunePlayer;
let data = std::fs::read("music.sndh")?;
let mut player = load_sndh(&data, 44100)?;
// Select subsong (1-based index)
player.init_subsong(1)?;
player.play();
// Generate audio samples
let mut buffer = vec![0.0f32; 882]; // ~50Hz at 44100 sample rate
player.generate_samples_into(&mut buffer);§SNDH Format
SNDH is a standard format for Atari ST music that embeds the original 68000 replay code along with the music data. The format uses a simple header followed by executable code:
- Entry point + 0: Initialize subsong (D0 = subsong number)
- Entry point + 4: Exit/cleanup
- Entry point + 8: Play one frame (called at player rate, typically 50Hz)
Many SNDH files are ICE! packed for smaller file sizes.
Structs§
- Basic
Metadata - Basic metadata container implementing
PlaybackMetadata. - Sndh
File - SNDH file representation
- Sndh
Flags - SNDH feature flags (from FLAG tag, SNDH v2.2)
- Sndh
Metadata - SNDH file metadata
- Sndh
Player - SNDH file player.
- Subsong
Info - Information about a specific subsong
Enums§
- DmaSample
Rate - DMA sample rates for STE and Falcon
- Playback
State - Playback state for chiptune players.
- Sndh
Error - Errors that can occur during SNDH parsing and playback.
Traits§
- Chiptune
Player - Unified player interface for chiptune formats.
- Playback
Metadata - Unified metadata trait for chiptune playback.
Functions§
- ice_
depack - Depack ICE! 2.4 compressed data.
- is_
ice_ packed - Check if data is ICE! 2.4 packed.
- is_
sndh_ data - Check if data appears to be SNDH format.
- load_
sndh - Load an SNDH file and create a player.
Type Aliases§
- Result
- Result type for SNDH operations.