• ### Not clipping! (?) OMG, MY BAD, NEVERMIND

I accidentally discovered that I can send audio streams with +/- 1.4 peaks to [dac~] and it doesn't clip on either my 01V96i or MOTU ultralite 4, although the analog output levels are different. I always thought +/- 1 was full scale. What's going on? The mixer can be connected via S/PDIF or USB and the MOTU via USB, so I'm guessing those links can handle numbers > 1 and < -1 (what's the maximum?), and the fact that my converters produce different output levels for the same numbers means there's no standard? And 1.4 suggests that the actual limit might be 1.4142 = sqrt(2) = pow(cos(pi/4), -1). If true, what's the significance?

• Posts 15 | Views 2114
• @jameslo Since the "loudness wars" the EBU R 128 spec recommends a maximum of -3dB as lossy codecs will often clip at just above. I know that at least one pci soundcard card adjusts its metering for that spec, even though it is a broadcast spec, as it has madi output with aes/ebu.

I cannot find anything that points to whether Miller or the computer industry decided on your 1.4.
Only that devices are different..... i.e. old ios didn't use floating point because it couldn't do the maths fast enough.

You need high impedance headphones with most laptops as their voltage rails are 3.3V nowadays. Even when they were 5V audio out was puny. The MacBook pro only delivers 3V RMS to the headphone socket.
And 32bit floating point has a dynamic range of 1528dB....! ... be careful out there...!...
David.

• @whale-av said:

And 32bit floating point has a dynamic range of 1528dB....! ... be careful out there...!...

That's a joke, right?

Let's do a thought experiment. Let's say you have binary floating-point samples where the maximum exponent is 4 and you have 2 bits below the point. Then the maximum value is 1.11 * 2^4 = 11100 = 28. If you had all the bits of precision, the maximum would be 31 (the largest integer less than 2^(4+1)). So the maximum quantization error due to the limited precision of the mantissa is 3 = 2 ^ (max exponent - mantissa bits) - 1.

If we increase the maximum exponent to 5, the same holds: max possible value = 111111 = 63, max encodable = 111000, max error = 7.

If we increase the maximum exponent to 127 (max allowed in single precision), and allow 23 bits below the point, then the error is 2 ^ (127 - 23) - 1 = 2 ^ 104 - 1, or on the order of 2 * 10^31.

This is the noise part of signal-to-noise ratio. It's the maximum noise. The overall noise level is the integral of the quantization error function (which is the absolute value of the difference between y and quantized y, where quantized y is a piecewise function) divided by the x range (something like that) and this will be lower than the max.

Of course, if you have an audio signal scaled up to 2^127, then some samples might reach the peak, but many will be lower amplitude, and their quantization error will be lower. So the overall SNR should be higher than the worst case at the top of the range. But quantization error must integrate over the absolute value, so the lower error at small amplitudes does not cancel out the astronomical error at high amplitudes.

Yes, I've seen the articles producing that bogus 1528 dB figure. The mistake they make is to assume that quantization error is equally distributed throughout the range, and that the magnitude of this quantization error is proportional to the smallest representable value. This is a fundamental reasoning error. To understand how to think properly about quantization error, read https://www.analog.com/media/en/training-seminars/tutorials/MT-229.pdf .

I'm quite bothered by this, actually. Some marketing bros use faulty math to claim that "our soundcard can give you 1528 dB dynamic range!!1!1!!" and then this goes to the top of search results, and gets repeated as folklore. But it's nonsense. It needs to be stopped.

hjh

• @ddw_music True... of course no soundcard is going to give such a range... but the lies in audio marketing are legion and "musician" and "space" nearly synonyms.
I thought we (but probably just me) were discussing internal IEEE standard processing wrt 32bit floating point. Anyway its a bit more complex than that. A better read on the subject of quantization error imhb...... https://www.analog.com/en/technical-articles/relationship-data-word-size-dynamic-range.html
David.

• @whale-av said:

I thought we (but probably just me) were discussing internal IEEE standard processing wrt 32bit floating point.

Sure, and no dispute. Audio software generally assumes that floating point +/- 1.0 is full scale, and indeed I always assumed that. But if something in the chain is reducing by 3 dB then Pd wouldn't have any control over that.

In any case, I mainly wanted to note that this is one case where Google doesn't help.

Incidentally there were some extensive debates in SuperCollider land over whether SC should or should not clip to +/-1.0. Apparently in Mac, there might not be any limiting or clipping within CoreAudio before applying the system volume control. If something blows up, you might get a 700 dB signal out of SC, which would be attenuated by up to just a few dozen dB at the system volume control = full range distorted signal into your earphones, call your doctor. So pd isn't the only place where signals beyond full scale got passed through.

A better read on the subject of quantization error imhb...... https://www.analog.com/en/technical-articles/relationship-data-word-size-dynamic-range.html

One thing this article doesn't do is to calculate the 32 bit float SNR (unless I overlooked it), probably because the answer depends partly on signal amplitude.

hjh

• this is why using abstractions to wrap/clip output before `[dac~]` are good practice imo.. I have `[outputc~]` in shadylib that also has a volume slider and the option to record.

• I sometimes use my mixer as a lazy loopback device: I output to it via S/PDIF and then take input via USB. If I send signals that step outside of -1..1 I get clipping! So so far I only see that 3dB of headroom on the analog outputs.

• @jameslo said:

So far I only see that 3dB of headroom on the analog outputs.

Just occurred to me: If an equal-power stereo panner's gain is 0 dB at the sides, then the gain will be sqrt(1/2) in the center (both with sinusoidal and sqrt laws).

So here's a common audio operation that would drop 3 dB with default settings, which a driver or OS-mixer author might consider a good idea to include in the chain. (Also, this would be unlikely to be applied to mono inputs.)

hjh

• @ddw_music That's it!!! I was ignoring my panner, which when panned to the middle is down 3dB on both L & R. And for that last test with my lazy man's loopback, I just wrote something from scratch and omitted the panner. Crap, I wish I could delete this whole thread so as not to mislead anyone else. -1..1 is the full range, period. Sorry to waste everyone's time

• @jameslo The time was not wasted.... we all learnt something... and a great quantity of head scratching will probably save me money for shampoo...
David.

Posts 15 | Views 2114
Internal error.

Oops! Looks like something went wrong!