- 
                Notifications
    You must be signed in to change notification settings 
- Fork 204
Open
Description
I found bug in Audio::Gain function causing audio channel swapping and wrong balance operation.
The correct function should look like this:
int32_t Audio::Gain(int16_t s[2]) {
   int32_t v[2];
   float step = (float)m_vol /254;
   uint8_t l = 0, r = 0;
   if(m_balance < 0){
       step = step * (float)(abs(m_balance) * 16);
       r = (uint8_t)(step);            // bugfix
   }
   if(m_balance > 0){
       step = step * m_balance * 16;
       l = (uint8_t)(step);            // bugfix
   }
   v[LEFTCHANNEL] = (s[LEFTCHANNEL]  * (m_vol - l)) >> 8;
   v[RIGHTCHANNEL]= (s[RIGHTCHANNEL] * (m_vol - r)) >> 8;
   return (v[RIGHTCHANNEL] << 16) | (v[LEFTCHANNEL] & 0xffff);   // bugfix
} 
Metadata
Metadata
Assignees
Labels
No labels