3
$\begingroup$

What would a straight-forward way to convert an audio payload (PCM 16bit) from 6 kHz to 8kHz? I understand that this is an interpolation problem.

I fear that a linear interpolation would introduce too much noise. If so, what would be a better interpolation? I was looking at Lanczos resampling but I've seen it used in image scaling only and not sure it's worth it for audio.

I'm using Java. I've found the JSSRC library butI would have prefer something more lightweight. Beside, I'm not sure this is really necessary for low-frequency audio (which happens to be decoded from ADPCM).

BTW, I'm not interested in creating a WAV having a 6 kHz frequency header, I really want to resample.

$\endgroup$
1
  • $\begingroup$ You can upsample it 4 times and downsample 3 times to achive 8 kHz, don't you? $\endgroup$
    – Serj
    Jan 15, 2015 at 20:39

2 Answers 2

2
$\begingroup$

Using a windowed Sinc interpolation kernel is a very common way to do this kind of sample rate change. A polyphase table with precalculated coefficients allows this kind of rational interpolation to be done by a simple interleaved set of convolutions. You can vary the quality of the resampling by choice of the width and shape of the window on the Sinc function.

No need to upsample and downsample in two stages of operations.

$\endgroup$
5
  • $\begingroup$ sorry if I'm wrong but, the sinc interpolation kernel is actually an ideal lowpass filter. And if you dont up/down sample how will you keep the number of samples correct? Polyphase decomposition is an efficient method of up/down rate conversion. These are all based on Discrete-Time Signal Processing, 2e, A.Oppenheim, Ch:4 Sampling of Continuous Time signals, sections: 4.6 and 4.7 $\endgroup$
    – Fat32
    Jan 16, 2015 at 21:25
  • $\begingroup$ You get the correct number of samples by interpolating the correct number of points at the proper spacing and phase offset for each result sample point. $\endgroup$
    – hotpaw2
    Jan 16, 2015 at 23:26
  • $\begingroup$ Indeed yes, I think I remembered that method of resampling a dt signal, from its reconstruction formula. $\endgroup$
    – Fat32
    Jan 16, 2015 at 23:41
  • $\begingroup$ I'm currently reading ccrma.stanford.edu/~jos/resample/resample.pdf which explains in details how to get there. However, I'm not sure about the "polyphase table" you mentioned. Is it known by any other name? I do realize that coefficients do not need to be calculated every time since they get repeated periodically (scaling by a rational factor here), so they can be computed once and kept in a table. Is this what you meant by polyphase table? $\endgroup$
    – gawi
    Jan 26, 2015 at 17:24
  • 1
    $\begingroup$ Yes. A polyphase table is another name for a precalculated table for all the repeating fractional interpolation offsets (perhaps arranged for efficient access or indexing of the needed coefficients for each sample interpolation). $\endgroup$
    – hotpaw2
    Jan 26, 2015 at 18:05
2
$\begingroup$

If processing cost is not a problem, you may use the following algorithm for sample rate converting your data from 6 khz to 8 khz.

1- expand your signal x[n] by 8, producing xe[n] (insert 7 zeros after every sample of x[n])
2- design a low pass filter hlpf[n] with a gain of 8 and cutoff frequency pi/8
3- process the expanded signal with this lowpass filter = xef[n]
4- compress output of the filter by 6 via selecting every 6th sample: y[n]=xef[6n]
(NOTE: You can also do this with 4:3 upsample and down sample, with a new filter, which would require less processing cost)

Lowpass filter must be sharp enough to ensure proper anti-aliazing. If this is too much overburden for simple rate conversion then try high order polynomial resampling. That could also be costly however.

$\endgroup$
1
  • $\begingroup$ One FIR filter with $\pi/4$ and out of band suppression of about 40...50 dB is the simplest decision here. Polynomial resempling is good enough for the cases of big least common multiple. $\endgroup$
    – Serj
    Jan 15, 2015 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.