Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-examples / python / apps / hf_radio / hfir.sci
1 // designs a complex tap fir filter akin to the hilbert transformer.
2 //
3 // The hilbert transformer is classified as a linear phase fir
4 // with allpass magnitude response and 90 degree phase response for
5 // positive frequencies and -90 degrees phase for negative frequencies.
6 // Or, if you prefer, normalized frequencies between .5 and 1 since
7 // negative frequencies don't really have much meaning outside the complex
8 // domain.
9 //
10 // Normally one would use the hilbert transformer in one leg of a complex
11 // processing block and a compensating delay in the other.
12 //
13 // This one differs in the following respects:
14 //  It is low pass with a cutoff of .078125
15 //  The filter is a lowpass kaiser windowed filter with parameter 3
16 //  The phase response is 45 degrees for positive frequencies and -45
17 //   for negative frequencies.
18 //  The coefficent set is used in one path and the same coefficients
19 //   are used time reversed in the other. This results in the net effect
20 //   of +/- 90 degrees as in the usual hilbert application.
21 //
22 // The coefficient set can be used in the gnuradio frequency translating
23 // fir filter for ssb demodulation.
24 //
25 // This isn't as computationally efficient as using the hilbert transformer
26 // and compensating delay but fascinating none the less.
27 //
28 // This program is for the scilab language a very powerful free math 
29 // package similar to Matlab with infinitely better price/performace.
30 //
31 // compute the prototype lowpass fir
32 // length is 255 (odd) for the same symmetry reasons as the hilbert transformer
33
34 len = 1023;
35 l2 = floor(len/2);
36 md = l2 + 1;
37 l3 = md + 1;
38
39 h = wfir( 'lp', len, [10.0/256 0], 'kr', [3 0] );
40
41 H = fft(h);
42
43 H(1:l2)=H(1:l2)*exp(%i*%pi/4);
44 H(md)=0+%i*0;
45 H(l3:len)=H(l3:len)*exp(-%i*%pi/4);
46
47 j=real(ifft(H));
48 k(1:len)=j(len:-1:1);
49 x=j+%i.*k;
50 X=fft(x);
51 plot(abs(X))
52
53 f = file('open','taps')
54 for i=(1:len)
55   fprintf( f, '%f%+fj', j(i), k(i) )
56 end
57
58 file('close',f)
59