Skip to main content

Crate ym2149_sndh_replayer

Crate ym2149_sndh_replayer 

Source
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 m68000 crate 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§

BasicMetadata
Basic metadata container implementing PlaybackMetadata.
SndhFile
SNDH file representation
SndhFlags
SNDH feature flags (from FLAG tag, SNDH v2.2)
SndhMetadata
SNDH file metadata
SndhPlayer
SNDH file player.
SubsongInfo
Information about a specific subsong

Enums§

DmaSampleRate
DMA sample rates for STE and Falcon
PlaybackState
Playback state for chiptune players.
SndhError
Errors that can occur during SNDH parsing and playback.

Traits§

ChiptunePlayer
Unified player interface for chiptune formats.
PlaybackMetadata
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.