Struct sphinxad::AudioDevice [] [src]

pub struct AudioDevice { /* fields omitted */ }

Audio device like microphone It will automatically stop recording and will be destroyed

Methods

impl AudioDevice
[src]

Open default audio device(microphone) with SPS(samples per second) = 16000

Open default audio device(microphone) with given SPS

Example

use std::thread;

let mut device=AudioDevice::default_with_sps(44100)?;
device.start_recording()?;

loop{ //recording loop
    match device.read(&mut buffer[..])? {
        Some( buffer ) => {
            for i in 0..buffer.len() {
                ...
            }
        },
        None => break,
    }

    thread::sleep_ms(100);
}

Open specified audio device with given SPS

Start recording

Stop recording

Example

let mut device=AudioDevice::default_with_sps(44100)?;
device.start_recording()?;

loop{ //recording loop
    ...
}

device.stop_recording()?;

thread::sleep_ms(1000);

device.start_recording()?;

Read sound to buffer, and return slide of read samples(length of slice may be not equal to buffer length). Return None if nothing to read

Trait Implementations

impl Drop for AudioDevice
[src]

A method called when the value goes out of scope. Read more