Downsampling with high fractional sampling ratio

Hi,

I’m emulating a retro Programmable Sound Generator (producing mostly simple square envelopes), running from 1 to 2 Mhz.

The idea was to generate, in real-time using an AudioSource, the data in chunks, then resample the 1000000Hz signal to 44100Hz (for example) at the end of the getNextAudioBlock method. The sampling ratio is pretty high, and fractional.

The generation works very fine, but the trouble comes from the resampling. I must highlight the fact that I know nothing about DSP, FFT and stuff like that, so I relied on existing pieces of code.

Basically, I manage to “get it working”, but there are always some problems depending on the generated frequencies. I tried:

  • The ResamplingAudioSource class: works but quality isn’t good enough.
  • All the interpolators (WindowedSincInterpolator, CatmullRomInterpolator mostly). Works, but once again the quality isn’t good enough.
  • R8Brain. The quality is great, but due to the high fractional sampling ratio, I get problems on how the buffer cycles (too much is generated, or not enough, and I can’t manage to fill the gap (seems I’m not the only one, according to this thread)).

So:

  • Is my two-passes solution the way to go?
  • If no… hmmm, how can I make it work?

Thanks a lot.

@ Jnv
You might like this KVR thread: https://www.kvraudio.com/forum/viewtopic.php?f=33&t=556692
According to them the best idea appears to be a FIR running at the resampled rate. I use a polyphase filter myself but I only need .5 * resampling.

Thanks for the reply. But I have to be honest, the thread is Chinese to me. I do not grasp any of these concepts. But I’ll give it a try. Thanks :).

Hmmm. It might be the time to learn some DSP? You don’t have to go deep, just enough to understand descriptions of techniques.
Here’s a free book on DSP, although I would recommend buying a hard copy.


And there’s probably some more coding orientated books out there.
1 Like