pub trait ChiptunePlayer: ChiptunePlayerBase {
type Metadata: PlaybackMetadata;
// Required method
fn metadata(&self) -> &Self::Metadata;
}Expand description
Unified player interface for chiptune formats.
This trait extends ChiptunePlayerBase with metadata access.
It provides a common API for playing YM, AKS, AY and other
chiptune formats.
§Metadata
Each player provides metadata through PlaybackMetadata. The trait
uses an associated type to allow format-specific metadata structs while
still providing a common interface.
§Object Safety
This trait is not object-safe due to the associated Metadata type.
Use ChiptunePlayerBase when you need trait objects.
§Example
ⓘ
use ym2149_common::{ChiptunePlayer, PlaybackState};
fn play_song(player: &mut impl ChiptunePlayer) {
println!("Playing: {}", player.metadata().title());
player.play();
let mut buffer = vec![0.0; 1024];
while player.state() == PlaybackState::Playing {
player.generate_samples_into(&mut buffer);
// ... send buffer to audio device
}
}Required Associated Types§
Sourcetype Metadata: PlaybackMetadata
type Metadata: PlaybackMetadata
The metadata type for this player.