Bug in Resample Filter algorithm

GoldWave general discussions and community help
Post Reply
Videogamer555
Posts: 43
Joined: Wed May 25, 2011 2:28 am

Bug in Resample Filter algorithm

Post by Videogamer555 »

When resampling audio there is a bug. I know that before/and or after scaling a filter must be applied to keep from generating unwanted harmonics of the signal. However the filter has a bug. Rather than filtering it exactly to the edge of the band, it cuts into the band. For example, when I resample 48000sample/second audio up to 96000samples/second, I start with a 24khz bandwidth, and expect to end up with it also having a 24khz bandwidth, while all the harmonics above 24khz are filtered out. Unfortunately that's not what I get. Instead I get a 23khz bandwidth! The filter cut 1khz off the top of the band!!!!!

Now this may not sound like much important, as it is well above the human ear's frequency range. However I'm using this software for processing audio for scientific purposes, and I am intentionally trying to capture ultrasonic frequencies in my experiment. And part of my experiment calls for upsampling the audio to get better time-resolution, and therefore reasampling the audio is NOT OPTIONAL in my experiment. So your filter's bug is causing me to LOSE DATA in my science experiment!
Gord
Posts: 391
Joined: Thu May 21, 2009 4:26 pm
Location: Canada

Re: Bug in Resample Filter algorithm

Post by Gord »

You may want to use

http://src.infinitewave.ca/

to compare the "Passband" performance of Sampling Rate Converters (SRCs) used by various applications. If GoldWave does not meet your particular needs then perhaps some other piece of software will.
DewDude420
Posts: 1171
Joined: Fri Mar 11, 2005 11:15 pm
Location: Washington DC Metro Area
Contact:

Re: Bug in Resample Filter algorithm

Post by DewDude420 »

This is *NOT* a bug! There is no point in you getting over excited about LOSING DATA in your experiment. Goldwave is an audio application; and while it does have many other uses...just because it works properly for audio and not for retaining data; does not mean it's flawed.

Upsampling audio doesn't give you better time-resolution; it's not magically making data appear that wasn't there before; it's basically repeating so many samples to "pad-out" to the desired rate. Sure, it's more data; but I'm not sure how it's going to give you more time-domain information. It's sort of like saying a book is now 33% larger when all you've done is increased the font size. Yes; it's taking 33% more page space to print; but it's added no new information.

This is kind of what's happening when converting 48khz to 96khz; you're not adding any new spectrum information; you're just repeating the sample...even though that's a very basic way of thinking about it.

Basically; good filters try to cut off before the max extreme end of the spectrum; this is to avoid unnecessary quantization errors when doubling up the rate (as it sounds you're doing). However, you need to know resampling is mostly a transparent process; and not entirely lossless. You may need to consider that modifying the sampling rate; with or without a filter; is going to corrupt your data to begin with.
DougDbug
Posts: 2172
Joined: Wed Feb 16, 2005 3:33 pm
Location: Silicon Valley

Re: Bug in Resample Filter algorithm

Post by DougDbug »

Are you sure you need to upsample? You are altering your "scientific data", using an unknown algorithm.*

Sometimes there are "tricks" you can use, such as changing the sample rate (without re-sampling) to bring the frequency down to the audio range. I don't know if that will help you, but doing that doesn't change the raw sample data, it just changes the way the audio software "sees" and processes the data. For example, lowering the sample-rate from 48kHz to 24kHz will double the playing-time and cut the frequencies in half. Mathematically this does nothing (you haven't touched the raw data yet), but if your audio software (or hardware) was filtering-out supersonic signals, those signals can now be processed.
Rather than filtering it exactly to the edge of the band, it cuts into the band.
There are no perfect filters. There are tradeoffs and the DSP programmer (or hardware designer) will usually try to avoid super-sharp filters whenever possible, especially with audio where the most important thing is overall sound quality. If you really need super-sharp filter, you may have to accept some ringing, lots of phase-shift, and other side-effects.
The filter cut 1khz off the top of the band!!!!!
The cut-off frequency for a filter is defined as the 3dB down point. For example, if I tell you I have a 20kHz low-pass filter, you know there is 3dB of loss at 20kHz. So if you want flat response to 20kHz, your cut-off has to be above 20kHz. How much above 20kHz depends on the sharpness (filter order) and on how "flat" the pass-band response needs to be. There are also filters that introduce "bumps" or "ripple" in the passband... Tradeoffs.




* Most scientists use MatLab (or a MatLab clone) or they have an assistant who knows MatLab. That way they can have full control and full understand of the algorithms. I'm NOT suggesting you learn MatLab... It's NOT EASY unless you have a strong math, programming, or DSP background.
Post Reply