Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Can volume change percision

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    14

    Can volume change percision

    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

  2. #2
    Junior Member
    Join Date
    Jul 2020
    Posts
    14
    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?

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    469
    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".

  4. #4
    Senior Member
    Join Date
    Jun 2018
    Posts
    134
    Quote Originally Posted by MarkT View Post
    If it were floating point that would not be needed, but on some Teensy's it would be much slower...
    Floating point library here: https://github.com/chipaudette/OpenAudio_ArduinoLibrary

    It doesn't show up on google searches very well yet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •