Skip to main content

Denoiser

Struct Denoiser 

Source
pub struct Denoiser { /* private fields */ }
Expand description

Streaming noise suppressor. Stereo uses two independent RNNoise states, one per channel (no crosstalk between channels).

See the crate-level documentation for details on latency and carry-over.

Implementations§

Source§

impl Denoiser

Source

pub fn new(channels: u16) -> Result<Denoiser, DenoiseError>

Create with a channel count (1 = mono, 2 = interleaved stereo).

Source

pub fn process(&mut self, interleaved: &mut [f32]) -> Result<(), DenoiseError>

Apply noise suppression in place to any-length interleaved samples (normalized ±1.0, 48 kHz). Length must be a multiple of the channel count (an empty slice is a no-op).

Internally splits input into frames of FRAME_SIZE samples per channel and carries any remainder to the next call. Output is delayed by FRAME_SIZE samples per channel, with silence (0.0) at the start of the stream. Chunk boundaries do not change the output sequence. Output samples are clamped to ±1.0.

Source

pub fn flush(&mut self) -> Vec<f32>

Zero-pad the carried remainder to one frame and process it, then return the final delayed FRAME_SIZE samples per channel as interleaved output and close the stream.

Total output is now total input + FRAME_SIZE samples per channel (initial silence padding). After this call, the denoiser returns to the same initial state as Denoiser::reset and can process a new stream.

Source

pub fn reset(&mut self)

Reset the RNN state, carry-over buffers, and delay line.

After reset, the state matches a newly created denoiser, so the same input produces the same output.

Source

pub fn channels(&self) -> u16

Channel count specified at construction.

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.