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§

Clears buffered data and resets frame start to default.

Shrinks the excessive capacity of the buffer as much as possible.

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).

Examples found in repository?
src/synth.rs (line 339)
331
332
333
334
335
336
337
338
339
340
    fn ensure_frame_time(&mut self, sample_rate: u32, ts_rate: f64, frame_ts: FTs, margin_ts: FTs) {
        let time_rate = sample_rate as f64 / ts_rate;
        assert!(time_rate > 0.0);
        let frame_time = time_rate * frame_ts as f64;
        assert!(frame_time > 0.0);
        let margin_time = time_rate * 2.0 * margin_ts as f64;
        assert!(margin_time >= 0.0);
        self.time_rate = time_rate;
        self.set_frame_time(frame_time, margin_time);
    }

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.

Finalizes audio frame.

Returns the number of audio samples, single channel-wise, which are ready to be produced from the frame.

time_end is specified in the sample time units (1.0 = 1 audio sample).

Examples found in repository?
src/synth.rs (line 345)
343
344
345
346
    fn end_frame(&mut self, timestamp: FTs) -> usize {
        debug_assert!(timestamp > 0);
        self.end_frame(self.time_rate * timestamp as f64)
    }

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.

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.

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§

A type for sample ∆ amplitudes (pulse height).
This method allows the Blep implementation to reserve enough memory for the audio frame with an additional margin and to set up a sample time rate and other internals. Read more
Finalizes audio frame. Read more
This method is being used to add square-wave pulse steps within a boundary of a single frame. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert to S a sample type from self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.