+ // Stereo sound support
+ if (sb->format.channels == 2)
+ {
+ if (vol[6] + vol[7] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[1] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[1] * vol[3]) >> 16;
+ paint[i].sample[4] += ((samples[0] + samples[1]) * vol[4]) >> 17;
+ paint[i].sample[5] += ((samples[0] + samples[1]) * vol[5]) >> 17;
+ paint[i].sample[6] += (samples[0] * vol[6]) >> 16;
+ paint[i].sample[7] += (samples[1] * vol[7]) >> 16;
+ samples += 2;
+ }
+ }
+ else if (vol[4] + vol[5] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[1] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[1] * vol[3]) >> 16;
+ paint[i].sample[4] += ((samples[0] + samples[1]) * vol[4]) >> 17;
+ paint[i].sample[5] += ((samples[0] + samples[1]) * vol[5]) >> 17;
+ samples += 2;
+ }
+ }
+ else if (vol[2] + vol[3] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[1] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[1] * vol[3]) >> 16;
+ samples += 2;
+ }
+ }
+ else if (vol[0] + vol[1] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[1] * vol[1]) >> 16;
+ samples += 2;
+ }
+ }
+ }
+ else if (sb->format.channels == 1)
+ {
+ if (vol[6] + vol[7] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[0] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[0] * vol[3]) >> 16;
+ paint[i].sample[4] += (samples[0] * vol[4]) >> 16;
+ paint[i].sample[5] += (samples[0] * vol[5]) >> 16;
+ paint[i].sample[6] += (samples[0] * vol[6]) >> 16;
+ paint[i].sample[7] += (samples[0] * vol[7]) >> 16;
+ samples += 1;
+ }
+ }
+ else if (vol[4] + vol[5] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[0] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[0] * vol[3]) >> 16;
+ paint[i].sample[4] += (samples[0] * vol[4]) >> 16;
+ paint[i].sample[5] += (samples[0] * vol[5]) >> 16;
+ samples += 1;
+ }
+ }
+ else if (vol[2] + vol[3] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[0] * vol[1]) >> 16;
+ paint[i].sample[2] += (samples[0] * vol[2]) >> 16;
+ paint[i].sample[3] += (samples[0] * vol[3]) >> 16;
+ samples += 1;
+ }
+ }
+ else if (vol[0] + vol[1] > 0)
+ {
+ for (i = 0;i < count;i++)
+ {
+ paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+ paint[i].sample[1] += (samples[0] * vol[1]) >> 16;
+ samples += 1;
+ }
+ }
+ }
+ else
+ return false; // unsupported number of channels in sound
+ }