[chuck-users] Heavy distortion/clipping in Windows (Kassen)

Perry Cook prc at CS.Princeton.EDU
Wed Feb 25 13:43:46 EST 2015


It's even a little stranger than one might think.  On Mac OSX,
it's really hard to clip at all.  For example, this code:

SinOsc s => dac;
8.0 => s.gain;
second => now;

runs and sounds fine.  You might need to turn your master
system volume down so it doesn't blow out your headphones
or speakers, but if you do that, you will hear a pretty pure
sine wave.  The proper gain for this should be 1.0 (the
default), but it works ok up to pretty large numbers, but
only on Macs.  I haven't tried this in a VM Windoze on Mac,
and I'm not sure how the audio is virtualized in this case.  BUT

This very same code would cause hideous distortion on a Windows/
Linux machine, because those audio subsystems have a hard limit 
on the amplitude that can be sent into the dacs.  Mac seems to have 
figured out a how to deal with this in a very different (floating point) way.


>   2. Re: Heavy distortion/clipping in Windows (Kassen)
> Message: 2
> Date: Thu, 19 Feb 2015 19:44:05 +0100
> From: Kassen <signal.automatique at gmail.com>
> To: ChucK Users Mailing List <chuck-users at lists.cs.princeton.edu>
> Subject: Re: [chuck-users] Heavy distortion/clipping in Windows
> Message-ID:
> 	<CAK4G45dtCcjRuEwiVmcKRHnLcNe6S3me5__oqOOzfm20NErSsA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> On 19 February 2015 at 18:59, Perry Cook <prc at cs.princeton.edu> wrote:
>> 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.

More information about the chuck-users mailing list