pub struct BlipBuf { /* private fields */ }Expand description
Streaming BLEP decimator + filter chain that feeds host-rate samples to the frontend’s audio thread.
Implementations§
Source§impl BlipBuf
impl BlipBuf
Sourcepub fn new(sample_rate: u32, cpu_rate: f64) -> Self
pub fn new(sample_rate: u32, cpu_rate: f64) -> Self
Create a new band-limited buffer.
sample_rate is the host audio rate in Hz (typically 44 100).
cpu_rate is the NES CPU rate in Hz (CPU_HZ_NTSC or
CPU_HZ_PAL).
Sourcepub fn set_filter_model(&mut self, model: FilterModel)
pub fn set_filter_model(&mut self, model: FilterModel)
v2.1.3 — swap the analog output-filter model (see
crate::mixer::FilterModel), rebuilding the filter chain at the
current sample rate. This resets the filter’s IIR state, so switching
while audio is playing (the Settings selector applies it live) produces a
brief transient — as with any live filter swap. The frontend also applies
it at ROM load / power-cycle, where there is no audible discontinuity.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset to silence. Empties the input ring, the pending output queue, and the filter chain state.
Sourcepub fn add_sample(&mut self, value: f32)
pub fn add_sample(&mut self, value: f32)
Add one mixed sample at CPU resolution. The buffer accumulates
host-rate samples internally; drain via Self::drain or
Self::drain_all.
The mixer’s output is approximately in [-0.5, 0.5] for the 2A03
alone, with on-cart audio expansions pushing the absolute range
up somewhat. We clamp value defensively so a stray NaN/Inf or
runaway mapper can’t propagate non-finite values into the FIR
state. The clamp range is far outside any sane mixer output, so
the gate is purely a saturation backstop, not a normal-operation
limiter.