From 4c4eb1bd8f003b3b57707badd2dd089ed193a896 Mon Sep 17 00:00:00 2001 From: wukong Date: Fri, 10 Apr 2026 23:46:12 -0700 Subject: renamed fir window generators; minor edits to whitespace and comments for more consistent style; --- fir_window_vonhann.awk | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 fir_window_vonhann.awk (limited to 'fir_window_vonhann.awk') 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 + } + } +} + -- cgit v1.2.3