Re: [chuck-users] Heavy distortion/clipping in Windows
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 object. 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. PRC
On 19 February 2015 at 18:59, Perry Cook
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.
Perry, now that you mention the OS's I'd like to share a thought. I wanted to postpone debating OS audio infrastructure because debates on OS features tends to lead to debates on OS preferences and the next step is likely to be total war and so I thought I'd try to figure out what was going on on my own. ;-) Am I correct in understanding that you are saying the files could have been made on OSX with the system audio gain set to -say- 0.5? Then ChucK's output could reach peaks of -say-1.5 , it's get attunated and be at .75 when hitting the DAC; perfectly fine. In this case the audio reaching such amplitudes at ChucK's output might go unnoticed by the file's author. Under OS's with a audio infrastructure expressed in int's a output of 1.5 at the ChucK dac would clip at 1 at hitting the OS's audio rating and the final output (assuming identical system volume) would end up at a 0.5 amplitude while being heavily clipped. Is that correct? Yours, Kas.
participants (2)
-
Kassen
-
Perry Cook