BitShiftGain
TL;DW: The ‘One Weird Trick’ perfect boost/pad, with a catch!
Just when you thought we were done with gain…
In order to support the next set of Airwindows plugins, which are dither plugins both common and bizarre, here is one final trick for clean gain aficionados.
Turns out the only way to get cleaner gain trim than PurestGain, with its high mathematical precision and noise shaping… is not to do any of that. No fancy math, no noise shaping or dither. Just a very narrowly defined boost or cut, in the form of a ‘bit shift’.
Doing this means your waveform is scaled up or down by increments of 6 dB exactly. No 3 db, no 9, no 7 or even 6.001! Only 6 or 12 or 18 and so on, up or down. Select the number of bits you want to shift, and BitShiftGain applies the exact number, not even calculating it in floating-point through repeated operations: from a look-up table to make sure it’s absolutely exact and precise.
And when it does, all the bits shift neatly to the side inside your audio, and whether you lose the smallest and subtlest or gain up and fill it in with a zero… every single sample in your audio is in exactly, EXACTLY the same relative position to the others. Apart from the gain or loss of the smallest bit, there is literally no change to the audio at all: if there was a noise shaping, it would have nothing to work with.
Perfection, at exclusively increments of 6 dB. That’s the catch. You probably can’t mix with gain changes that coarse (though it’s tempting to try!) but here’s what you can do: you can take 24-bit dithers, gain down 8 bits in front and 8 bits up after, and have a perfect 16 bit dither. Or a 17 bit, if that pleases you… or shift 16 bits down so you can hear what your dither’s noise floor acts like (we’ll be doing lots of that when I start bringing out the dithers). +-16 bits of gain trim is a very big boost or cut. The overall range of BitShiftGain is huge. But the real magic of BitShiftGain is the sheer simplicity of the concept. Provided your math is truly, rigorously accurate and your implementation’s perfect, gain trim with bit shift is the only way in digital (fixed OR floating point) where you can apply a change, and the word length of your audio doesn’t have to expand, AND every sample which remains in your audio continues to be in exactly the same relation to all the others.
Digital audio is like some crystalline structure: it’s fragile, brittle, and suffers tiny fractures at the tiniest alterations. There’s almost nothing you can do in digital audio that’s not going to cause some damage. But as long as you stick to 6 dB steps and rigidly control the implementation (BitShiftGain doesn’t even store the audio in a temporary variable!), you can chip away at that least significant bit, and the whole minutes-or-hours-long crystalline structure of digital bits can remain perfectly intact above it.
BitShiftGain is free, of course. It’d be weird even to consider charging for a position on every DAW’s fader. But if you like knowing that I’ve brought you a refined and super-strict version of this magical perfect-gain trick, as AU and VST, and especially if you’ve learned something through it, please support my Patreon. My job is working out this stuff and bringing it to you in plugin form, even (or especially!) if it seems like not the most commercially trendy plugin ever seen. Your job is to pitch in a buck a month (or more if you like) and find other people who can spare a small totally voluntary contribution, and keep ME on the job. :)
Bravo! Only Airwindows would provide us with such wonderful tools.
This is the best thing ever. I print the mix at -12dBFS (I feel like it sounds better than if I were to record hotter or even clip the converter) and need to normalize it ITB. Even PurestGain messes up the sound a little, but it’s better than the default gain plugin in my DAW. I can hear the mix falling apart and it’s a shame because I spend lots of time trying to make it sound cohesive by means of a summing mixer and whatnot.
“Digital audio is like some crystalline structure: it’s fragile, brittle, and suffers tiny fractures at the tiniest alterations.” Turns out it’s even more fragile than I thought. BitShiftGain is a lifesaver, thank you.
Isn’t it actually 6.02dB per bit?
Doh! :)
Hi Chris,
Loading BitShiftGain into DDMF’s Metaplugin – AU to AAX wrapper generates an error message. It suggests it to be related to BitShiftGain not being 64bit. Do you know what might be the cause? (I’m also wondering if loading BitShiftGain into the Metaplugin would actually defeat the point of the minimalist approach all together…) Anyway I have had no problems with any of the other Airwindows plugins I have tried or use.
[…] https://www.airwindows.com/bitshiftgain/ […]
I cannot get the AU version of this to come up using the Mac. Anyone else have this problem?
Got it working now!
this one is special.. it has become one of my main mixing tools. thanks chris.. i never heard of this before.
but extremely dangerous i gotta say if you knock that slider wrong you get blasted.
best luck with creating!
I can’t understand how the exponent and mantissa are not affected by this, wouldn’t it need a non-floating point number for this to work?
Chris, that is stunning.
Thank you.
I figured out doing… gain = 2 ^ ( Slider# / 6 ) and setting slider# to multiples of 6 gives this behaviour in JSFX for Reaper. Then multiply gain and input to get output. (turn off denormal to see it work on a scope)
Saved my bacon. Recorded to a master recorder in DSD, which actually sounds best when the peaks hover near -12db or so, then converted to PCM. Worked in Pro Tools using clip gain and cross fades, then tried boosting by 12db using various methods, none of them transparent. Simply setting the fader in PT to +12db markedly changed the sound for example.
Ended up just committing the stereo track to 32bit float, cutting it up into separate clips, and using Reaper batch convert with bitshift gain. At first it didn’t quite sound right, but that was because I was trying to dither after bitshift gain. Once I put airwindows tpdf *before bitshift gain it was happy days again. Had to get rid of that pro tools crud first, instead of making it louder and trying to dither a bunch of zeros :P