blob: 95bd8279b040bbc911228b7905dbdeaf8cf0adb6 (
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
40
41
42
43
44
|
#!/usr/bin/awk -f
### fir_window_hamming.awk
# generate a Hamming raised cosine FIR window
# R.W. Hamming, 'Digital Filters': H = '0.23 0.54 0.23'
# https://en.wikipedia.org/wiki/Window_function provides a few values for the
# 'a0' and 'a1' parameters of the raised cosine.
# note: the forms provided from wikipedia do not give expected results and
# appear to show inconsistency between raised cosine variations. need to
# cross-check these forms against DSP/signaling texts.
# Hamming window (raised cosine)
function hamming(n) {
# optimal values for equal-ripple
#a0 = 0.53836
#a1 = 0.46164
a0 = (25.0/46.0)
a1 = (21.0/46.0)
return a0 + a1*cos((pi*n)/M)
}
BEGIN {
ARGV[1] ? N = ARGV[1] : N = 0
ARGV[2] ? OFMT = "%." ARGV[2] "g" : OFMT = "%g"
# window interval goes from -M to M
M = 0.5*(N - 1)
pi = 4.0*atan2(1.0, 1.0)
for (n=-M; n<=M; n++) {
if (N > 1 && M > 0) {
w[n] = hamming(n)
print n + M, w[n]/M
}
else {
print n + M, 1.0
}
}
}
|