[chuck-users] Heavy distortion/clipping in Windows

Perry Cook prc at CS.Princeton.EDU
Thu Feb 19 12:59:32 EST 2015

Ack!  This is a common problem, and I thought I had caught all of
the clipping/distortion cases on Windows/Linux with our last 
passes on checking the source code.  I'll check it all again and
put it in our Errata file for future ChucK/Mini releases, and future
printings of the book.

As others have noted, the solution is to scale the output gain of 
all of the components, but just by the amount necessary to get 
rid of the clipping.

I'm also going to give you a non-state-approved but useable
quick solution.  I really don't recommend that people get in the 
habit of doing this, but it's possible to set the gain of the global dac

0.4 => dac.gain;

is legal, and works.  It's also global and persistent, so you only
have to do it once in one place and it sticks for all other, and 
subsequent code that goes through the dac.

This is a really quick way to get rid of clipping if you have it.
Set it to 0.8 or 0.6 or 0.5 or whatever gets rid of the distortion.

Once you've figured that out, I'd recommend going back and
scaling the output of all of the contributing components (the 
different players in the jazz band in this case) by that amount.
Then you can set dac gain back to 1.0 where it's supposed to
be and delete the line that sets it to anything other than 1.0.
You could also delete the line that sets dac gain, then stop/restart
the VM.  That resets it to 1.0 as well.

Another possible solution if you have only one file that's clipping
a little is to put a Dyno object just before the dac.  It's set up by 
default to help limit output to try to avoid clipping.  But in this case
where you have multiple instruments, putting a Dyno on each one
wouldn't help, because their aggregate outputs mixed inside the
dac would still clip.

Hope this helps, and sorry for the confusion.


More information about the chuck-users mailing list