blob: fd6d89c66d57add6dbdc0f43a7d508f5905c6dd4 (
plain) (
blame)
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
|
#!/usr/bin/awk -f
### hamming.awk
# generate a Hamming window
# https://en.wikipedia.org/wiki/Window_function provides a few values for the
# 'a0' and 'a1' parameters of the raised cosine.
BEGIN {
### R.W. Hamming, "Digital Filters"
# H = "0.23 0.54 0.23"
N = ARGV[1]
# window interval goes from -M to M
M = 0.5*(N - 1)
pi = 4*atan2(1,1)
a0 = (25.0/46.0)
a1 = (21.0/46.0)
### optimal values for equal-ripple
#a0 = 0.53836
#a1 = 0.46164
### VonHann
#a0 = 0.5
#a1 = 0.5
for (n=-M; n<=M; n++) {
if (N > 1 && M > 0) {
w[n] = a0 + a1*cos((pi*n)/M)
print n, w[n]/M
}
else {
print n, 1.0
}
}
}
|