灵符lingfu

ling-mic

↓ 0 downloads

Microphone input and real-time audio capture for Ling

lingfu install ling-mic
LicenseApache-2.0 OR MIT
AuthorsLing Lin, Sanny Lin
READMECode / FilesVersionsDependency GraphDependentsSecurityBuildsSettings

Code / Files (8)

src/web.rs
//! WASM microphone stub — Web Audio API capture is handled in JS.

use crate::{MicConfig, MicError};

pub struct WebMic;

impl WebMic {
    pub fn open(_config: MicConfig) -> Result<Self, MicError> {
        Err(MicError::Unsupported(
            "microphone capture on WASM requires JS interop".into(),
        ))
    }

    pub fn start<F>(&self, _cb: F) -> Result<(), MicError>
    where
        F: Fn(&[f32], usize) + Send + Sync + 'static,
    {
        Ok(())
    }

    pub fn stop(&self) {}

    pub fn peak(&self) -> f32 {
        0.0
    }

    pub fn rms(&self) -> f32 {
        0.0
    }

    pub fn latest_samples(&self) -> Vec<f32> {
        Vec::new()
    }

    pub fn sample_rate(&self) -> u32 {
        44_100
    }

    pub fn channels(&self) -> u16 {
        1
    }

    pub fn device_name(&self) -> String {
        String::new()
    }
}

← Back to index