You are here

The "float/fixed" debate and more digital myths

For everything after the recording stage: hardware/software and how you use it.

Re: The "float/fixed" debate and more digital myths

Postby Folderol » Fri Jan 03, 2020 2:34 pm

desmond wrote:When you import a 32-bit float file into Logic, Logic first converts it to a 24-bit fixed point file, and then uses that 24-bit file in the project from then on - Ie, it doesn't directly use the original 32-bit float file after the import process.

Logic's mixer is 32-float format by default, but does have a 64-bit high precision engine option if you want.
Interesting.
These days, there isn't a lot of difference resource-wise between float and fixed point, but the conversion from one to the other is a serious bottleneck, so presumably they've done this to retain compatibility with their original file format and get rid of said bottleneck.

I've only worked with linux code, and know of just one person who seems to have done something similar (very much a cutting-edge guy). I've not looked at the code itself, but my understanding is the internal working resolution is 32bit fixed, which is just a bit shift away from 24bit
User avatar
Folderol
Jedi Poster
Posts: 11657
Joined: Sat Nov 15, 2008 1:00 am
Location: The Mudway Towns, UK
Yes. I am that Linux nut.
Onwards and... err... sideways!

Re: The "float/fixed" debate and more digital myths

Postby merlyn » Tue Jan 07, 2020 12:25 am

I've always thought on audio data as integers. Two's complement signed integers.

A float takes the form :

s|eeeeeeee|mmmmmmmmmmmmmmmmmmmmmmm

1 sign bit, 8 exponent bits and 23 mantissa bits. That's turned back into a number as

+/- 2^(e-127) * (1+m)

There is then some conversion required to get a 24 bit two's complement signed integer -- it's not simply a case of dumping the exponent. But does it need dither?

Back in the days of16 bit recording dither was added to the input signal. Now with 24 bit the noise of the preamp dithers the signal and the last four bits are lost below the noise floor. I don't think even a super low level signal would need dithered when converted to 24 bit because it's in the dither, which will be ~4 bits high when scaled back to normality, normality being an exponent of 2^0 = 1 which is a value of 127 of the exponent bits.

Dither de-correlates quantisation distortion from the signal. The ear is more tolerant of noise than distortion.

An undithered image:

Image

Dithering saves the image from technical catastrophe :

Image
merlyn
Regular
Posts: 149
Joined: Thu Nov 07, 2019 3:15 am

Re: The "float/fixed" debate and more digital myths

Postby DC-Choppah » Tue Jan 07, 2020 3:32 am

:thumbup:
merlyn wrote:I've always thought on audio data as integers. Two's complement signed integers.

A float takes the form :

s|eeeeeeee|mmmmmmmmmmmmmmmmmmmmmmm

1 sign bit, 8 exponent bits and 23 mantissa bits. That's turned back into a number as

+/- 2^(e-127) * (1+m)

There is then some conversion required to get a 24 bit two's complement signed integer -- it's not simply a case of dumping the exponent. But does it need dither?

Back in the days of16 bit recording dither was added to the input signal. Now with 24 bit the noise of the preamp dithers the signal and the last four bits are lost below the noise floor. I don't think even a super low level signal would need dithered when converted to 24 bit because it's in the dither, which will be ~4 bits high when scaled back to normality, normality being an exponent of 2^0 = 1 which is a value of 127 of the exponent bits.

Dither de-correlates quantisation distortion from the signal. The ear is more tolerant of noise than distortion.

An undithered image:

Image

Dithering saves the image from technical catastrophe :

Image

:) :thumbup:
User avatar
DC-Choppah
Frequent Poster
Posts: 1638
Joined: Fri Jul 20, 2012 12:00 am
Location: MD, USA

Re: The "float/fixed" debate and more digital myths

Postby Rich Hanson » Tue Jan 07, 2020 11:33 am

merlyn wrote:I've always thought on audio data as integers. Two's complement signed integers.

A float takes the form :

s|eeeeeeee|mmmmmmmmmmmmmmmmmmmmmmm

1 sign bit, 8 exponent bits and 23 mantissa bits. That's turned back into a number as

+/- 2^(e-127) * (1+m)

There is then some conversion required to get a 24 bit two's complement signed integer -- it's not simply a case of dumping the exponent.

If you work through the maths, as long as the exponent is 127 (which would be equivalent to the normal 24 bit range) then throwing away the exponent is exactly what you are doing. The sign bit and the mantissa are still making up a two's complement number.

Obviously this only holds true for that situation, and higher exponent values for example could lead to clipping.
User avatar
Rich Hanson
Frequent Poster (Level2)
Posts: 2170
Joined: Sat Sep 06, 2003 12:00 am
Location: UK

Re: The "float/fixed" debate and more digital myths

Postby merlyn » Tue Jan 07, 2020 2:51 pm

It would make things easier if that was the case. As far as I can make out that is not the case. Dumping the exponent and appending the sign bit gives a number that's not in two's complement.

There is an IEEE 754 converter here :

https://www.h-schmidt.net/FloatConverter/IEEE754.html
merlyn
Regular
Posts: 149
Joined: Thu Nov 07, 2019 3:15 am

Re: The "float/fixed" debate and more digital myths

Postby Rich Hanson » Tue Jan 07, 2020 3:36 pm

I stand corrected, I'm well out of date :thumbup:
User avatar
Rich Hanson
Frequent Poster (Level2)
Posts: 2170
Joined: Sat Sep 06, 2003 12:00 am
Location: UK

Re: The "float/fixed" debate and more digital myths

Postby Folderol » Tue Jan 07, 2020 7:06 pm

Rich Hanson wrote:I stand corrected, I'm well out of date :thumbup:
I have to be corrected so often that I find it more comfortable to sit :lol:
User avatar
Folderol
Jedi Poster
Posts: 11657
Joined: Sat Nov 15, 2008 1:00 am
Location: The Mudway Towns, UK
Yes. I am that Linux nut.
Onwards and... err... sideways!

Re: The "float/fixed" debate and more digital myths

Postby merlyn » Wed Jan 08, 2020 5:48 pm

@Rich Thanks for your input. This is how myths get busted!

The idea that 32 bit float contains unaltered 24 bit audio data scaled by an eight bit exponent is ... a myth. I don't know where this originated but it's all around the internet -- I've never seen it explained any other way.

It may have been put together to reassure neurotic musicians who want to dither 24 bit audio ... twice.

What I said above about an exponent of 2^0 = 1 is wrong. With an exponent of 1 the numbers that can be represented are +1 to +2 and -1 to -2. That isn't a lot of use for audio.

The two's complement integers must be converted to a float between -1 and +1.

As far as I can see this doesn't introduce errors. Take 1 as an integer. To convert it to a float between 0 and 1 you would divide by 2^23 and that can be done exactly in a float with an exponent 0f 2^-23.

1 > 1/(2^23) = 2^-23
2 > 2/(2^23) = 1/(2^22) = 2^-22
3 > 3/(2^23) (also exact)
4 > 4/(2^23) = 2^-21

... and so on. This means the exponent is being used all the time.

The principle that no information is being lost or gained holds, but the details are more involved than the myth suggests.
merlyn
Regular
Posts: 149
Joined: Thu Nov 07, 2019 3:15 am

Re: The "float/fixed" debate and more digital myths

Postby Hugh Robjohns » Wed Jan 08, 2020 6:11 pm

merlyn wrote:...the details are more involved than the myth suggests.

Isn't that always the way? :D :ugeek:
User avatar
Hugh Robjohns
Moderator
Posts: 29034
Joined: Fri Jul 25, 2003 12:00 am
Location: Worcestershire, UK
Technical Editor, Sound On Sound

Re: The "float/fixed" debate and more digital myths

Postby desmond » Wed Jan 08, 2020 6:27 pm

merlyn wrote:The idea that 32 bit float contains unaltered 24 bit audio data scaled by an eight bit exponent is ... a myth.

I'm not sure if you were referring to me or not, but I'll say if it wasn't clear is that I didn't think that was the case. When I say that 32-floating audio format contains 24-bit audio data, it doesn't mean I think it's a naive mapping of 24-bits of fixed point stuck in the lower bits of the floating point number - but I can see that it can be interpreted (incorrectly) as that's what's going on.

One thing I do say is that float numbers are "mathsy" and not at all intuitive to "regular" folk compared to fixed point files which are reasonably straighforward, and the times when I've looked into it just makes me realise that the full details are over rather over my head and I have needed to get into it deeply enough for a complete understanding. I understand just enough of it to be useful (and not *too* dangerous!) ;)

merlyn wrote:I don't know where this originated but it's all around the internet -- I've never seen it explained any other way.

Indeed. Like many things about digital audio, often they are explained by people who don't know the full details, because the full details have complexities that are problematic to explain to us more naive folk.

merlyn wrote:The two's complement integers must be converted to a float between -1 and +1.

Indeed.

merlyn wrote:The principle that no information is being lost or gained holds, but the details are more involved than the myth suggests.

Yes.

Also, I vaguely recall (but don't have the full details offhand) something about the floating range when you get high up is that the resolution isn't quite linear like integers - the gaps between numbers on the scale get bigger as you go. Maybe you can explain that to us laymen...
User avatar
desmond
Jedi Poster
Posts: 10619
Joined: Tue Jan 10, 2006 1:00 am
mu:zines | music magazine archive | difficultAudio

Re: The "float/fixed" debate and more digital myths

Postby Hugh Robjohns » Wed Jan 08, 2020 6:53 pm

Most users don't realise that digital audio typically uses of two's complement binary, or the fundamental reasons for that, and will probably never grasp the important subtleties of IEEE floating point formats...

And most explanations are (over) simplified to try and get a concept across, rather than the detail... which is absolutely fine in my book. Most people aren't interested in, and don't need the technical detail, and the few who are interested will be quite capable of moving beyond the simplified analogies.

H
User avatar
Hugh Robjohns
Moderator
Posts: 29034
Joined: Fri Jul 25, 2003 12:00 am
Location: Worcestershire, UK
Technical Editor, Sound On Sound

Re: The "float/fixed" debate and more digital myths

Postby Rich Hanson » Wed Jan 08, 2020 8:18 pm

Back in the dim and distant past (i.e. pre IEEE standardisation) there was a floating point format that was effectively a 2's complement with an exponent, so that's probably where the myth originated. My experience was on an old GEC minicomputer with 14 bit word length, so that gives you some idea of how long ago :bouncy: (Needless to say that in 14 bits, the accuracy was less than stellar, we tended to use our own fixed point libraries instead)

Anyway, back to the subject in hand!
User avatar
Rich Hanson
Frequent Poster (Level2)
Posts: 2170
Joined: Sat Sep 06, 2003 12:00 am
Location: UK

Re: The "float/fixed" debate and more digital myths

Postby CS70 » Wed Jan 08, 2020 9:14 pm

desmond wrote:Also, I vaguely recall (but don't have the full details offhand) something about the floating range when you get high up is that the resolution isn't quite linear like integers - the gaps between numbers on the scale get bigger as you go. Maybe you can explain that to us laymen...

That's not so difficult to see, without even considering radix complements and IEEE 754. it's just a general consequence of the fact that the representation uses a nonlinear function and that you have only so many bits available to represent the function parameters (for a format say as "1.decimals x 10 power exponent" you will have a onlya given number of bits for "decimals" and for "exponent").

For fixed point representation (in the form "number dot decimals"), the "fixed number" of bits for "number" and "decimals" means that you have constant gaps between the real numbers that can be represented and numbers that cannot (and will be approximated, typically to the nearest lower representable number).

Say you allocate 2 bits for the decimals, you can represent only .0, .1, .2 and .3 as decimal parts, so that the real numbers 1.15 and 1.16 will end up both as,say 1.1 - the gap between the numbers you can represent will be a constant .1 . In other words, the mapping between reals and representation - so long there is one - is linear because the mapping function is linear.

With a representation that uses a power 10 function (or whatever nonlinear mapping), you still have the same "constant spacing" for the decimal part, but the multiplier will vary nonlinearly, leading to an nonlinear spacing between the representable numbers.

Say you use 2 bits for decimal part and 2 bits the exponent: you will have 0,1,2 and 3 as possible decimal parts (leading to 1.0, 1.1, 1.2 and 1.3 as left multiplier) and 1, 10, 100 and 1000 as possible right multipliers. Therefore, the numbers you can represent are therefore 1, 1.1, 1.2, 1.3, then 10, 11, 12, 13, then again 100, 110, 120, 130 and finally 1000, 1200, 1300, 1400. So the gaps between numbers that can be represented (or equivalently, the approximation error when you map real numbers) varies nonlinearly (and gets bigger for bigger numbers that you want to represent).

The same will happen with any representation using a nonlinear function, with the "gaps" between numbers varying according to the specific nonlinear function used.
User avatar
CS70
Jedi Poster
Posts: 6485
Joined: Mon Nov 26, 2012 1:00 am
Location: Oslo, Norway
Silver Spoon - Check out our latest video and the FB page

Re: The "float/fixed" debate and more digital myths

Postby merlyn » Thu Jan 09, 2020 5:00 am

If I have a go at explaining that ...

23 bits is 8,388,608 different values. If the exponent is 2^0 = 1 there are 8,388,608 steps between 1 and 2. If the exponent is 2^1 = 2 there are the same number of steps but now these steps span the interval between 2 and 4. This is the same number of steps covering twice the range. If the exponent is 2^2 = 4 there are the same number of steps to cover the interval between 4 and 8. The distance between steps is getting bigger as the exponent goes up.

The exponent can go up to 2^127 = 170 141 183 460 469 231 731 687 303 715 884 105 728.

Those ~8 million steps don't seem like so many now :D
merlyn
Regular
Posts: 149
Joined: Thu Nov 07, 2019 3:15 am

Re: The "float/fixed" debate and more digital myths

Postby wireman » Thu Jan 09, 2020 9:10 pm

Yes indeed. By the way there is a nice blog here...

https://blogs.mathworks.com/cleve/2014/07/07/floating-point-numbers/

In some fields people are looking at using less bits to represent numbers than the standard 32/64 and also proposing other floating-pont representations with different distributions. Specialist hardware (GPUs) now support shorter number formats which means that multiple operations can run faster and also you get an advantage because it takes less memory and memory bandwidth to compute on numbers represented by less bits.

For audio (and I doubt we care anyway) it could even turn out that the distribution you note is actually a good thing as we use log scales as more relevant to hearing response in any case
wireman
Frequent Poster
Posts: 559
Joined: Fri Dec 17, 2004 1:00 am

PreviousNext