Skip to main content

Denoiser

Struct Denoiser 

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

ストリーミングのノイズ抑制器。ステレオはチャンネル独立に 2 インスタンスの RNNoise 状態で処理する (チャンネル間のクロストークなし)。

遅延と持ち越しの詳細は crate レベルのドキュメント を参照。

Implementations§

Source§

impl Denoiser

Source

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

チャンネル数 (1 = mono, 2 = stereo interleaved) を指定して構築する。

Source

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

任意長の interleaved (±1.0 正規化・48kHz) サンプルをインプレースで ノイズ抑制する。長さはチャンネル数の倍数であること (空スライスは no-op)。

内部で FRAME_SIZE サンプル/ch のフレームに切って処理し、端数は次回へ 持ち越す。出力は入力を FRAME_SIZE サンプル/ch 遅らせた列で、ストリーム 先頭の遅延分は無音 (0.0)。呼び出しの切り方を変えても出力列は変わらない。 出力サンプルは ±1.0 にクランプされる。

Source

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

持ち越し中の端数をゼロ詰めで 1 フレームに整えて処理し、遅延分の末尾 FRAME_SIZE サンプル/ch を interleaved で返してストリームを閉じる。

これで総出力 = 総入力 + FRAME_SIZE サンプル/ch (先頭の無音詰め物) になる。 呼び出し後は Denoiser::reset と同じ初期状態に戻るので、続けて新しい ストリームを処理できる。

Source

pub fn reset(&mut self)

RNN 状態・持ち越しバッファ・遅延線をすべて初期化する。

reset 後は生成直後と同じ状態で、同一入力からは同一出力が得られる。

Source

pub fn channels(&self) -> u16

構築時に指定したチャンネル数。

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 = 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.