Triangular Probability Density Function Dither, How does this random number exaclty work 
Triangular Probability Density Function Dither, How does this random number exaclty work 
Dec 31 2003, 04:52
Post
#1


Group: Members Posts: 22 Joined: 31December 03 From: Warwick, UK Member No.: 10830 
Hello everybody,
THis is my first post on this site. NIce to find a forum for this field which I am interested in and studying. So here is the problem... I need to write in C, a program that will dither and truncate a 16 bit stereo file to a 14 bit stereo file. It is for an assignment for university basically. I more or less have the idea of how it works after having read several books and websites. However here is the problem/question. To go from 16 bit to 14 bit and add dither before truncating it is necessary to add 3 bits of noise to the 16 bit original signal. 3 bits can have the maximum value of 8. In audio Terms 4 to +4. Correct so far? Now if i generate a random number between 0 and 8, I can't just add that number to the 16 bit stream right? Becuase I need to add a +4 to 4 range number. It that correct? and if it is, how can I generate a random number between +4 and 4 in C? int a = rand() % 8; this would give a random value between 0 and 8. BUt how do i set a lower and upper limit for the random number to be generated? Well, at this point this is all i will ask. I have a feeling this is somehting really simple and for some reason I have been stuck on it for some time now. Thank you in advance for reading it and hopefully replying. In the meantime, Happy New Year everybody! PS: Oops..i just realised it was moved from general audio to Scientific..Sorry..i am new ..i thought this was a simple question and thats why i put it in General audio. This post has been edited by aristotel: Dec 31 2003, 05:02 


Jun 16 2005, 14:50
Post
#2


Group: Members Posts: 24 Joined: 14April 05 Member No.: 21432 
Sorry, guys, I've only just seen the thread and haven't read all the way through it. The bit depth of the dither is not "2 bits" but rather "2 quantization steps" (of the remaining quanta). 2 bits implies the options of 00, 01, 10, and 11. 2 quanta implies 00, 01 and 10. The dither must be of triangular probability within this range. The way to generate the dither is to generate one bit's worth of random values twice, so:
Random value between 0000 (bits 13 through 16) and 0100. Do this twice and add them together. You now have TPDF dither of 2 quanta in amplitude (not 2 bits). The result will be some value between 0000 and 1000 with the greatest likelihood that the number will be 0100. To the person that asked, this is precisely the amount and type of dither needed in order to completely remove quantization distortion (or rather turn it into noise). This has been mathematically proven and you can find these proofs in the writings of Lipshitz and Vanderkooy. I hope this helps? Nika 


LoFi Version  Time is now: 25th November 2015  06:59 