Struct FileOutputBlock

Source
pub struct FileOutputBlock<S: Sample> { /* private fields */ }
Expand description

Writes audio from the DSP graph to a file.

This block uses a separate I/O thread to perform disk writes, avoiding blocking the audio thread. Samples are passed through a lock-free ring buffer.

Implementations§

Source§

impl<S: Sample + Send + 'static> FileOutputBlock<S>

Source

pub fn new(writer: Box<dyn Writer<S>>) -> Self

Create a FileOutputBlock with the Writer implementation for a particular type of audio file.

The writer is moved to a background I/O thread. Samples are passed through a lock-free ring buffer to avoid blocking the audio thread.

Source

pub fn start_recording(&mut self)

Tell the writer to begin storing audio sample data.

Source

pub fn stop_recording(&mut self) -> Result<(), Box<dyn Error>>

Tell the writer to stop storing audio sample data.

This signals the I/O thread to flush remaining samples and finalize the file. The method blocks until the I/O thread completes.

Source

pub fn is_recording(&self) -> bool

Check whether the writer is actively storing audio sample data.

Source

pub fn error_occurred(&self) -> bool

Check whether any write errors have occurred.

This can be queried periodically to detect I/O failures without blocking the audio thread.

Trait Implementations§

Source§

impl<S: Sample + Send + 'static> Block<S> for FileOutputBlock<S>

Source§

fn process( &mut self, inputs: &[&[S]], _outputs: &mut [&mut [S]], _modulation_values: &[S], _context: &DspContext, )

Process audio through this block. Read more
Source§

fn input_count(&self) -> usize

Returns the number of input ports this block accepts.
Source§

fn output_count(&self) -> usize

Returns the number of output ports this block produces.
Source§

fn modulation_outputs(&self) -> &[ModulationOutput]

Returns the modulation outputs this block provides. Read more
Source§

fn channel_config(&self) -> ChannelConfig

Returns how this block handles multi-channel audio. Read more
Source§

fn set_smoothing(&mut self, _sample_rate: f64, _ramp_time_ms: f64)

Configure smoothing time for parameter changes. Read more
Source§

impl<S: Sample + Send + 'static> Drop for FileOutputBlock<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<S: Sample> From<FileOutputBlock<S>> for BlockType<S>

Source§

fn from(block: FileOutputBlock<S>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S> Freeze for FileOutputBlock<S>

§

impl<S> !RefUnwindSafe for FileOutputBlock<S>

§

impl<S> Send for FileOutputBlock<S>

§

impl<S> Sync for FileOutputBlock<S>

§

impl<S> Unpin for FileOutputBlock<S>

§

impl<S> !UnwindSafe for FileOutputBlock<S>

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.