3 ms·
Floats are really nice for audio (PCM) which may not be intuitive. It's much nicer during mixing, editing and other production steps to work with floats and so
by tialaramex 4y ago
Floats are really nice for audio (PCM) which may not be intuitive.
It's much nicer during mixing, editing and other production steps to work with floats and so essentially all modern software does that, even though the A2D conversion is integer and the end results will be integer data (e.g. CD audio is Linear PCM 16-bits at 44.1kHz)
- jqpabc123 4y agoIt's much nicer Said every developer who has ever applied floats where scaled integers would be just as effective. I attribute this to pocket calculators which have shaped most people's thinking. I've even had developers try to tell me it can't be done any other way --- until I show them. All that said, if floats are needed to interface with other software, you may not have much choice in the matter.
- tialaramex 4y agoNot for developers, it's much nicer for the users. There's a phrase "infinite headroom" which might make this a bit sharper. With a conventional analogue recording medium, the medium has physical properties which impact the precision with which it can record audio. For example maybe the reel-to-reel tape recorders in a studio can do about 12-bit precision. At the bottom, the precision is cut off by noise, mechanical noise in the equipment and eventually even quantum mechanical noise in our universe which is unavoidable. At the top it's cut off by practical engineering limits - the magnetic field strengths are limited. A good analogue engineer ensures that there's "headroom" where if the recording is a little louder than expected it doesn't bump into that upper limit, when Aretha hits that note 6dB louder than anticipated, you had 10dB of headroom so it's captured OK. But to do this you're sacrificing that precision at the other end of the scale, listeners can't hear her turning the lyrics sheet in the background of the song even though you'd have heard that if you were in the room. In digital integer space, we can have lots of precision, 14-bit happened early, 16-bit was soon common place, and today 24-bit is widely available (although you need to squint to see 24 actual bits, don't think about it too hard). But, the integers are brick walls at the edges of that range. If you set things up to use all your (say) 16-bits and it comes out hotter than expected, your data is trashed because it saturates † producing a harsh clipping. So you need to carefully set the headroom to give you as much space at the top as you need, but without wasting too much. Stressful. With floats you get infinite headroom. Conventionally PCM audio is represented as -1.0 to 1.0, but in float space if you're "too hot" by a factor of literally 1000, it's no problem at all, floating point numbers can go from -1000.0 to 1000.0 just fine, and when you're ready to actually listen to it, just multiply them by 0.001 (this is called "gain" in audio). † Or, if the programmer doesn't understand what they're doing, it wraps and sounds like complete nonsense. This is common on 1980s home computer audio setups.
- jqpabc123 4y agoDon't get me wrong --- there are perfectly valid use cases for floats --- and it sounds like you may have one. But these valid uses are a lot less than what I see in a lot of software.
- ttoinou 4y agoSaid every developer who has ever applied floats where scaled integers would be just as effective. Floats are great to prototype quickly and get a good result. Once the algorithm is found, you can spend more time fine tuning with improvements such as others kinds of ways to represent fractional numbers
- pclmulqdq 4y agoThat's not why audio processing software uses floats. Floats are used because they effectively let you decouple scale from precision. With scaled integers, soft sounds only have a few bits of precision, while loud sounds are very precise. With floats, every signal is within 1 bit of precision of each other, regardless of volume. That means you can raise and lower the volume on signals over and over without significant precision loss.
- tialaramex 4y agoWhat part of what I wrote do you think you're disagreeing with ?
- pclmulqdq 4y agoThe part where you said that floats were used because it was easier. It has definite benefits for audio quality to have higher dynamic range in your numerics. Edit: You said it was nicer, not that it was necessarily easier. They are synonyms.
- tialaramex 4y agoI'm sure you believe I said "floats were used because it was easier" but I didn't, which is why if you go look at the comment you replied to that's not what it says.
- tialaramex 4y agoOK, now you've edited your reply to say you believe "nicer" is a synonym for "easier". But, it's just not.