Generate a Hann window of the given size.
(size: usize)
| 93 | |
| 94 | /// Generate a Hann window of the given size. |
| 95 | fn hann_window(size: usize) -> Vec<f32> { |
| 96 | (0..size) |
| 97 | .map(|i| { |
| 98 | let phase = 2.0 * std::f32::consts::PI * i as f32 / size as f32; |
| 99 | 0.5 * (1.0 - phase.cos()) |
| 100 | }) |
| 101 | .collect() |
| 102 | } |
| 103 | |
| 104 | /// Build mel filterbank matrix [n_mels, n_freq]. |
| 105 | fn mel_filterbank(n_mels: usize, n_freq: usize, sample_rate: usize, n_fft: usize) -> Vec<f32> { |
no outgoing calls