aboutsummaryrefslogtreecommitdiff
path: root/octave/make_ssbfilt.m
diff options
context:
space:
mode:
authorAuthor Name <[email protected]>2023-07-07 12:20:59 +0930
committerDavid Rowe <[email protected]>2023-07-07 12:29:06 +0930
commitac7c48b4dee99d4c772f133d70d8d1b38262fcd2 (patch)
treea2d0ace57a9c0e2e5b611c4987f6fed1b38b81e7 /octave/make_ssbfilt.m
shallow zip-file copy from codec2 e9d726bf20
Diffstat (limited to 'octave/make_ssbfilt.m')
-rw-r--r--octave/make_ssbfilt.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/octave/make_ssbfilt.m b/octave/make_ssbfilt.m
new file mode 100644
index 0000000..bcd00f1
--- /dev/null
+++ b/octave/make_ssbfilt.m
@@ -0,0 +1,39 @@
+% make_ssbfilt.m
+% David Rowe May 2015
+%
+% Creates low pass filter coeff used to implement a SSB filter in ch
+
+graphics_toolkit ("gnuplot");
+
+ssbfilt_n = 100;
+ssbfilt_bw = 2400;
+ssbfilt_centre = 1500;
+Fs = 8000;
+
+ssbfilt_coeff = sbfilt_coeff = fir1(ssbfilt_n, ssbfilt_bw/Fs);
+
+figure(1)
+clf;
+h = freqz(ssbfilt_coeff,1,Fs/2);
+plot(20*log10(abs(h)))
+grid minor
+
+% save coeffs to a C header file
+
+f=fopen("../src/ssbfilt_coeff.h","wt");
+fprintf(f,"/* %d Hz LPF FIR filter coeffs */\n", ssbfilt_bw);
+fprintf(f,"/* Generated by make_ssbfilt Octave script */\n");
+
+fprintf(f,"\n#define SSBFILT_N %d\n\n", ssbfilt_n);
+fprintf(f,"\n#define SSBFILT_CENTRE %d\n\n", ssbfilt_centre);
+
+fprintf(f,"float ssbfilt_coeff[]={\n");
+for r=1:ssbfilt_n
+ if r < ssbfilt_n
+ fprintf(f, " %f,\n", ssbfilt_coeff(r));
+ else
+ fprintf(f, " %f\n};", ssbfilt_coeff(r));
+ end
+end
+
+fclose(f);