diff options
| author | wukong <wukong@longaeva> | 2026-04-10 23:46:12 -0700 |
|---|---|---|
| committer | wukong <wukong@longaeva> | 2026-04-10 23:46:12 -0700 |
| commit | 4c4eb1bd8f003b3b57707badd2dd089ed193a896 (patch) | |
| tree | 15b62907fffd70c46a9b4369df93ab33c6aa88ac /fir_window_vonhann.awk | |
| parent | e7d1781578e846a7b1d634cd43c8fab00a67b883 (diff) | |
renamed fir window generators;
minor edits to whitespace and comments for more consistent style;
Diffstat (limited to 'fir_window_vonhann.awk')
| -rw-r--r-- | fir_window_vonhann.awk | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/fir_window_vonhann.awk b/fir_window_vonhann.awk new file mode 100644 index 0000000..3c831c7 --- /dev/null +++ b/fir_window_vonhann.awk @@ -0,0 +1,35 @@ +#!/usr/bin/awk -f
+
+### fir_window_vonhann.awk
+# https://en.wikipedia.org/wiki/Window_function provides a few values for the
+# 'a0' and 'a1' parameters of the raised cosine.
+
+
+# vonHann (raised cosine)
+function vonhann(n) {
+ a0 = 0.5
+ a1 = 0.5
+ 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*atan2(1,1)
+
+ 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
+ }
+ }
+}
+
|
