1% make_ssbfilt.m
2% David Rowe May 2015
3%
4% Creates low pass filter coeff used to implement a SSB filter in cohpsk_ch
5
6graphics_toolkit ("gnuplot");
7
8ssbfilt_n = 100;
9ssbfilt_bw = 2400;
10ssbfilt_centre = 1500;
11Fs = 8000;
12
13ssbfilt_coeff  = sbfilt_coeff = fir1(ssbfilt_n, ssbfilt_bw/Fs);
14
15figure(1)
16clf;
17h = freqz(ssbfilt_coeff,1,Fs/2);
18plot(20*log10(abs(h)))
19grid minor
20
21% save coeffs to a C header file
22
23f=fopen("../src/ssbfilt_coeff.h","wt");
24fprintf(f,"/* %d Hz LPF FIR filter coeffs */\n", ssbfilt_bw);
25fprintf(f,"/* Generated by make_ssbfilt Octave script */\n");
26
27fprintf(f,"\n#define SSBFILT_N %d\n\n", ssbfilt_n);
28fprintf(f,"\n#define SSBFILT_CENTRE %d\n\n", ssbfilt_centre);
29
30fprintf(f,"float ssbfilt_coeff[]={\n");
31for r=1:ssbfilt_n
32  if r < ssbfilt_n
33    fprintf(f, "  %f,\n",  ssbfilt_coeff(r));
34  else
35    fprintf(f, "  %f\n};", ssbfilt_coeff(r));
36  end
37end
38
39fclose(f);
40