]>
Commit | Line | Data |
---|---|---|
1 | use std::f32::consts; | |
2 | ||
3 | #[derive(Debug,Clone,Copy,PartialEq)] | |
4 | pub enum WindowType { | |
5 | Square, | |
6 | Sine, | |
7 | KaiserBessel, | |
8 | } | |
9 | ||
10 | pub fn generate_window(mode: WindowType, scale: f32, size: usize, half: bool, dst: &mut [f32]) { | |
11 | match mode { | |
12 | WindowType::Square => { | |
13 | for n in 0..size { dst[n] = scale; } | |
14 | }, | |
15 | WindowType::Sine => { | |
16 | let param; | |
17 | if half { | |
18 | param = consts::PI / ((2 * size) as f32); | |
19 | } else { | |
20 | param = consts::PI / (size as f32); | |
21 | } | |
22 | for n in 0..size { | |
23 | dst[n] = (((n as f32) + 0.5) * param).sin() * scale; | |
24 | } | |
25 | }, | |
26 | WindowType::KaiserBessel => { | |
27 | unimplemented!(); | |
28 | }, | |
29 | }; | |
30 | } |