]> git.nihav.org Git - nihav.git/blame - src/dsp/window.rs
dsp: make IDCT (un)scaled
[nihav.git] / src / dsp / window.rs
CommitLineData
e35062e7
KS
1use std::f32::consts;
2
3#[derive(Debug,Clone,Copy,PartialEq)]
4pub enum WindowType {
5 Square,
6 Sine,
7 KaiserBessel,
8}
9
10pub 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 => {
27unimplemented!();
28 },
29 };
30}