patch-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Patch-gnuradio] preemphasis filter


From: sriram s
Subject: [Patch-gnuradio] preemphasis filter
Date: Sun, 25 May 2008 02:13:47 -0700 (PDT)

#Code for Preemphasis filter in fm_emph.py.

##################
class fm_preemph(gr.hier_block):
    """
    FM Preemphasis IIR filter.
    """
    def __init__(self, fg, fs, tau1=50e-6, f2):
        """
        @param fg: flow graph
        @type fg: gr.flow_graph
        @param fs: sampling frequency in Hz
        @type fs: float
        @param tau1: Time constant in seconds (75us in US, 50us in EUR)
        @type tau1: float
        @param f2: cutoff frequency in Hz,choose f2 > f1 ( f1 is 2.12KHz in US, 3.2KHz in EUR)
        @type f2: float
        """
       
    tau2=tau1/(2*math.pi*f2*tau1-1)
    w_1=1/tau1
    w_2=1/tau2
    w_p1=math.tan(w_1/(fs*2))
    w_p2=math.tan(w_2/(fs*2))
    b0=(w_p2+1)/(1+w_p1+w_p2)
    b1=(w_p2-1)/(1+w_p1+w_p2)
    a1=(w_p1+w_p2-1)/(w_p1+w_p2+1)
    btaps = [b0,b1]
             ataps = [1,a1]
             if 0:
                    print "btaps =", btaps
                    print "ataps =", ataps
                   global plot2
                    plot2 = gru.gnuplot_freqz (gru.freqz (btaps, ataps), fs, True)
            preemph = gr.iir_filter_ffd(10*btaps, ataps)
   
      gr.hier_block.__init__(self, fg, preemph, preemph)

##################################

# please let me know if this works.

Sriram



reply via email to

[Prev in Thread] Current Thread [Next in Thread]