Struct xsynth_core::buffered_renderer::BufferedRenderer

source ·
pub struct BufferedRenderer { /* private fields */ }
Expand description

The helper struct for deferred sample rendering. Helps avoid stutter when the render time is exceding the max time allowed by the audio driver.

Instead, it renders in a separate thread with much smaller sample sizes, causing a minimal impact on latency while allowing more time to render per sample.

Designed to be used in realtime playback only.

Implementations§

source§

impl BufferedRenderer

source

pub fn new<F: 'static + AudioPipe + Send>( render: F, stream_params: AudioStreamParams, render_size: usize, ) -> Self

Creates a new instance of BufferedRenderer.

  • render: An object implementing the AudioPipe struct for BufferedRenderer to read samples from
  • stream_params: Parameters of the output audio
  • render_size: The number of samples to render each iteration
source

pub fn read(&mut self, dest: &mut [f32])

Reads samples from the remainder and the output queue into the destination array.

source

pub fn set_render_size(&self, size: usize)

Sets the number of samples that should be rendered each iteration.

source

pub fn get_buffer_stats(&self) -> BufferedRendererStatsReader

Returns a statistics reader. See the BufferedRendererStatsReader documentation for more information.

Trait Implementations§

source§

impl AudioPipe for BufferedRenderer

source§

fn stream_params(&self) -> &AudioStreamParams

The audio stream parameters of the audio pipe.
source§

fn read_samples_unchecked(&mut self, to: &mut [f32])

Reads samples from the pipe without checking the channel count of the output.
source§

fn read_samples(&mut self, to: &mut [f32])

Reads samples from the pipe. Read more
source§

impl Drop for BufferedRenderer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

source§

fn into_sample(self) -> T

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.