discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] dc restorer


From: cswiger
Subject: [Discuss-gnuradio] dc restorer
Date: Tue, 5 Oct 2004 17:04:34 -0400 (EDT)

Gang - Working from this algorithm:

http://www.dspguru.com/comp.dsp/tricks/alg/dc_block.htm
http://aulos.calarts.edu/pipermail/music-dsp/1998-March/020124.html

the following seems to work removing a dc offset from a signal.
Hasn't been thoroughly tested, submitted for peer review. It doesn't
look too expensive in cpu.

For some reason we get this message repeated:
  gr_iir_filter_ffd::work noutput_items = 4095
but it seem to work anyway.

------------

dc_restorer.py

def build_graph ():

        sampling_freq = 8e6

        fg = gr.flow_graph ()

        src = gr.sig_source_f (
                sampling_freq,
                gr.GR_SIN_WAVE, 266e3,
                1, -4.8 )      # test signal w/ dc offset
        # vary freq and offset to make sure result has
        # same amplitude and no offset for any input

        diff = gr.fir_filter_fff ( 1, [1, -1] ) # y[n] = x[n] - x[n-1]
        int = gr.iir_filter_ffd ( [1, 0], [0, .999] )
                # y[n] = .999*y[n-1] + x[n]
                # 1 seems to work also
                # in place of .999 ??

        dst_i = gr.file_sink (gr.sizeof_float, "restore_in")
        dst_o = gr.file_sink (gr.sizeof_float, "restore_out")

        fg.connect (src, dst_i)
        fg.connect (src, diff)
        fg.connect (diff, int)
        fg.connect (int, dst_o)

        return fg

--------------------

May contain typos.
Now for the automatic gain control....

--Chuck





reply via email to

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