diff options
Diffstat (limited to 'octave/make_ssbfilt.m')
| -rw-r--r-- | octave/make_ssbfilt.m | 39 |
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); |
