WAV file resampling sketch

el_supremo

Well-known member
I've ordered audio adaptors for my two Teensy 3.1 and while waiting for them to arrive, I've been playing with resampling WAV files using the ARM CMSIS arm_fir_q15 function.
This sketch (for Teensy 3.0 or 3.1) reads a 8kHz WAV file and converts it to 44.1kHz:
http://members.shaw.ca/el_supremo/my_fir_cd_usd_d.zip
There are also a few example WAV files in the samples subdirectory in the zip file.

The sketch reads a 16-bit mono PCM WAV file sampled at 8000Hz from the /samples directory of an attached uSD card, upsamples to 48kHz and lowpass filters the result. It then removes 13 of every 160 samples, which results in a 44.1kHz sampling rate, lowpasses that again and then writes the result into the /resample directory on the uSD card. I had expected that the second part (removing samples) would cause problems. However, it is the upsampling to 48kHz which causes some aliasing which is particularly noticeable in the phone.wav sample.

Play with it. Share any improvements/fixes that you make.

Pete
 
After playing some more with the sketch I found that it was the conversion from 48kHz to 44.1kHz that introduces the aliasing, not going from 8kHz to 48kHz. Unfortunately, there's no way to avoid the aliasing doing it that way.
I've created another sketch which upsamples a file from 8kHz to 88kHz, low pass filters it and then downsamples it to 44kHz. It then just changes the WAV header's sample rate to 44100Hz. I've tried this with the doorbell and Bach samples at 44000 and at 44100 and I can't hear a difference but then I do not have perfect pitch. But the aliasing isn't there any more.
The new sketch is here: http://members.shaw.ca/el_supremo/my_fir_44k_usd.zip

Pete
 
Hi Pete, I am working on a project that requires up-sampling from 8kHz to 44.1Khz, exactly as you have described. I am wondering if it is still possible to have a look at the code described in your last post? Unfortunately the link is no longer work. Fair enough too, it has been 8 years...

Cheers,
Alex
 
Hi Mark, that looks pretty impressive! I will check it out and hopefully I can wrap my head around it. Thank you!
 
Back
Top