pub struct SpectrumAnalyzer { /* private fields */ }Expand description
Register-based spectrum analyzer.
Maps YM2149 channel frequencies to note-aligned spectrum bins, showing the actual notes being played rather than FFT analysis.
Supports up to 4 PSGs (12 channels total) for multi-PSG configurations.
Implementations§
Source§impl SpectrumAnalyzer
impl SpectrumAnalyzer
Sourcepub fn set_psg_count(&mut self, count: usize)
pub fn set_psg_count(&mut self, count: usize)
Set the number of active PSGs (1-4).
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Get the number of active channels.
Sourcepub fn update(&mut self, channel_states: &ChannelStates)
pub fn update(&mut self, channel_states: &ChannelStates)
Update spectrum from YM2149 channel states (single PSG, for backward compatibility).
Call this once per frame. Applies decay to previous values and updates bins based on current frequencies. Updates channels 0-2.
Sourcepub fn update_psg(&mut self, psg_index: usize, channel_states: &ChannelStates)
pub fn update_psg(&mut self, psg_index: usize, channel_states: &ChannelStates)
Update spectrum for a specific PSG (0-3).
Call this for each active PSG to update its 3 channels.
Sourcepub fn update_multi_psg(
&mut self,
register_banks: &[[u8; 16]],
psg_count: usize,
)
pub fn update_multi_psg( &mut self, register_banks: &[[u8; 16]], psg_count: usize, )
Update spectrum from multiple PSG register banks.
Call this once per frame with all PSG register states.
Sourcepub fn channel_spectrum(&self, channel: usize) -> &[f32; 32]
pub fn channel_spectrum(&self, channel: usize) -> &[f32; 32]
Get spectrum for a specific channel (0-11 for multi-PSG).
Sourcepub fn all_channel_spectrums(&self) -> &[[f32; 32]; 12]
pub fn all_channel_spectrums(&self) -> &[[f32; 32]; 12]
Get all per-channel spectrums (all 12 channels).
Sourcepub fn high_freq_ratio(&self, channel: usize) -> f32
pub fn high_freq_ratio(&self, channel: usize) -> f32
Compute high frequency ratio (bins 8-15 vs total).
Useful for badges indicating “bright” or “treble” content.
Trait Implementations§
Source§impl Clone for SpectrumAnalyzer
impl Clone for SpectrumAnalyzer
Source§fn clone(&self) -> SpectrumAnalyzer
fn clone(&self) -> SpectrumAnalyzer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more