DSPRelated.com
Forums

Time domain convolution in a real-time situation

Started by DSP-Newbie March 6, 2007
"DSP-Newbie" <No@way.invalid> wrote in message 
news:mn.35537d7381c69ea9.59994@way.invalid...
> cincydsp@gmail.com wrote: > >> >> Explicitly padding the input signal with zeros like this will work. >> However, note that you're essentially delaying the input signal by >> length(H) samples, so your output signal (even before you see any >> transients) will also be delayed by length(H) samples. >> > > I am aware of that, but its is not a problem; the delay is the same for > all samples. > > > >>> My problem now was, which part of Y[] should I extract and use? >>> After much and trial & error and some hair-pulling, I finally found a >>> intuitive solution that actually works: >> >> -snipped- >> >> I forgot to ask before: why do you want to discard the transients? The >> filter "startup" time is valid data, and occurs as your input signal >> gradually fills up the delay lines that feed each filter tap. > > Perhaps I have not explained my problem clearly. > I have set the soundcard to sample at 11.025 KHz, and to report the > samples in blocks of 2048 samples, so I have to process about 5 > samples/sec. > > Each of these samples - after filtering, envelope detection, PLL bit > sampler etc... - represents a number of bits, not necessarily a *whole* > number of bits, which I have to cobble together block by block to > reconstruct the original synchronous bitstream. > > Now, if I apply the algorithm as found in the book for each incoming > datablock, I will have a startup transient for *each* block.
There's a problem you don't need to carry along. Don't do what the book did. Do continuous processing - if even the continous process has to wait between availability of data. Something like this: Get 2048 data points: Compute 2048 output points. Initially this will include the M-1 startup transient points. Wait for another 2048 block. Continue where you left off using M-1 values of the last input block still in the filter and the one next new input point. There will be no transients in the second and succeeding blocks. The code won't look all that much different from what you're using. Take a look at the circular code at: http://www.dspguru.com/sw/lib/fir_algs_1-0.c Fred
On Mar 6, 10:05 pm, "Fred Marshall" <fmarshallx@remove_the_x.acm.org>
wrote:
> "DSP-Newbie" <N...@way.invalid> wrote in message > > news:mn.35537d7381c69ea9.59994@way.invalid... > > > > > cincy...@gmail.com wrote: > > >> Explicitly padding the input signal with zeros like this will work. > >> However, note that you're essentially delaying the input signal by > >> length(H) samples, so your output signal (even before you see any > >> transients) will also be delayed by length(H) samples. > > > I am aware of that, but its is not a problem; the delay is the same for > > all samples. > > >>> My problem now was, which part of Y[] should I extract and use? > >>> After much and trial & error and some hair-pulling, I finally found a > >>> intuitive solution that actually works: > > >> -snipped- > > >> I forgot to ask before: why do you want to discard the transients? The > >> filter "startup" time is valid data, and occurs as your input signal > >> gradually fills up the delay lines that feed each filter tap. > > > Perhaps I have not explained my problem clearly. > > I have set the soundcard to sample at 11.025 KHz, and to report the > > samples in blocks of 2048 samples, so I have to process about 5 > > samples/sec. > > > Each of these samples - after filtering, envelope detection, PLL bit > > sampler etc... - represents a number of bits, not necessarily a *whole* > > number of bits, which I have to cobble together block by block to > > reconstruct the original synchronous bitstream. > > > Now, if I apply the algorithm as found in the book for each incoming > > datablock, I will have a startup transient for *each* block. > > There's a problem you don't need to carry along. Don't do what the book > did. Do continuous processing - if even the continous process has to wait > between availability of data. Something like this: > > Get 2048 data points: > Compute 2048 output points. Initially this will include the M-1 startup > transient points. > Wait for another 2048 block. > Continue where you left off using M-1 values of the last input block still > in the filter and the one next new input point. > There will be no transients in the second and succeeding blocks. > > The code won't look all that much different from what you're using. > > Take a look at the circular code at:http://www.dspguru.com/sw/lib/fir_algs_1-0.c > > Fred
I'm amazed that it's even working at all. Or maybe he really is keeping the filter history and doesn't realize it. I can't see how you would get anything meaningful if the filter history was flushed after every block; you'd have to be really lucky, I guess. Jason
Fred Marshall wrote:
> The code won't look all that much different from what you're using. > > Take a look at the circular code at: > http://www.dspguru.com/sw/lib/fir_algs_1-0.c > > Fred
Many thanks Fred, this is *exactly* what I needed to implement continuous block-to-block filtering! printf("Testing fir_circular:\n "); clear(NTAPS, z); state = 0; for (ii = 0; ii < IMP_SIZE; ii++) { output = fir_circular(imp[ii], NTAPS, h, z, &state); printf("%3.1lf ", (double) output); } Regards - Dirk
DSP-Newbie wrote:
> Fred Marshall wrote: >> The code won't look all that much different from what you're using. >> >> Take a look at the circular code at: >> http://www.dspguru.com/sw/lib/fir_algs_1-0.c >> >> Fred
And I finally got it working... Thanks to all responders! <http://users.pandora.be/dirk.claessens2/DSP/scrshot.JPG>
DSP-Newbie <No@way.invalid> writes:

> DSP-Newbie wrote: >> Fred Marshall wrote: >>> The code won't look all that much different from what you're using. >>> >>> Take a look at the circular code at: >>> http://www.dspguru.com/sw/lib/fir_algs_1-0.c >>> >>> Fred > > > And I finally got it working... > Thanks to all responders! > > <http://users.pandora.be/dirk.claessens2/DSP/scrshot.JPG>
Very Cool! -- % Randy Yates % "The dreamer, the unwoken fool - %% Fuquay-Varina, NC % in dreams, no pain will kiss the brow..." %%% 919-577-9882 % %%%% <yates@ieee.org> % 'Eldorado Overture', *Eldorado*, ELO http://home.earthlink.net/~yatescr