Struct AudioSample

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

An AudioSample (with surround sound 5.1 support).

Implementations§

Source§

impl AudioSample

Source

pub fn stereo(left: i16, right: i16) -> AudioSample

Create stereo audio sample.

Examples found in repository?
examples/monitoring.rs (line 21)
7fn main() {
8    let mut app = App::new(());
9
10    let mut buffer = VecDeque::new();
11 
12    loop {
13        // Record some sound.
14        app.record(&mut |_whichmic, l, r| {
15            buffer.push_back((l, r));
16        });
17
18        // Play that sound.
19        app.play(&mut || {
20            if let Some((lsample, rsample)) = buffer.pop_front() {
21                AudioSample::stereo(lsample, rsample)
22            } else {
23                // Play silence if not enough has been recorded yet.
24                AudioSample::stereo(0, 0)
25            }
26        });
27    }
28}
Source

pub fn surround( front_left: i16, front_right: i16, front_center: i16, lfe: i16, surround_left: i16, surround_right: i16, ) -> AudioSample

Create surround sound 5.1 audio sample.

  • Center: 0°.
  • Front-Left: -30°
  • Front-Right: 30°
  • Surround-Left: -110°
  • Surround-Right: 110°

source: https://en.wikipedia.org/wiki/5.1_surround_sound#Music

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.