Any recommended algorithms for generating digital dither signals? How is this normally done?
Generate digital dither
Started by ●April 8, 2014
Reply by ●April 8, 20142014-04-08
On Mon, 07 Apr 2014 23:30:01 -0400, B <b@nope.com> wrote:>Any recommended algorithms for generating digital dither signals? >How is this normally done?You usually want a triangular distribution, which you get automagically by summing two independent uniforms. So you just need two independent random number generators. Note that the overall range of the sum will be twice as big, so you'd need to scale down by 2 to keep the same range. But most likely you'll be scaling down to match a 16-bit of 24-bit range anyway. The best dither *amplitude* may be subject to some debate. but is somewhere in the vicinity of 1/2 LSB. Too high of a dither amplitude doesn't reduce the effect, just makes the dither noise itself more audible. Too low an amplitude and you'll reduce or lose the effect. Note that you don't need any dither if your signal already contains more noise than this. Best regards, Bob Masta DAQARTA v7.50 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE Signal Generator, DaqMusiq generator Science with your sound card!
Reply by ●April 8, 20142014-04-08
On Monday, April 7, 2014 11:30:01 PM UTC-4, B wrote:> Any recommended algorithms for generating digital dither signals? > > How is this normally done?Are you needing one or two dimensional dithering? Clay
Reply by ●April 8, 20142014-04-08
On Tue, 8 Apr 2014 09:47:09 -0700 (PDT), claysturner@gmail.com wrote:>On Monday, April 7, 2014 11:30:01 PM UTC-4, B wrote: >> Any recommended algorithms for generating digital dither signals? >> >> How is this normally done? > >Are you needing one or two dimensional dithering? > >ClayAudio vs image? It hadn't occurred to me to specify. This is audio, so presumably 2D.
Reply by ●April 8, 20142014-04-08
On Tue, 08 Apr 2014 12:56:26 GMT, N0Spam@daqarta.com (Bob Masta) wrote:>On Mon, 07 Apr 2014 23:30:01 -0400, B <b@nope.com> wrote: > >>Any recommended algorithms for generating digital dither signals? >>How is this normally done? > >You usually want a triangular distribution, which you get >automagically by summing two independent uniforms. So you >just need two independent random number generators. Note >that the overall range of the sum will be twice as big, so >you'd need to scale down by 2 to keep the same range. But >most likely you'll be scaling down to match a 16-bit of >24-bit range anyway.I was wondering whether there were preferred algorithms, or whether the normal 'computer language library' rand() function was suitable for this. I guess there's no reason why it shouldn't be, unless I'm going for a specific frequency contour.>The best dither *amplitude* may be subject to some debate. >but is somewhere in the vicinity of 1/2 LSB. Too high of a >dither amplitude doesn't reduce the effect, just makes the >dither noise itself more audible. Too low an amplitude and >you'll reduce or lose the effect. > >Note that you don't need any dither if your signal already >contains more noise than this. > >Best regards, >Bob MastaThanks, Bob.
Reply by ●April 8, 20142014-04-08
On 4/8/14 7:11 PM, B wrote:> On Tue, 8 Apr 2014 09:47:09 -0700 (PDT), claysturner@gmail.com wrote: > >> On Monday, April 7, 2014 11:30:01 PM UTC-4, B wrote: >>> Any recommended algorithms for generating digital dither signals? >>> >>> How is this normally done? >> >> Are you needing one or two dimensional dithering? >> > > Audio vs image?i presume that's what Clay sorta meant.> It hadn't occurred to me to specify. This is audio, so presumably 2D.??? you mean the channel number is another dimension? you can do multi-channel stuff, but audio is basically 1D. image processing is 2D. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●April 8, 20142014-04-08
On 4/8/14 7:16 PM, B wrote:> On Tue, 08 Apr 2014 12:56:26 GMT, N0Spam@daqarta.com (Bob Masta) > wrote: > >> On Mon, 07 Apr 2014 23:30:01 -0400, B<b@nope.com> wrote: >> >>> Any recommended algorithms for generating digital dither signals? >>> How is this normally done?probably, for your purposes, a good linear congruence (not all are sufficiently decent) will be good enough. if you want good RNG, check out https://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators . but if you're writing efficient DSP code to do this, then you probably *don't* want to use the Mersenne Twister or something really good like that. i think a linear congruance generator with a good reputation (look at https://en.wikipedia.org/wiki/Linear_congruential_generator ) will be sufficient for good dither for audio quantization. i thought that Numerical Recipes had a few good linear congruence generators, but there might be folks here that will set me straight on that possible misconception of mine. another thing to do is to scramble up the bits (using table lookup) coming from an RNG to make the result appear even more randomized. there are also some commercial dither algs for audio mastering like apogee UV-22 that are supposed to be pretty good, but some of this smells like Monster Cable to me.>> You usually want a triangular distribution, which you get >> automagically by summing two independent uniforms.it's not automagic.>> So you just need two independent random number generators.or a single good one and just add subsequent RNs. or, for an efficient, DC-free and high-pass triangular dither, subtract v[n-1] from v[n]. where v[n] is the uniform random number from rand() or similar.>> Note that the overall range of the sum will be twice as big, so >> you'd need to scale down by 2 to keep the same range.but you don't want to do that. you want it to be 2 LSBs of amplitude.> I was wondering whether there were preferred algorithms, or whether > the normal 'computer language library' rand() function was suitable > for this.there is nothing in the rand() spec that says how *good* the RNG is. but it's supposed to be independent and uniform from 0 to however> I guess there's no reason why it shouldn't be, unless I'm > going for a specific frequency contour.except for special cases, it's hard to get a specific spectral shape and a specific PDF for you random process. it's easy to get high-pass, triangular PDF dither. or low-pass, triangular PDF dither. it's also easy (but less easy) to get white, triangular PDF dither. normally, to get the spectrum of quantization error that you want, you want to do it with error feedback, dithered or not. if dithered, i think you want white TPDF dither.>> The best dither *amplitude* may be subject to some debate.about as much debate as the Big Bang has in cosmology.>> but is somewhere in the vicinity of 1/2 LSB.no.>> Too high of a dither amplitude doesn't reduce the effect,are you making a perceptual claim? because mathematically, the dither you're promoting ain't large enough.>> just makes the dither noise itself more audible.the minimum dither you need to decouple both the mean and variance of the quantization error from the value of the signal about to be quantized, is triangular PDF of width *2* LSBs (not 1/2).>> Too low an amplitude and you'll reduce or lose the effect.yes. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●April 8, 20142014-04-08
robert bristow-johnson <rbj@audioimagination.com> wrote:> On 4/8/14 7:16 PM, B wrote:(snip)> probably, for your purposes, a good linear congruence (not all are > sufficiently decent) will be good enough.> if you want good RNG, check out> https://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators .> but if you're writing efficient DSP code to do this, then you probably > *don't* want to use the Mersenne Twister or something really good like > that. i think a linear congruance generator with a good reputation > (look at https://en.wikipedia.org/wiki/Linear_congruential_generator ) > will be sufficient for good dither for audio quantization. i thought > that Numerical Recipes had a few good linear congruence generators, but > there might be folks here that will set me straight on that possible > misconception of mine.I wrote one for converting 24 bit WAV files to 16 bit. I uses the CRC32 generator on the actual data, and then use some appropriate bits. Though the recordings that I use it on probably already have enough noise. Recorded with a live audience of kids and parents, not to mention the electronic noise in the recording system. (As I understand it, amplifiers and ADC good enough to generate 24 bit audio with 150dB S/N are pretty expensive.) But I record with 24 bits, then scale appropriately for the record level. That allows me to keep the record level just a little lower than I might otherwise want it, and avoid surprises. I tested it by taking one track and converting it with more and more bits of right shift. That is, smaller and smaller signal with the same amount of dither. Then made a CD and played it at higher and higher output level. I did with and without dither, for comparison, and could hear the difference at the lowest levels. -- glen
Reply by ●April 9, 20142014-04-09
On Tuesday, April 8, 2014 7:11:29 PM UTC-4, B wrote:> On Tue, 8 Apr 2014 09:47:09 -0700 (PDT), claysturner@gmail.com wrote: > > > > >On Monday, April 7, 2014 11:30:01 PM UTC-4, B wrote: > > >> Any recommended algorithms for generating digital dither signals? > > >> > > >> How is this normally done? > > > > > >Are you needing one or two dimensional dithering? > > > > > >Clay > > > > Audio vs image? It hadn't occurred to me to specify. This is audio, > > so presumably 2D.The 2D case I was thinking about involves imaging. If your sensor (CCD or CMOS) subsamples (relative to the optical resolution) the image field, then by combining muliple images with fractional pixel offsets, you can achieve near the resolution limit of the optical train. The Drizzle algorithm was invented to do just this. It was done to increase the resolution of the Hubble Wide Field and Planetary Camera. The dithering can result from re-aiming the telescope between exposures - this is in practice done by introducing offsets in the target position in the guidescope. Or the dithering can result from atmospheric turbulance where Drizzling can allow you to again overcome subsampling almost to the point of reaching the diffraction limit of the optics. This has been effective in mitigating the effective different sampling rates (green vs red and blue) in Bayer Filtered sensors for planetary imaging. In Bayer arrays, 50% of the pixels are green, 25% are red, and 25% are blue. Clay
Reply by ●April 9, 20142014-04-09
On Tue, 08 Apr 2014 21:32:32 -0400, robert bristow-johnson <rbj@audioimagination.com> wrote:>On 4/8/14 7:11 PM, B wrote: >> On Tue, 8 Apr 2014 09:47:09 -0700 (PDT), claysturner@gmail.com wrote: >> >>> On Monday, April 7, 2014 11:30:01 PM UTC-4, B wrote: >>>> Any recommended algorithms for generating digital dither signals? >>>> >>>> How is this normally done? >>> >>> Are you needing one or two dimensional dithering? >>> >> >> Audio vs image? > >i presume that's what Clay sorta meant. > >> It hadn't occurred to me to specify. This is audio, so presumably 2D. > >??? you mean the channel number is another dimension? you can do >multi-channel stuff, but audio is basically 1D. image processing is 2D.Oops...yes I intended to say 1D for audio. It would be stereo, but I didn't think that would add a dimension with respect to dithering.






