Skip to main content

PcmQueue

Struct PcmQueue 

Source
pub struct PcmQueue {
    samples: VecDeque<i16>,
    pub channels: u32,
    pub sample_rate: u32,
}
Expand description

復号済み PCM の待ち行列(ステレオ交互、i16)。

Fields§

§samples: VecDeque<i16>§channels: u32

入力のチャンネル数(1 ならモノラル。出力時に左右へ複製する)。

§sample_rate: u32

標本化周波数 [Hz]。

Implementations§

Source§

impl PcmQueue

Source

pub fn new(sample_rate: u32, channels: u32) -> Self

Source

pub fn push(&mut self, pcm: &[i16])

交互配置の PCM(channels 本)を末尾へ足す。

Source

pub fn buffered_ms(&self) -> u64

溜まっている時間 [ms]。

Source

pub fn clear(&mut self)

Source

pub fn frames(&self) -> usize

溜まっているフレーム数。

Source

pub fn fill_words(&mut self, out: &mut [u32], range: u32) -> usize

out(左右交互の PWM 語。長さは偶数)を待ち行列から埋める。足りない分は無音。 埋めた(実データの)フレーム数を返す。

Source

pub fn drain_frames(&mut self, frames: usize)

frames フレーム分を捨てる(実機の DMA が無い環境で、実時間の消費を真似る)。

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> Same for T

Source§

type Output = T

Should always be Self
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.