Can volume change percision

Status
Not open for further replies.
I may be misguided here in the way the Teensy handles volume. But I am imagining two ways it could be done:

1) Volume is tracked independently as a property of a audio block, in this case the data of the audio block is unaffected by this until it is output.

2) Volume is enforced by multiplying data by a multiple, for example volume=0.5, data*0.5.

In the first case as long as any custom code written takes this into account, I see no issue. In the second case I see an issue. If the volume is 0.5 this effectively limits the possible values of it to half the possible values, and rounding will lose tons of data. This seems like a glaring issue that must have been handled so is it safe to assume the volume is tracked independently in the audio blocks and applied in some other way?

Best wishes
 
Upon further inspection, it seems it is multiplying by the in the mixer. Imagine I were to set a gain of 1/INT16_T_MAX then a gain that got me back to full volume. Would I not have lost all the data except for the sign effectively reducing this to 1 bit data?
 
Yes, its basically 16 bit fixed point throughout the Audio library, so you have to manage the gain structure carefully. If it were floating point
that would not be needed, but on some Teensy's it would be much slower... The basic rules for good gain structure are "don't attenuate
then amplify" and "don't amplify and then attenuate".
 
Status
Not open for further replies.
Back
Top