-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSincTable.cpp
More file actions
69 lines (55 loc) · 1.7 KB
/
SincTable.cpp
File metadata and controls
69 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
VocoderSynth is a DSP plugin.
Copyright 2024 Tim Krause
This file is part of VocoderSynth
VocoderSynth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
VocoderSynth is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with VocoderSynth. If not, see
<https://www.gnu.org/licenses/>.
Contact: tim.krause@twkrause.ca
*/
#include "SincTable.h"
#include <cmath>
SincTable sincTable;
SS_SincTable SS_sincTable;
static float sinc(float x)
{
if(fabs(x)<1e-9f){
return 1.0f;
}else{
return sinf(x)/x;
}
}
static float hamming(int n, int N)
{
float a0 = 25.0f/46.0f;
float a1 = 1.0f - a0;
return a0 - a1*cosf(2.0f*M_PIf*n/(N-1));
}
SincTable::SincTable(void)
{
for(int i_ss=0;i_ss<N_SINC_SS;i_ss++){
float alpha = (float)i_ss/N_SINC_SS;
for(int i_w=0;i_w<N_SINC_WINDOW;i_w++){
float x = (float)(i_w-(N_SINC_WINDOW/2-1)) - alpha;
data[i_ss][i_w] = sinc(M_PI*x)*hamming(i_w, N_SINC_WINDOW);
}
}
}
SS_SincTable::SS_SincTable(void)
{
for(int i_ss=0;i_ss<N_SINC_SS_SS;i_ss++){
float alpha = (float)i_ss/N_SINC_SS_SS;
for(int i_w=0;i_w<N_SINC_WINDOW;i_w++){
float x = (float)(i_w-(N_SINC_WINDOW/2-1)) - alpha;
data[i_ss][i_w] = sinc(M_PI*x)*hamming(i_w, N_SINC_WINDOW);
}
}
}