[Stk] voicer->tick() returns clipped audio

Perry Cook prc at CS.Princeton.EDU
Sat Aug 22 12:47:31 PDT 2015


Oops, I see that you are on iOS.  So I guess the overload problem
is there as well as Windoze.

PRC

On Aug 22, 2015, at 12:41 PM, Perry Cook <prc at CS.Princeton.EDU> wrote:
> 
> 
> That wasn’t in voicer’s original design, so it’s up to you
> to manage gains.  Turns out it’s not necessary on Macs
> (this is built into the audio subsystem in OS X), but Windoze 
> and Linux it is necessary.
> 
> Actually what you’re doing is clipping (forcing square tops
> onto anything over 1.0).  The audio subsystem is probably
> wrapping (making large negative numbers out of numbers
> greater than 32767, and visa versa), which totally sounds 
> horrible.  Clipping sounds nicer, but something softer than
> that is even better.
> 
> For this reason, we added Dyno (dynamic range processor
> object) to ChucK.  You might consider going to the ChucK
> source and grabbing that object and adding it to your STK
> build.  (Gary, we should do that as well…).
> 
> PRC
> 
>> On Aug 22, 2015, at 11:07 AM, Patrick J. Collins <patrick at collinatorstudios.com> wrote:
>> 
>> Another problem I have found is that the voicer is not doing anything to
>> stop the mixing of multiple instruments' audio from clipping.
>> 
>> For example, if I output a whole bunch of random noteOn events, I see
>> voicer->tick() will actually return values greater than 1.0f or less
>> than -1.0f...
>> 
>> In order to prevent clipping in my app, I am having to do:
>> 
>>       float sample = voicer->tick();
>>       if (sample > 0.99f) {
>>           sample = 0.99f;
>>       } else if (sample < -0.99f) {
>>           sample = -0.99f;
>>       }
>>       buffer[i] = sample * (1 << 15);
>> 
>> I would think the voicer should be taking care of this internally and
>> never return anything that would potentially be distored.  Is there any
>> reason for this?
>> 
>> Patrick J. Collins
>> http://collinatorstudios.com
>> 
>> _______________________________________________
>> Stk mailing list
>> Stk at ccrma.stanford.edu
>> https://cm-mail.stanford.edu/mailman/listinfo/stk
>> 
> 
> 
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/stk




More information about the Stk mailing list