#音调 #频率 #检测 #音频

无需 std dywapitchtrack

Antoine Schmitt 编写的 dywapitchtrack 的 Rust 实现

1 个不稳定版本

0.1.0 2023年5月24日

168多媒体 中排名

MIT 许可证

330KB
396

dywapitchtrack

用法

use dywapitchtrack::DywaPitchTracker;

fn main() {
    const SAMPLE_RATE: usize = 44100;
    const SIZE: usize = 1024;

    let dt = 1.0 / SAMPLE_RATE as f32;
    let freq = 300.0;

    // Sound samples
    let samples: Vec<f32> = (0..SIZE)
        .map(|x| (2.0 * std::f32::consts::PI * x as f32 * dt * freq).sin())
        .collect();

    let mut pitch_tracker = DywaPitchTracker::new();
    let pitch = pitch_tracker.compute_pitch(&samples, 0, SIZE)

    println!("Frequency: {}", pitch);
}

无运行时依赖