Page 2 of 2

Re: Disable automatic low pass filter when resampling

Posted: Sat Jun 08, 2019 5:14 pm
by steve
Trebor wrote:
Sat Jun 08, 2019 4:39 pm
In Audacity 2-3-2 on Windows 8 that code just speeds it up.
It doesn't "only" speed it up. It resamples the selected audio to 8 kHz, and returns the audio to the track. It does NOT change the Audacity track which is still set to 44.1 kHz.
Because there are less samples in the returned audio than there were in the original (because it has been resampled), it takes up less space in the audio track, effectively "speeding it up".
By changing the track sample rate (from the track's drop down menu) to 8000 Hz, the samples are then correctly spaced out at intervals of 1/8000 second, and the track will play at the correct speed.

Re: Disable automatic low pass filter when resampling

Posted: Sat Jun 08, 2019 5:47 pm
by Trebor
steve wrote:
Sat Jun 08, 2019 5:14 pm
By changing the track sample rate (from the track's drop down menu) to 8000 Hz,
the samples are then correctly spaced out at intervals of 1/8000 second,
and the track will play at the correct speed.
OK but that plays it at the correct speed, but it has nothing above 4kHz.
It doesn't have the high-frequency digital-artefacts, which was the brief.

before-after dblue crush (downsample 16th).flac
after downsampling by 1/16th with dBlue crusher there are plenty artefacts
(1.34 MiB) Downloaded 28 times

Re: Disable automatic low pass filter when resampling

Posted: Sun Jun 09, 2019 1:54 am
by DVDdoug
OK but that plays it at the correct speed, but it has nothing above 4kHz.
It doesn't have the high-frequency digital-artefacts, which was the brief.
Right. It won't. The Nyquist limit is half the sample rate.

Aliasing is "false" lower frequencies that are created if you don't filter before downsampling.

Re: Disable automatic low pass filter when resampling

Posted: Sun Jun 09, 2019 10:36 am
by steve
DVDdoug wrote:
Sun Jun 09, 2019 1:54 am
Right. It won't. The Nyquist limit is half the sample rate.

Aliasing is "false" lower frequencies that are created if you don't filter before downsampling.
Exactly so.
Example, If you generate a sine tone at 5 kHz and resample to 8 kHz, the Nyquist frequency is 4 kHz. "Proper" resampling (with anti-alias filtering) will remove the 5 kHz sine tone and the result will be silence. Resampling without anti-alias filtering will create a strong peak at 3 kHz (the alias frequency).

The code I provided will also create additional frequencies at a much lower level. These are the result of "distortion" cause by the linear interpolation.

firsttrack000.png
firsttrack000.png (26.86 KiB) Viewed 472 times

Re: Disable automatic low pass filter when resampling

Posted: Sun Jun 09, 2019 5:06 pm
by 8bit_coder
The problem is the sheer act of selecting 8khz in the drop down after using the nyquist command does the exact same effect as just selecting resample and selecting 8khz. The dblue crusher also doesn't allow for a specific sample rate, just a number of sample reductions

Re: Disable automatic low pass filter when resampling

Posted: Sun Jun 09, 2019 5:27 pm
by steve
8bit_coder wrote:
Sun Jun 09, 2019 5:06 pm
the sheer act of selecting 8khz in the drop down after using the nyquist command does the exact same effect as just selecting resample and selecting 8khz.
No it doesn't.

When you select Resample, the audio is resampled by "soxr" (a high quality resampling library) which applies anti-alias filtering prior to resampling.
With the steps that I posted, the audio is resampled by Nyquist using linear interpolation and no pre-filtering.

Try the comparison that I described in this post: viewtopic.php?p=371369#p371369
You will see that Audacity's resampling (using soxr) produces silence, whereas Nyquist's "force-srate" produces an alias 3 kHz waveform.