Saturday, July 07, 2007

I spent nearly the entire week dithering...

If you'll pardon the horrific pun...

Obviously a mastering limiter has dithering. Right?
So, naturally we wanted to provide the best dithering in the world, because that's just what we do.

This is really interesting, go do this:
http://www.24-96.net/dither/

It's very cool. However PLEASE DO HEED THE WARNING ABOUT LISTENING TO IT QUIETLY! :)
As many people have pointed out, the psychoacoustics behind dither rely on your hearing perception spectrum changing with volume, so unless you try it nice and quiet, you won't learn much from it.

That said, I tried it out at a higher volume... and I gotta say, things didn't change TOO much! The order of "goodness" remained -roughly- the same for me, the best stayed the best, at least... and that's MegaBitMax. The Waves IDR(/POW-R, for that is what it appears to be) comes a good second... but MBM definitely has it.

I stumbled onto (literally found by accident) the coefficients for the POW-R3 dither (yeah, they're on the net in some sourcecode! Weird!).

I spent the start of the week figuring out how dither works. Today, the maths all made sense, arranged itself in my brain, and fell into place. I now have all the dither you want... :)

So, first up, I ought to start with the background... why do we dither things, how does it work, why, etc.

Well, we're going to reduce bit-depth to fit it onto a CD, and whatever we do to get rid of those excess bits is going to generate some form of distortion. That distortion sounds bad. We want to get rid of it.

Step1: Add some noise. If the noises is louder than the distortion (which is actually quite quiet), you won't hear the distortion.

Good one. A little noise, and the distortion is gone.

Now we have this extra noise that we don't want... so..

Step2: Maybe, with some feedback, we can filter the noise and make it less audible.

Bingo! now, we've hidden the distortion under some noise... and then we hid the noise! ACE! :D
Does it get any better than that?? This is the magical thing about noise... you can bend it - so we fold it out of the way to places we can't hear!

"How is this all psycho-acoustic?"

Easy! We want to get rid of the noise where you can't hear it. Psychoacoustics tells me about where your hearing isn't very sensitive... so... I EQ it away from where you CAN hear, and towards where you CAN'T hear... there are curves for this sort of thing, and all you need to do is invert that curve and you're home and dry... maybe...

"Really?"

Well, actually no! You're not! If that WAS completely true, POW-R3 would sound better than MegaBitMax. But it doesnt, does it? How strange! So... there's a little bit more going on than psychoacoustics wants us to know about... but hey we can experiment and get it right.

"The way you're describing all this, it makes it sound like this is just about some EQ settings"
Well... that's the magic, it really is. Go find Alexey Lukin's page on dither, grab the pdf
(here: http://audio.rightmark.org/lukin/dither/dither.pdf)

see... curves! Magic.


"Is this really the only way to do it?"
No, but it is the best way.
We have a number of other options that we could explore, which I shall detail here:

1) We could not add dither noise.
Sure, and then the distortion comes back- that's the only reason we're doing this.

2) We could just shape the noise but not the quantize error
Sure, and then you'll have noise which isn't masking the error in the most sensitive part of your hearing.

3) We could just shape the quantize error but not the noise
Sure, but if you just want to add loud noise, why not record onto an old tape?

4) We could change the EQ to follow the shape of the music, and hide the noise in places that are loud so it's masked!
Good idea, but there are some real problems here that you must pay attention to: First and foremost, we add noise because it is specifically uncorrelated to the signal - if it WAS correlated, it would be harmonic distortion (that's the definition). Now, if you're planning to change the filter coefficients depending on the signal, then not only is that a time-variant filter (where you'll either be changing the curve too slowly to be useful or too quick, and making bad noises - it's a fine line and not a fun game) you would actually be adding in a correlated change - so you'd actually be adding in more distortion. It's possible that a strategy based on this might one day find the balance with the time-variant filter and allow you to blend between distortion and noise, but it's a very complicated task, and you really wouldn't be gaining anything. (Although it would make for a very interesting paper.)

So, with these decisions fixed, made and justified, my task was reduced to finding a way to generate the perfect dither response. The literature hints at it, but the answer is obviously an optimised Levinson-Durbin recursion since the problem can be resolved to solving a set of
simultaneous equations with a symmetric Toeplitz matrix. I can do it in realtime now :)
I've been A/Bing with the POW-R3 and MegaBitMax, and what I have here sounds at least as good;
I've reduced the problem down to calibrating one number, which is mad really. I think the final
answer will be about 2.2. ;)

I'll get some samples up sometime :)

[I will concede that finding the one number that tweaks it just right was a stroke of luck.. I've seen no reference to it in the literature.]

9 comments:

Anonymous said...

Very interesting - I have never even heard of MegaBitMax until now - where is it available?

Would love to hear your opinion on Ozone's MBIT+ as well - I just got a hold of this (as used in WaveEditor) and some people are saying it's f-in' excellent. Haven't had much time to play yet, though - I'm a POW-r guy for the most part (I like POW-r2, personally, but 3 sometimes bests it depending on the source material).

I also have access to the standalone IDR (as shipped in the Musician's Bundle) and WaveArts Final Plug... I tend to use those much less, however, if ever. IDR is a fairly recent acquisition, mind you, and if you're saying it's same/similar to POW-r then I might just leave it on the shelf.

Dave Sonalksis said...

MBIT+ = MegaBitMax.

Whether IDR is identical to POW-R, I do not know... However, from graphs, they look identical, and I don't remember hearing a difference. Do try for yourself though! Don't take my word for it! :)

Anonymous said...

Am I crazy or am I actually hearing different dithering methods affecting transients, even in very loud, over compressed music, in different ways? I've been switching in and out of several types of dither (basic TPDF, gaussian dither, waves IDR, apogee UV22HR and iZotope Ozone Megabitmax+) and so far the results do seem to be different. Sometimes surprisingly different! Main "victims" of worse vs good dither seems to be closed hihats, snares, the initial "click" of a kick etc. Tambourines and shakers don't seem to like some dithers either..

iZotope Ozone has been on my "to buy" list for ages now, mainly because of the limiter and the megabitmax dithering. Maybe I should wait a while and see what Sonalksis can deliver, no? :-)

Cheers!
bManic

Anonymous said...

By the way.. I'm a bit worried about the "harm" that crossover filters can do to very delicate music. Could you guys consider giving the user an option of only using your limiter in a "broad band" way instead of split band? Maybe by disabling all the cross over points? Or just a simple button?

I mean, it would be a slight shame to "cripple" a nice limiter algorithm by only allowing it to work in multiband mode.

Cheers!
bManic

Anonymous said...

I agree with bmanic.

Or why not to release 2 plugins :

A classic single band limiter, and a full featured multiband limiter.

Anonymous said...

I read a lot 'bout dither and it came to me that, if the algoritmh used generates the same "round numbers" in each side of the stereo track, and algorithms are nothing but known and repeated formulas, you would probably cause you stereo image to go worse, because the same numbers are appearing 44.100 times a second in both sides, right? Different algorithms are used in both sides, or just the fact that almost never the material in both sides will be the same puts my theory away? Have anyone think about it? Or, it's a known issue and it's already solved?

Anonymous said...

Any news on the multiband limiter plugin? Dave, you still alive? :)

Please take a read and a listen to some of the examples from this thread:

http://www.kvraudio.com/forum/viewtopic.php?t=190096&postdays=0&postorder=asc&start=45

Kilroy has a good point about hard-clipping the ADC (analog to digital converter) way versus limiters ala Waves L1/L2 etc.

No company, except iZotope, has developed any musically useful hard clipping algorithms. Please consider this possibility and try to get your hands on a Lavry gold AD converter and listen to how it clips things when pushed. It's apparently much more transparent than any limiter plugin.

Cheers!
bManic

Anonymous said...

http://www.kvraudio.com/forum/viewtopic.php
?t=190096&postdays=0&postorder=asc&start=45

The link got cut off so here it is again split into two lines.

Cheers!
bManic

Dave Sonalksis said...

eeeenteresting...
btw, don't worry about anything ruining anything... we have all that mapped out already...