1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Common traits and types for YM2149 chiptune replayers.
//!
//! This crate provides shared abstractions used across multiple replayer
//! implementations (YM, AKS, AY formats).
//!
//! # Traits
//!
//! - [`ChiptunePlayer`] - Unified player interface for any chiptune format
//! - [`PlaybackMetadata`] - Metadata access (title, author, duration, etc.)
//!
//! # Example
//!
//! ```ignore
//! use ym2149_common::{ChiptunePlayer, PlaybackMetadata, PlaybackState};
//!
//! fn play_any_format<P: ChiptunePlayer>(player: &mut P) {
//! println!("Playing: {}", player.metadata().title());
//! player.play();
//!
//! let mut buffer = vec![0.0; 4096];
//! while player.state() == PlaybackState::Playing {
//! player.generate_samples_into(&mut buffer);
//! // ... send buffer to audio device
//! }
//! }
//! ```
pub use Ym2149Backend;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// ============================================================================
// Common Constants
// ============================================================================
/// Standard audio sample rate (44.1 kHz CD quality).
pub const DEFAULT_SAMPLE_RATE: u32 = 44_100;
/// PAL frame rate (50 Hz) - used by Atari ST, Amiga, and most European systems.
pub const FRAME_RATE_PAL: u32 = 50;
/// NTSC frame rate (60 Hz) - used by some American systems.
pub const FRAME_RATE_NTSC: u32 = 60;
/// Standard YM2149 PSG master clock frequency (2 MHz).
///
/// This is the clock rate used on Atari ST, Amstrad CPC, ZX Spectrum 128, etc.
pub const PSG_MASTER_CLOCK_HZ: u32 = 2_000_000;
/// Alias for backwards compatibility.
pub const ATARI_ST_CLOCK: u32 = PSG_MASTER_CLOCK_HZ;
/// Atari ST MFP (MC68901) clock frequency (2.4576 MHz).
///
/// Used for timer-based effects like SID voice emulation and sample playback.
pub const ATARI_MFP_CLOCK_HZ: u32 = 2_457_600;
/// Number of audio channels per YM2149 PSG chip.
pub const CHANNELS_PER_PSG: usize = 3;
/// Master gain applied to all audio output.
///
/// This amplifies the output from all backends (core emulation, softsynth, SNDH).
/// The YM2149 output tends to be quiet compared to modern audio, so this provides
/// a global boost to bring levels up to a comfortable listening volume.
pub const MASTER_GAIN: f32 = 2.0;