[chuck-users] dithering with chuck

Ge Wang gewang at CS.Princeton.EDU
Tue Dec 12 11:16:03 EST 2006


Hi all!

Yet another solution: instead of dealing with floating point numbers, 
simulate the quantization using fixed point integers.  Here is a 
quick-and-dirty example which casts the output of an arbitrary UGen 
into int, simulates quantization by throwing away extra bits, and 
optional adds dither (before the cast):

     http://soundlab.cs.princeton.edu/drop/dither.ck

You can also modify the code to send arbitrary UGen's into 
play_with_dither() to hear quantization with and without dithering.  I 
hope this is on the right track.

Best,
Ge!

On Dec 10, 2006, at 6:43 PM, Kassen wrote:

> Adam;
>
>> There is another complication. Floating point numbers aren't stored
>> the same way that integers are, they are stored as a mantissa and
>> exponent. This technique also combats the precision problem. What
>> will happen is that the mantissa will stay the same and you are just
>> twiddling the exponent bits. No loss of precision. You could
>> definitely do this demonstration in chuck, and it is excellent, but I
>> think we will have to hear from Ge, Spencer or Perry about exactly
>> how much you will need to turn the gain down in order to achieve the
>> desired effect.
>
> Yes, I think that explains what is observed. As I understand floating 
> point we could force (some) data degradation by amplifying the signal 
> by some ratio that can't be expressed exactly in the exponent, forcing 
> adjustment in the data itself. Floating point does have rounding 
> errors but I seem to remember those tend to show up in particular when 
> very large numbers and very small ones are confronted with eachother.
>
> A more practical way of demonstrating dithering might be to have some 
> generated piece and record it (in ChucK) to a wave file at a low gain 
> in order to leave headroom in case several elements decide to be loud 
> at the same time. This data would be written to a fixed point file 
> (since ChucK doesn't support floating point formats yet) After this 
> ChucK might be used again to increase the amplitude to make the 
> loudest part close to 0db at which point dithering would be usefull? 
> If we are after a demonstration that might count as a fairly realistic 
> real-world scenario, I could imagine somebody wanting to publish a 
> algorithmic piece without clipping that would be made and processed 
> entirely in pure ChucK. Personally I tend to be in favour of 
> real-world scenarios for demonstrations but this isn't my experiment 
> so maybe this isn't relevant at all.
>
> Kas.
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list