- // 8bit 1 channel (mono)
- while (lpaintedtime < endtime)
- {
- // handle recirculating buffer issues
- i = lpaintedtime & (shm->samples - 1);
- snd_out = (unsigned char *) pbuf + i;
- snd_linear_count = shm->samples - i;
- if (snd_linear_count > endtime - lpaintedtime)
- snd_linear_count = endtime - lpaintedtime;
- for (i = 0;i < snd_linear_count;i++)
- {
- val = (((snd_p[i * 2] + snd_p[i * 2 + 1]) * snd_vol) >> 17) + 128;
- snd_out[i ] = bound(0, val, 255);
- }
- snd_p += snd_linear_count << 1;
- lpaintedtime += snd_linear_count;
- }
+ val = (int)(painted_ptr->sample[0] * 32768.0f);*snd_out++ = bound(-32768, val, 32767);
+ val = (int)(painted_ptr->sample[1] * 32768.0f);*snd_out++ = bound(-32768, val, 32767);
+ }
+ }
+ else if (channels == 1) // 1.0 mono
+ {
+ for (i = 0; i < nbframes; i++, painted_ptr++)
+ {
+ val = (int)((painted_ptr->sample[0] + painted_ptr->sample[1]) * 16384.0f);*snd_out++ = bound(-32768, val, 32767);
+ }
+ }
+
+ // noise is really really annoying
+ if (cls.timedemo)
+ memset(rb_ptr, 0, nbframes * channels * width);
+ }
+ else // 8bit
+ {
+ unsigned char *snd_out = (unsigned char*)rb_ptr;
+ if (channels == 8) // 7.1 surround
+ {
+ for (i = 0; i < nbframes; i++, painted_ptr++)
+ {
+ val = (int)(painted_ptr->sample[0] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[1] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[2] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[3] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[4] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[5] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[6] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[7] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ }
+ }
+ else if (channels == 6) // 5.1 surround
+ {
+ for (i = 0; i < nbframes; i++, painted_ptr++)
+ {
+ val = (int)(painted_ptr->sample[0] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[1] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[2] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[3] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[4] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[5] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ }
+ }
+ else if (channels == 4) // 4.0 surround
+ {
+ for (i = 0; i < nbframes; i++, painted_ptr++)
+ {
+ val = (int)(painted_ptr->sample[0] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[1] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[2] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[3] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ }
+ }
+ else if (channels == 2) // 2.0 stereo
+ {
+ for (i = 0; i < nbframes; i++, painted_ptr++)
+ {
+ val = (int)(painted_ptr->sample[0] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ val = (int)(painted_ptr->sample[1] * 128.0f) + 128; *snd_out++ = bound(0, val, 255);
+ }
+ }
+ else if (channels == 1) // 1.0 mono
+ {
+ for (i = 0;i < nbframes;i++, painted_ptr++)
+ {
+ val = (int)((painted_ptr->sample[0] + painted_ptr->sample[1]) * 64.0f) + 128; *snd_out++ = bound(0, val, 255);