unstable volume when using WAVE_FORMAT_IEEE_FLOAT

Started by TheRealByteraver, December 03, 2019, 19:28:37

Previous topic - Next topic

TheRealByteraver

Thank you so much for this explanation!
Also the video was very, very well made. I'll have to watch it a few times because the guy goes fast. I was shocked to hear that cassette tapes were probably not better than 6 bits  :o

I always wondered what dithering meant, now I have an idea. If I understood it correctly, you could in theory remove some noise from 8 bit samples by converting them to 16 bit and then adding a (high frequency?) dithering signal with a maximum amplitude of 256? Could it be used as an alternative to interpolation? Even though I suppose interpolation would be faster, even if of the sinc variant.

I was planning to do some programming but here I am reading up on Wikipedia for already two hours again  ;D

About the bit depth, after posting my previous reply, it came to me that if you use 32 bit floats, your signal will never be less precise than 24 bits. It is indeed a lot easier to work with compared to fixed point integer for mixing. All you need to do is scale it down again at the end of the mixing process (or perhaps a little bit up).

Saga Musix

QuoteI always wondered what dithering meant, now I have an idea. If I understood it correctly, you could in theory remove some noise from 8 bit samples by converting them to 16 bit and then adding a (high frequency?) dithering signal with a maximum amplitude of 256?
No, dithering cannot magically make a sample sound better after it has already been truncated. The point of dithering would to to apply the dither before the conversion to 8-bit to make the result sound better. Just think of it: What you proposed would simply add more noise to previously unused lower bits. It would not change anything about the noisy bits already present in the 8-bit source.

QuoteCould it be used as an alternative to interpolation?
Interpolation solves a completely different problem (sample rate conversion) than dithering (bit depth conversion). A good player needs both.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

TheRealByteraver

QuoteWhat you proposed would simply add more noise to previously unused lower bits. It would not change anything about the noisy bits already present in the 8-bit source.

I thought it could replace undesirable harmonics created by the truncation with less undesirable random noise. But I guess it can't do that?

So dithering should be applied before truncating 24 bit audio to 16 bit audio, got it. Does OpenMPT do that during replay (I know it can do so during rendering a .wav file)? Or is that not necessary since the sound card can actually handle (or so it seems) a bit depth of 24 bits or more?

If dithering is done in real time, I suppose you only need to do it for the final result right before you truncate the output from say, 24 bit to 16 bit? Since all the samples get their rate converted to 44.1 kHz (for example).

Saga Musix

Quote from: TheRealByteraver on December 17, 2019, 20:30:27
I thought it could replace undesirable harmonics created by the truncation with less undesirable random noise. But I guess it can't do that?
You can lessen the undesirable harmonics only before they are actually created - but after converting to 8 bit, the undesirable harmonics are already there, and since you cannot deduce the quantization error that was introduced a signal just from looking at the signal, you cannot possibly know what is unwanted quantization noise and what is wanted frequencies.


Quote from: TheRealByteraver on December 17, 2019, 20:30:27Does OpenMPT do that during replay (I know it can do so during rendering a .wav file)? Or is that not necessary since the sound card can actually handle (or so it seems) a bit depth of 24 bits or more?
It depends (TM). For example if we output floating-point audio there is obviously no need to dither (but dither may be introduced at a later stage in the audio pipeline). For other audio configurations, you can configure dither in OpenMPT's output settings.

Quote from: TheRealByteraver on December 17, 2019, 20:30:27
If dithering is done in real time, I suppose you only need to do it for the final result right before you truncate the output from say, 24 bit to 16 bit? Since all the samples get their rate converted to 44.1 kHz (for example).
Yes, you only dither the result. Otherwise you just keep adding up noise and it will be louder than it needs to be. But beware - you are mixing up sample rate conversion and bit depth conversion again. The fact that samples get resampled to a common sample rate like 44.1 or 48 kHz has absolutely nothing to do with dither. Dither only matters for conversion to the target bit depth. Even if you were writing a hypothetical mixer that internally works at 8 bit resolution for whatever reason, you would not dither the samples individually when mixing them into that 8 bit buffer, since it would add way more noise than the quantization error coming from straight up adding the samples together.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

TheRealByteraver

QuoteThe fact that samples get resampled to a common sample rate like 44.1 or 48 kHz has absolutely nothing to do with dither

Yes yes I get that now. Resampling corrects a "horizontal" quantization (frequency), dithering a "vertical" quantization (when reducing bit depth). Sorry for expressing it in such a lame way ;)
Thank you for your patience, this has been very educational, as always.
On a side note, what did you mean with "(TM)"? I googled it, but only found it meant "Text Me" or "Trade Mark". I apologize if it was a joke that went over my head :D

Saga Musix

The second definition is the correct one. It doesn't have any specific meaning, it's a Tradesnark. ;)
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.