Struct blip_buf::BlipBuf
[−]
[src]
pub struct BlipBuf { /* fields omitted */ }
Sample buffer that resamples from input clock rate to output sample rate
Methods
impl BlipBuf
[src]
fn new(sample_count: u32) -> BlipBuf
Creates new buffer that can hold at most sample_count samples. Sets rates
so that there are MAX_RATIO
clocks per sample. Returns pointer to new
buffer, or panics if insufficient memory.
fn set_rates(&mut self, clock_rate: f64, sample_rate: f64)
Sets approximate input clock rate and output sample rate. For every
clock_rate
input clocks, approximately sample_rate
samples are generated.
fn clear(&mut self)
Clears entire buffer. Afterwards, samples_avail() == 0
.
fn add_delta(&mut self, clock_time: u32, delta: i32)
Adds positive/negative delta into buffer at specified clock time.
fn add_delta_fast(&mut self, clock_time: u32, delta: i32)
Same as add_delta()
, but uses faster, lower-quality synthesis.
fn clocks_needed(&self, sample_count: u32) -> u32
Length of time frame, in clocks, needed to make sample_count
additional
samples available.
fn end_frame(&mut self, clock_duration: u32)
Makes input clocks before clock_duration
available for reading as output
samples. Also begins new time frame at clock_duration
, so that clock time 0 in
the new time frame specifies the same clock as clock_duration
in the old time
frame specified. Deltas can have been added slightly past clock_duration
(up to
however many clocks there are in two output samples).
fn samples_avail(&self) -> u32
Number of buffered samples available for reading.
fn read_samples(&mut self, buf: &mut [i16], stereo: bool) -> usize
Reads and removes at most buf.len()
samples and writes them to buf
. If
stereo
is true, writes output to every other element of buf
, allowing easy
interleaving of two buffers into a stereo sample stream. Outputs 16-bit signed
samples. Returns number of samples actually read.