diff -ur ScummVM-cvs20040127/scummvm/sound/mixer.cpp ScummVM-cvs20040127+hack/scummvm/sound/mixer.cpp
old
|
new
|
|
496 | 496 | } else { |
497 | 497 | assert(_converter); |
498 | 498 | |
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. |
505 | 504 | // The value getVolume() returns is in the range 0 - 256. |
506 | 505 | // Hence, the vol_l/vol_r values will be in that range, too |
507 | 506 | |
508 | 507 | 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 | } |
511 | 520 | |
512 | 521 | _converter->flow(*_input, data, len, vol_l, vol_r); |
513 | 522 | } |