DitherFloat
TL;DW: Look down. Look up. Your plugins are now dithered to 32 bit floating point :D
This began as a challenge. A forum poster said you couldn’t dither floating point outputs, and posted a link to a study explaining why.
Floating point (including the kind that fits between every plugin in a mix on MacOS or 32-bit bussed VST) has fixed point math of the kind one needs to dither, in a part of the number called the mantissa. (64-bit VST has it too, just more finely grained.) It’s not all that hard to work out how to apply dither to this part. You scale it up or down according to the part of the number called the exponent.
The trouble is (a) it’s hard enough getting people to dither to 16-bit CDs, and (b) the argument is that the amplitude of the dither would fluctuate madly, making it unhelpful and incorrect. This is kind of like how flat dither isn’t correct: with only one noise source what happens is, the noise floor fluctuates according to the waveform causing a kind of distortion. If you have a low sine wave you’ll hear the ripple effect of flat dither, and the argument is that dithering floating point is like that only more so (and so, nobody ever tried).
DitherFloat demonstrates this, and it’s not true. You can TPDF dither (even PaulDither, like I’m using here) floating point. The noise doesn’t fluctuate according to the waveform represented in the mantissa. It fluctuates according to the value in the EXPONENT, because it has to, because the quantization noise also fluctuates wildly in volume. And if you get it right, you end up with no truncation distortion at all, just like using TPDF to fixed point.
The video explains more and shows it working. It’s practically impossible to hear ONE stage of 32 bit truncation (may be literally impossible, I think) but you can cheat and hear it as obviously as you like. You just add a huge offset to the number, convert it to float, and then subtract the offset again: and that’s what DitherFloat does. It’s a demo. It shows you there’s still truncation in floats, and it shows you the way TPDF dither completely removes the truncation distortion. It linearizes the signal so that no trace of the truncation is present (that’s how correct dither works).
You can’t add DitherFloat after existing plugins to fix them: even though you can use it (with zero offset) to export a 64 bit buss to 32 bit float and dither it, by itself DitherFloat can’t fix existing plugins. You would have to put the code for the dithering, into every single plugin that outputs 32 bit floats. Every MacOS plugin, every singlereplacing VST (every older VST implementation before they implemented 64 bit buss). For the Airwindows library that would involve personally revising every plugin I’ve released under the VST/Patreon years, many hundreds of plugins.
So I did. :D
See the video, and to update everything you have, download NewUpdates.zip to drag and drop the whole collection (or whatever subset of it you use) to your plugins folder. Each individual plugin package has also been updated for people who download them one at a time, or find them through search. The only exceptions are plugins that are already dithers, or things like DCOffset and BitShiftGain that are meant to work with the direct sample values (BitShiftGain is purer than even 32 bit dithering: it literally changes only the exponent and leaves the mantissa always exactly as it was, only at a different gain scale, so it’s cleaner than even PurestGain). (if you need to roll back for any reason, BeforeFPDither.zip is the previous version, untouched)
It’s free. Go ahead and use all this. I don’t have to put any barrier in your way. Update the plugins for free, read the source code on my github page, and the new code is this, intentionally dual licensed in addition to my MIT license.
//This is free and unencumbered software released into the public domain.
uint32_t fpd; //this goes where fpNShape went, but it's an unsigned int used for the random generator
fpd = 17; //the random generator is xorshift32 which can't start off with zero.
//then in the actual processing code:
int expon; frexpf((float)inputSample, &expon);
fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5;
inputSample += (fpd*3.4e-36l*pow(2,expon+62));
//Anyone is free to copy, modify, publish, use, compile, sell, or
//distribute this software, either in source code form or as a compiled
//binary, for any purpose, commercial or non-commercial, and by any
//means.
//In jurisdictions that recognize copyright laws, the author or authors
//of this software dedicate any and all copyright interest in the
//software to the public domain. We make this dedication for the benefit
//of the public at large and to the detriment of our heirs and
//successors. We intend this dedication to be an overt act of
//relinquishment in perpetuity of all present and future rights to this
//software under copyright law.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//OTHER DEALINGS IN THE SOFTWARE.
64 bit version for hilarious overkill is almost identical but with small changes in frexp() and the constants. This is now a sort of mad community effort, so that becomes public domain too:
//This is free and unencumbered software released into the public domain.
uint32_t fpd; //this goes where fpNShape went, but it's an unsigned int used for the random generator
fpd = 17; //the random generator is xorshift32 which can't start off with zero.
//then in the actual processing code:
int expon; frexp((double)inputSample, &expon);
fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5;
inputSample += (fpd*6.4e-45l*pow(2,expon+62));
//Anyone is free to copy, modify, publish, use, compile, sell, or
//distribute this software, either in source code form or as a compiled
//binary, for any purpose, commercial or non-commercial, and by any
//means.
//In jurisdictions that recognize copyright laws, the author or authors
//of this software dedicate any and all copyright interest in the
//software to the public domain. We make this dedication for the benefit
//of the public at large and to the detriment of our heirs and
//successors. We intend this dedication to be an overt act of
//relinquishment in perpetuity of all present and future rights to this
//software under copyright law.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//OTHER DEALINGS IN THE SOFTWARE.
It’s not complicated but it’s my own code and it’ll work: it’s even pretty easy to drop into other plugins. If anyone’s game to do that and shout out that they did, I’d love to hear about it.
If they don’t, they will just continue adding a little truncation with every single plugin, every single calculation, and now none of MY plugins do that :)
If you like me being able to discover something like this, becoming determined to explore it, discovering that it’s a huge upgrade and implementing it into every (relevant) plugin I make, and then giving it to the world even more than I usually do, please support my Patreon. I like days like this. I like helping the industry (to the extent it’s willing to be helped, which is always a question) and advancing the science of digital audio, and I especially like making demos where it’s plain to hear what’s being done under the hood. And I wouldn’t be able to do it if not for Patreon, which doesn’t make as much money as commercial work (I’m still very poor) but it’s steadier, and it lets me give these tools to ALL the musicians whether they’re broke or not :)
Thank you and good night. Next up is Pafnuty, next week.
amazing! will check that out right now. airwindows have replaced all but EQ on my mixbuss. buttercomp 2, spiral, acceleration etc. great stuff, thank you.
Hi Chris,
With your new implementation of Dither we can now all enjoy the “Analogue world” of Digital,
large sound stage, detailed sides, dynamic and involving music without the fatigue of the Digital undertones.
PS. Just try this, it’s that good.
T.
hello I want to comment my experience, I had decided to experiment on an mpeg4 file, with a cut over 10.8khz, no daw, only voicemeeter and mini host with 96 24 onboard audio asio hi fi virtual cable. I only apply ditherfloat offset 4 dither 0.730000 and it’s fixed. Thanks for everything you do for the audio.
Bravo Chris!
now that’s great! :)
this is the correct way to deal with 32bit float! calculations on the audio have to be dithered there also. i only know of one daw that already does this since the beginning. it is samplitude by magix. in their 32bit float audioengine, gainchanges etc. are dithered to 32bit float.
probably that is why it was always revered for its good “sound” (if you want to call it that ;-) )
thanks chris!
Chris: I am so sorry for my Reddit mistake. I posted public apologies in an attempt to clear your name from the damage that I did.
Sincerely,
David Pixley theMuzzl3
I know this is a bitcrusher but Slew2 0.250000 + Ditherfloat Offset 1 Dither 0.500000 experimenting on an mpeg4 with cut at 10k give back nice controlled artifacts.
… and now the noise “floats” around peoples projects … :-)))
the offset is a cool thing together with dither strength
Hello Chris, can you tell how to Swell without being gated? hope you can talk on next QA and topic this, and which plugin/ how to run 64 bit depth just to use ditherfloat offset1 dither 1 before?, Thanks!
i have found some explanations here https://cycling74.com/forums/64-bit-sound
it has nothing to do with ditherfloat but it does give me some notions about
full path 64 bit
i have found this a little helpfull for what i want to ask to you and the possible answers it has nothing to do with dither float but it does give some notions about 64 bit full path
https://cycling74.com/forums/64-bit-sound
might has nothing to do with ditherfloat but it does about,
please sorry, im a little distracted, but im asking for run 64 bit full path even if i want to dither or not but how to convert the signal into with your plugins
maybe if i am loading from 16/24 bits additional bits are pointless, and also maybe im running out of memory a lot faster, i think might i need a jitter solution? or maybe i dont need to dither from 64 to 32 because ill getting noise or no matter what 64>32 bit conversion will not even be audible?. altought i im not sure if your new updates truncates or rounds, the latter might be console4buss… what i get when i load swell treshold 1 swell 0.9 drywet 1 im getting spikes of grittness and even worse if i add more purestgain= quantization errors at 64? and that is why your plugins are32 bit float
I don’t understand what you’re asking, but my plugins now dither to 32 bit if they’re running on a 32 bit buss, and they dither to 64 bit if they’re running on a 64 bit buss. And if Swell isn’t working out for you, you should try some other sort of plugin: Swell takes away the attacks of things, and I don’t think it’s meant to create spikes of anything.
yes, sorry, I’m not degrading swell, just something crazy happens and when I apply it I get a 64 bit readings in a free plugin called bitter, and at the approximate time it would be threshold 1 swell 0.500000 more or less and I get only attack from things do not spikes as I gave to understand before to overcome the threshold add purestgain and the effect was more pronounced, not worse as I wrote previously, that is, I do not deny that I’m using swell for something that is not done, but I was surprised see what could have those readings with my buss of 32. then the question is that if there is the possibility of having those bit depth readings, without the attack effect, combining some of your plugins. then then I thought about doing to have the constant 64-bit stream and then deciding whether to use ditherfloat offset 0 dither 0.01000000 or dither to 24 bits with offset 1 my bus is 32 although I’m using vst 64 in a 64 environment with a 64 processor , then I was also asking if a jitter plugin you could do, to listen to or temporarily store in 64 as suggested in the link that I posted here, but it’s not for anything special but to understand myself and about the 64 bit stream and to not make me the wise man. but as it did not appear and I remain posted several times
to clarify more with what I want to say that I would like to explain or do for us the uneducated students in broken banking in countries that do not exist the culture of the audio neither to six hundred kilometers around: is not that I ask you to explain basic topics about 64 bit audio in your Q&A because that’s what the internet is for and here y and is plenty of people with this guesses I can put some sites where I found relevant information to and to mitigate the lack of information and the lack of friends to discuss.
https://www.youtube.com/watch?v=ptzGI9VaZmQ (might be funny, but for a start)
https://www.soundonsound.com/techniques/32-bit-64-bit (this is about not mix up)
https://www.kvraudio.com/forum/viewtopic.php?t=35748 (this is very good expl.)
https://www.gearslutz.com/board/music-computers/705094-does-64-bit-summing-yield-noticeably-better-output.html (this is cool, but is full of rants)
https://cycling74.com/forums/64-bit-sound (this is cool)
https://en.wikipedia.org/wiki/Audio_bit_depth (Wow, brillant)
https://es.wikipedia.org/wiki/Mantisa (and More WOW)
What I would like you to explain is something that does not exist for now in any place and many people in all the sites could think that is not possible because it clearly would not exist within the parameters of this information and it would not enter their minds either, and it is like doing to roll audio in 64 bits on a buss of 32 since I hear it is possible with your plugins, and this would be a case similar to ditherfloat where the impossible becomes a tangible reality, it would only be necessary for the master of the puppets :) to decide to give us a solution, and if you do not want to do it, well in the future teach us how to program and for sure we will do it, or well keep us in the line of nescience but make it possible. Best Regards from me to you, and for all the guys up there like me.
one more last thing for the moment: do you accept moneygram? i dont have bank account
well, and here is my screen http://i68.tinypic.com/zui61u.png
Best regards
…to send money through moneygram is not necessary an address but rather the name and country of both sender and receiver then a code and an identification is necessary to withdraw the money.
so, these guys,freed innmates, terrorists with AK 47 machine guns and handkerchiefs on their faces were reading the messages here and waited until I showed up in class to fuck the balls. let’s wait for them next week to invade the classroom, as was recorded in the chat, is not intended to talk about politics or sexuality in an audio class, better must go to the border to do what they do best, create self-deluded states of monkeys with knives to kill soldiers. I hope your president nuke them.
This thing is a weapon. Great job
Genial demo.
Hi Chris. I have to say yours are the best plugins out there on Linux by sound :)
I have some questions:
1) If a plugin makes multi-stages calculations, should it apply your ditherfloat algorithm before/after every stage of its calculations to have to less truncation? Am I wrong?
2) If I want to add your float dithering code to an GPL licensed existing plugin, Can I do that? Are there any license problems? Do I have to add your license header to the existing plugin? I’d love to see it on my favorite DAW [Ardour](https://ardour.org/)’s built-in plugins.
Thank you if you want to answer my questions :)
Plugins should run a higher internal buss than 32-bit: some would say double (64-bit) is already high enough that dither becomes completely irrelevant.
You can use MIT-licensed stuff in a GPL program if you give credit as the MIT license requires. You can’t use the GPL stuff in an MIT-licensed plugin because that license is more demanding, so you can take anything of mine and use it in GPL stuff and then I can’t have the GPL side. So any license problem is only on my end and limits only me :)
[…] FloatDither:AirwindowsのChrisが開発した32bitディザリング […]
Hi
I want to use Ditherfloat to add it to a DSF file conversion to make a CD. I don’t know which audio converter software is compatible with your plugin .
Thank you for your answer
Best regards
Thanks for this great idea and plugin, I really appreciate it. I am wondering, though, why is this generating harmonic distortion at all? Isn´t it supposed to just add a noise floor for the dithering?:
https://i.postimg.cc/W25GrL2R/Untitled.png
Thank you.