Using a Moving Average Filter on Audio
2007-01-25 05:22:24
Hi, I've been reading up on how to implement digital filters in software - mostly using Smith's "The Scientist's and Engineer's Guide to DSP". Making a Moving Average Filter is my first attempt at implementing a filter. The idea behind the filter is very straight forward: the output of a sample will be an average of the given sample and it's neighbor samples. For example, using a 5 point moving average filter where "x" is the input data and "y" as the output data, sample 80 is calculated as:y[80] = (x[78] + x[79] + x[80] + x[81] + x[82]) / 5; So, in C++ I made a simple Moving Average Filter. For testing input data I recorded some 16 bit mono PCM audio of me just talking and then I randomly generated some static and mixed the two together. My expected outcome was that the static noise would be lessened but this was not the case. After trying many different values as the number of points for my moving average filter I always pretty much got the same output: a low volume static and my vocals had disappeared. So, my question: Is it possible that moving average filters are not really meant to be applied to audio, or time domain signals in general? The algorithm is very straightforward and I've reviewed my code many times and I'm not noticing any problem with the calculations. So, I'm starting to think that this filter and audio just don't mix do well. Any comments or advice? Thanks. Zeke