Ticket #8317: panvolume.diff

File panvolume.diff, 1.6 KB (added by eriktorbjorn, 21 years ago)

Patch against a January 27 CVS snapshot

  • scummvm/sound/mixer.cpp

    diff -ur ScummVM-cvs20040127/scummvm/sound/mixer.cpp ScummVM-cvs20040127+hack/scummvm/sound/mixer.cpp
    old new  
    496496        } else {
    497497                assert(_converter);
    498498
    499                 // The pan value ranges from -127 to +127. That's 255 different values.
    500                 // From the channel pan/volume and the global volume, we compute the
    501                 // effective volume for the left and right channel.
    502                 // Note the slightly odd divisor: the 255 reflects the fact that
    503                 // the maximal value for _volume is 255, while the 254 is there
    504                 // because the maximal left/right pan value is 2*127 = 254.
     499                // From the channel pan/volume and the global volume, we
     500                // compute the effective volume for the left and right channel.
     501                // Note the slightly odd divisor: the 255 reflects the fact
     502                // that the maximal value for _volume is 255, while the 127 is
     503                // there because the pan value ranges from -127 to 127.
    505504                // The value getVolume() returns is in the range 0 - 256.
    506505                // Hence, the vol_l/vol_r values will be in that range, too
    507506               
    508507                int vol = getVolume() * _volume;
    509                 st_volume_t vol_l = (127 - _pan) * vol / (255 * 254);
    510                 st_volume_t vol_r = (127 + _pan) * vol / (255 * 254);
     508                st_volume_t vol_l, vol_r;
     509
     510                if (_pan == 0) {
     511                        vol_l = vol / 255;
     512                        vol_r = vol / 255;
     513                } else if (_pan < 0) {
     514                        vol_l = vol / 255;
     515                        vol_r = ((127 + _pan) * vol) / (255 * 127);
     516                } else {
     517                        vol_l = ((127 - _pan) * vol) / (255 * 127);
     518                        vol_r = vol / 255;
     519                }
    511520
    512521                _converter->flow(*_input, data, len, vol_l, vol_r);
    513522        }