Struct spectrusty_audio::synth::BandLimited
source · pub struct BandLimited<T, O = BandLimWide> { /* private fields */ }
Expand description
Bandwidth-Limited Pulse Buffer implementation with high-pass and low-pass filtering, for an efficient band-limited synthesis.
T
specifies pulse step amplitude unit types. Currently, implementations are provided for:
f32
, i16
, and i32
.
Implementations§
source§impl<T: Copy + Default, O> BandLimited<T, O>
impl<T: Copy + Default, O> BandLimited<T, O>
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the excessive capacity of the buffer as much as possible.
sourcepub fn set_frame_time(&mut self, frame_time: f64, margin_time: f64)
pub fn set_frame_time(&mut self, frame_time: f64, margin_time: f64)
Ensures the frame buffer length is large enough to fit data for the specified frame_time
with additional margin_time
.
Sets the duration of the average frame to frame_time
which should be specified with as much
precision as possible.
margin_time
specifies a frame duration fluctuation margin and should be significantly smaller
than frame_time
.
Both frame_time
and margin_time
are specified in the sample time units (1.0 = 1 audio sample).
sourcepub fn is_frame_ended(&mut self) -> bool
pub fn is_frame_ended(&mut self) -> bool
Returns true
if BandLimited::end_frame has been called before the call to BandLimited::next_frame.
It indicates if audio samples can be digitized from the last frame data.
source§impl<T, O> BandLimited<T, O>where
T: Copy + Default + AddAssign + MulNorm + FromSample<f32>,
O: BandLimOpt,
impl<T, O> BandLimited<T, O>where
T: Copy + Default + AddAssign + MulNorm + FromSample<f32>,
O: BandLimOpt,
sourcepub fn new(channels: usize) -> Self
pub fn new(channels: usize) -> Self
Returns a new instance of BandLimited
buffer.
channels
- specifies the maximum number of audio channels that the sound can be rendered for.
Before any pulse steps are added to the buffer the method BandLimited::set_frame_time or Blep::ensure_frame_time must be called first.
Panics
Panics if channels
equals to 0
.
sourcepub fn next_frame(&mut self)
pub fn next_frame(&mut self)
Prepares the buffer for the next audio frame.
This method must be called after the call to BandLimited::end_frame or to Blep::end_frame and optionally after audio data has been produced with BandLimited::sum_iter.
source§impl<T, O> BandLimited<T, O>where
T: Copy + MulNorm + FromSample<f32>,
O: BandLimOpt,
impl<T, O> BandLimited<T, O>where
T: Copy + MulNorm + FromSample<f32>,
O: BandLimOpt,
sourcepub fn sum_iter<'a, S: 'a>(
&'a self,
channel: usize
) -> impl Iterator<Item = S> + ExactSizeIterator + 'awhere
T: IntoSample<S>,
pub fn sum_iter<'a, S: 'a>(
&'a self,
channel: usize
) -> impl Iterator<Item = S> + ExactSizeIterator + 'awhere
T: IntoSample<S>,
Returns an iterator that produces audio samples in the specified sample format S
from the specified channel
.
This method must be called after the call to BandLimited::end_frame or Blep::end_frame and before BandLimited::next_frame.
Trait Implementations§
source§impl<T, O> Blep for BandLimited<T, O>where
T: Copy + Default + SampleDelta + MulNorm,
impl<T, O> Blep for BandLimited<T, O>where
T: Copy + Default + SampleDelta + MulNorm,
§type SampleDelta = T
type SampleDelta = T
Auto Trait Implementations§
impl<T, O = BandLimWide> !RefUnwindSafe for BandLimited<T, O>
impl<T, O> Send for BandLimited<T, O>where
O: Send,
T: Send,
impl<T, O = BandLimWide> !Sync for BandLimited<T, O>
impl<T, O> Unpin for BandLimited<T, O>where
O: Unpin,
T: Unpin,
impl<T, O> UnwindSafe for BandLimited<T, O>where
O: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
S
a sample type from self
.