pub struct StreamReaderState { /* private fields */ }Implementations§
Source§impl StreamReaderState
impl StreamReaderState
pub fn new(channels: NonZeroChannelCount) -> Self
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true if there is there is currently an active stream on this node.
Sourcepub fn underflow_occurred(&self) -> bool
pub fn underflow_occurred(&self) -> bool
Returns true if an underflow occured (due to the output stream
running faster than the input stream).
If this happens excessively in Release mode, you may want to consider
increasing ResamplingChannelConfig::latency_seconds.
(Calling this will also reset the flag indicating whether an underflow occurred.)out
Sourcepub fn overflow_occurred(&self) -> bool
pub fn overflow_occurred(&self) -> bool
Returns true if an overflow occured (due to the input stream
running faster than the output stream).
If this happens excessively in Release mode, you may want to consider
increasing ResamplingChannelConfig::capacity_seconds. For
example, if you are streaming data from a network, you may want to
increase the capacity to several seconds.
(Calling this will also reset the flag indicating whether an overflow occurred.)
Sourcepub fn start_stream(
&mut self,
sample_rate: NonZeroU32,
output_stream_sample_rate: NonZeroU32,
channel_config: ResamplingChannelConfig,
) -> Result<NewOutputStreamEvent, ()>
pub fn start_stream( &mut self, sample_rate: NonZeroU32, output_stream_sample_rate: NonZeroU32, channel_config: ResamplingChannelConfig, ) -> Result<NewOutputStreamEvent, ()>
Begin the output audio stream on this node.
The returned event must be sent to the node’s processor for this to take effect.
sample_rate- The sample rate of this node.output_stream_sample_rate- The sample rate of the active output audio stream.channel_config- The configuration of the input to output channel.
If there is already an active stream running on this node, then this will return an error.
Sourcepub fn available_frames(&self) -> usize
pub fn available_frames(&self) -> usize
The total number of frames (not samples) that can currently be read from the stream.
If there is no active stream, the stream is paused, or the processor end
is not ready to receive samples, then this will return 0.
Sourcepub fn occupied_seconds(&self) -> Option<f64>
pub fn occupied_seconds(&self) -> Option<f64>
The amount of data in seconds that is currently occupied in the channel.
This value will be in the range [0.0, ResamplingChannelConfig::capacity_seconds].
This can also be used to detect when an extra packet of data should be read or discarded to correct for jitter.
If there is no active stream, then this will return None.
Sourcepub fn num_channels(&self) -> NonZeroChannelCount
pub fn num_channels(&self) -> NonZeroChannelCount
The number of channels in this node.
Sourcepub fn sample_rate(&self) -> Option<NonZeroU32>
pub fn sample_rate(&self) -> Option<NonZeroU32>
The sample rate of the active stream.
Returns None if there is no active stream.
Sourcepub fn read_interleaved(&mut self, output: &mut [f32]) -> Option<ReadStatus>
pub fn read_interleaved(&mut self, output: &mut [f32]) -> Option<ReadStatus>
Read from the channel and write the results into the given output buffer in interleaved format.
If there is no active stream, the stream is paused, or the processor end
is not ready to send samples, then the output will be filled with zeros
and None will be returned.
Sourcepub fn read<Vin: AsMut<[f32]>>(
&mut self,
output: &mut [Vin],
range: Range<usize>,
) -> Option<ReadStatus>
pub fn read<Vin: AsMut<[f32]>>( &mut self, output: &mut [Vin], range: Range<usize>, ) -> Option<ReadStatus>
Read from the channel and write the results into the given output buffer in de-interleaved format.
output- The channels to write data to.range- The range in each slice inoutputto write to.
If there is no active stream, the stream is paused, or the processor end
is not ready to send samples, then the output will be filled with zeros
and None will be returned.
Sourcepub fn discard_frames(&mut self) -> usize
pub fn discard_frames(&mut self) -> usize
Discard a certian number of output frames from the buffer. This can be used to correct for jitter and avoid excessive overflows and reduce the percieved audible glitchiness.
This will discard frames.min(self.available_frames()) frames.
Returns the number of output frames that were discarded.
Sourcepub fn autocorrect_overflows(&mut self) -> Option<usize>
pub fn autocorrect_overflows(&mut self) -> Option<usize>
Correct for any overflows.
This returns the number of frames (samples in a single channel of audio) that were
discarded due to an overflow occurring. If no overflow occured, then None
is returned.
Note, this method is already automatically called in StreamReaderState::read and
StreamReaderState::read_interleaved.
This will have no effect if ResamplingChannelConfig::overflow_autocorrect_percent_threshold
was set to None.
This method is realtime-safe.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Returns true if the processor end of the stream is ready to start sending
data.
Sourcepub fn pause_stream(&mut self)
pub fn pause_stream(&mut self)
Pause any active audio streams.
pub fn stop_stream(&mut self)
pub fn handle(&self) -> Mutex<Self>
Trait Implementations§
Source§impl Clone for StreamReaderState
impl Clone for StreamReaderState
Source§fn clone(&self) -> StreamReaderState
fn clone(&self) -> StreamReaderState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StreamReaderState
impl RefUnwindSafe for StreamReaderState
impl Send for StreamReaderState
impl Sync for StreamReaderState
impl Unpin for StreamReaderState
impl UnwindSafe for StreamReaderState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.