Converting from float 32 PCM to signed 16 PCM. Does it matter if I resample before or after the bit depth conversion?

0

I have a sound source fed into a GStreamer pipeline for conversion into a more suitable format. The sources are varied but at the end of the pipeline I must have Signed 16-bit PCM (Mono) at 48Khz.

The audio source at the begining of the pipeline is 32bit floating point samples at whatever rate the source sees fit (a result of using the playbin element) with 1 or more channels (usually stereo but could be more) so the pipeline as of now does the following in this order:

  • Downmix to mono (fp 32)
  • Resample (fp 32; [anything] -> 48Khz)
  • Conversion (fp32 -> s16)

Doing the conversion first saves me some significant CPU load since all the remaining conversions are done mostly in integers but I am unsure if there would be any noticeable artifacts under some circumstances.

NeonMan

Posted 2019-01-09T14:06:56.813

Reputation: 103

Answers

3

I think the way you currently have the pipeline set-up is the right way to do it. Conversion should be the last block in the chain for sure as this will ensure that any processing artifacts are minimised during down-mix and resampling.

Performing conversion at the start may provide some small CPU benefits, but has the possibility of introducing artifacts which may be undesirable.

If you are using Floating Point optimised code and processor instructions you will not have to worry too much about CPU load by having the conversion at the end.

I would also recommend adding dither prior to conversion and truncation.

Mark

Posted 2019-01-09T14:06:56.813

Reputation: 7 535

Can you point me to some doc related to adding dither and when is it needed? It is possible the resample element already does it right now, i should check (Edit: It does. 'TPDF' by default, 'RPDF' or 'None' available too). – NeonMan – 2019-01-09T14:17:44.797

Dither is usually employed during a bit-truncation process, for instance when you are truncating your word-length from 24-bits to 16-bits for delivery. IMHO It's always needed if you are reducing your word-length.

Here's an article on dither:

http://darkroommastering.com/blog/dithering-explained/

– Mark – 2019-01-09T23:18:17.723