mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-25 05:21:41 +00:00
Stereo using phase separation now works without static. It is turned off by
default, but can be turned on simply by setting snd_stereo_phase_separation to something resonable (eg 0.6). snd_stereo_phase_separation is measured in milliseconds and the 0.6 is based on assuming a 20cm diameter head with speed of sound being 331m/s (0.000604229607 is more accurate for that, but I didn't want to type it in the console:) at the moment, phase and volume separation happen together. I'm not sure if it's worth disabling volume separation when phase separation is used, it sounds good to me :).
This commit is contained in:
parent
b08583c57e
commit
4323b3039e
1 changed files with 19 additions and 10 deletions
|
@ -39,7 +39,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PAINTBUFFER_SIZE 512
|
#define PAINTBUFFER_SIZE 512
|
||||||
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE+100];
|
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE * 2];
|
||||||
|
int max_overpaint; // number of extra samples painted due to phase shift
|
||||||
int snd_scaletable[32][256];
|
int snd_scaletable[32][256];
|
||||||
int *snd_p, snd_linear_count, snd_vol;
|
int *snd_p, snd_linear_count, snd_vol;
|
||||||
short *snd_out;
|
short *snd_out;
|
||||||
|
@ -285,7 +286,8 @@ void S_PaintChannels(int endtime)
|
||||||
end = paintedtime + PAINTBUFFER_SIZE;
|
end = paintedtime + PAINTBUFFER_SIZE;
|
||||||
|
|
||||||
// clear the paint buffer
|
// clear the paint buffer
|
||||||
memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
|
//memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
|
||||||
|
max_overpaint = 0;
|
||||||
|
|
||||||
// paint in the channels.
|
// paint in the channels.
|
||||||
ch = channels;
|
ch = channels;
|
||||||
|
@ -302,7 +304,8 @@ void S_PaintChannels(int endtime)
|
||||||
ltime = paintedtime;
|
ltime = paintedtime;
|
||||||
|
|
||||||
while (ltime < end)
|
while (ltime < end)
|
||||||
{ // paint up to end
|
{
|
||||||
|
// paint up to end
|
||||||
if (ch->end < end)
|
if (ch->end < end)
|
||||||
count = ch->end - ltime;
|
count = ch->end - ltime;
|
||||||
else
|
else
|
||||||
|
@ -338,6 +341,10 @@ void S_PaintChannels(int endtime)
|
||||||
|
|
||||||
// transfer out according to DMA format
|
// transfer out according to DMA format
|
||||||
S_TransferPaintBuffer(end);
|
S_TransferPaintBuffer(end);
|
||||||
|
|
||||||
|
memcpy (paintbuffer, paintbuffer + end - paintedtime, max_overpaint * sizeof (paintbuffer[0]));
|
||||||
|
memset (paintbuffer + max_overpaint, 0, sizeof (paintbuffer) - max_overpaint * sizeof (paintbuffer[0]));
|
||||||
|
|
||||||
paintedtime = end;
|
paintedtime = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,9 +404,13 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
if (ch->phase >= 0) {
|
if (ch->phase >= 0) {
|
||||||
left_phase = ch->phase;
|
left_phase = ch->phase;
|
||||||
right_phase = 0;
|
right_phase = 0;
|
||||||
|
if (ch->phase > max_overpaint)
|
||||||
|
max_overpaint = ch->phase;
|
||||||
} else {
|
} else {
|
||||||
left_phase = 0;
|
left_phase = 0;
|
||||||
right_phase = -ch->phase;
|
right_phase = -ch->phase;
|
||||||
|
if (-ch->phase > max_overpaint)
|
||||||
|
max_overpaint = -ch->phase;
|
||||||
}
|
}
|
||||||
sfx = (signed short *)sc->data + ch->pos;
|
sfx = (signed short *)sc->data + ch->pos;
|
||||||
|
|
||||||
|
@ -408,8 +419,6 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
data = sfx[i];
|
data = sfx[i];
|
||||||
left = (data * leftvol) >> 8;
|
left = (data * leftvol) >> 8;
|
||||||
right = (data * rightvol) >> 8;
|
right = (data * rightvol) >> 8;
|
||||||
//paintbuffer[i].left += left;
|
|
||||||
//paintbuffer[i].right += right;
|
|
||||||
paintbuffer[i+left_phase].left += left;
|
paintbuffer[i+left_phase].left += left;
|
||||||
paintbuffer[i+right_phase].right += right;
|
paintbuffer[i+right_phase].right += right;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue