+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[4] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[5] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[6] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[7] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ else
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[4] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[5] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[6] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[7] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ }
+ else if (shm->format.channels == 6)
+ {
+ // 5.1 surround
+ if (snd_swapstereo.value)
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[4] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[5] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ else
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[4] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[5] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ }
+ else if (shm->format.channels == 4)
+ {
+ // 4.0 surround
+ if (snd_swapstereo.value)
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ else
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[2] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[3] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ }
+ else if (shm->format.channels == 2)
+ {
+ // 2.0 stereo
+ if (snd_swapstereo.value)
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ else
+ {
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = (snd_p->sample[0] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ val = (snd_p->sample[1] >> 8) + 128;*snd_out++ = bound(0, val, 255);
+ }
+ }
+ }
+ else if (shm->format.channels == 1)
+ {
+ // 1.0 mono
+ for (i = 0;i < snd_frames;i++, snd_p++)
+ {
+ val = ((snd_p->sample[0]+snd_p->sample[1]) >> 9) + 128;*snd_out++ = bound(0, val, 255);