mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-28 23:01:53 +00:00
almost there, not sure where this last static is coming from though
This commit is contained in:
parent
63895493c3
commit
f012888213
1 changed files with 64 additions and 56 deletions
110
source/snd_mix.c
110
source/snd_mix.c
|
@ -395,14 +395,8 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
{
|
{
|
||||||
int leftvol, rightvol;
|
int leftvol, rightvol;
|
||||||
signed short *sfx;
|
signed short *sfx;
|
||||||
int i = 0;
|
unsigned int i = 0;
|
||||||
unsigned int left_phase, right_phase; // never allowed < 0 anyway
|
unsigned int left_phase, right_phase; // never allowed < 0 anyway
|
||||||
int oldphase = ch->oldphase * 2;
|
|
||||||
int phase = ch->phase * 2;
|
|
||||||
|
|
||||||
int dir = (phase - oldphase) > 0 ? 1 : -1;
|
|
||||||
int ldir;
|
|
||||||
int rdir;
|
|
||||||
|
|
||||||
leftvol = ch->leftvol;
|
leftvol = ch->leftvol;
|
||||||
rightvol = ch->rightvol;
|
rightvol = ch->rightvol;
|
||||||
|
@ -413,63 +407,77 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
sfx = (signed short *)sc->data + ch->pos;
|
sfx = (signed short *)sc->data + ch->pos;
|
||||||
ch->pos += count;
|
ch->pos += count;
|
||||||
|
|
||||||
if (oldphase >= 0) {
|
if (ch->phase >= 0) {
|
||||||
left_phase = oldphase;
|
left_phase = ch->phase;
|
||||||
right_phase = 0;
|
right_phase = 0;
|
||||||
} else {
|
} else {
|
||||||
left_phase = 0;
|
left_phase = 0;
|
||||||
right_phase = -oldphase;
|
right_phase = -ch->phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PAINT_CHANNELS do { \
|
if (ch->oldphase != ch->phase) {
|
||||||
int data = sfx[i]; \
|
unsigned int olp, orp, nlp, nrp;
|
||||||
int left = (data * leftvol) >> 8; \
|
unsigned int cl, cr, c;
|
||||||
int right = (data * rightvol) >> 8; \
|
|
||||||
paintbuffer[i + left_phase / 2].left += left; \
|
|
||||||
paintbuffer[i + right_phase / 2].right += right;\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
if (oldphase != phase) {
|
if (ch->oldphase >= 0) {
|
||||||
int c;
|
olp = ch->oldphase;
|
||||||
|
orp = 0;
|
||||||
if ((oldphase ^ phase) & ~((~0u)>>1)) {
|
|
||||||
// phase change crosses 0
|
|
||||||
c = min (count, abs(oldphase));
|
|
||||||
count -= c;
|
|
||||||
if (oldphase > 0) {
|
|
||||||
ldir = -1;
|
|
||||||
rdir = 0;
|
|
||||||
} else {
|
} else {
|
||||||
ldir = 0;
|
olp = 0;
|
||||||
rdir = -1;
|
orp = -ch->oldphase;
|
||||||
}
|
}
|
||||||
for ( ; c; c--, i++) {
|
nlp = left_phase;
|
||||||
PAINT_CHANNELS;
|
nrp = right_phase;
|
||||||
left_phase += ldir;
|
if (nlp > olp)
|
||||||
right_phase += rdir;
|
cl = 2 * (nlp - olp);
|
||||||
}
|
else
|
||||||
oldphase = 0;
|
cl = olp - nlp;
|
||||||
}
|
if (nrp > orp)
|
||||||
// oldphase and phase [now] on same size of 0
|
cr = 2 * (nrp - orp);
|
||||||
c = min (count, abs (phase - oldphase));
|
else
|
||||||
|
cr = orp - nrp;
|
||||||
|
c = min (count, max (cr, cl));
|
||||||
count -= c;
|
count -= c;
|
||||||
if (phase > 0) {
|
while (c) {
|
||||||
ldir = dir;
|
int data = sfx[i];
|
||||||
rdir = 0;
|
int left = (data * leftvol) >> 8;
|
||||||
} else {
|
int right = (data * rightvol) >> 8;
|
||||||
ldir = 0;
|
if (nlp < olp) {
|
||||||
rdir = dir;
|
if (!(cl & 1)) {
|
||||||
|
paintbuffer[i + olp].left += left;
|
||||||
|
olp--;
|
||||||
}
|
}
|
||||||
for ( ; c; c--, i++) {
|
cl--;
|
||||||
PAINT_CHANNELS;
|
} else if (nlp > olp) {
|
||||||
left_phase += ldir;
|
paintbuffer[i + olp].left += left;
|
||||||
right_phase += rdir;
|
olp++;
|
||||||
|
paintbuffer[i + olp].left += left;
|
||||||
|
} else {
|
||||||
|
paintbuffer[i + olp].left += left;
|
||||||
|
}
|
||||||
|
if (nrp < orp) {
|
||||||
|
if (!(cr & 1)) {
|
||||||
|
paintbuffer[i + orp].right += right;
|
||||||
|
orp--;
|
||||||
|
}
|
||||||
|
cr--;
|
||||||
|
} else if (nrp > orp) {
|
||||||
|
paintbuffer[i + orp].right += right;
|
||||||
|
orp++;
|
||||||
|
paintbuffer[i + orp].right += right;
|
||||||
|
} else {
|
||||||
|
paintbuffer[i + orp].right += right;
|
||||||
|
}
|
||||||
|
c--;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; count ; count--, i++) {
|
for (; count ; count--, i++) {
|
||||||
PAINT_CHANNELS;
|
int data = sfx[i];
|
||||||
|
int left = (data * leftvol) >> 8;
|
||||||
|
int right = (data * rightvol) >> 8;
|
||||||
|
paintbuffer[i + left_phase].left += left;
|
||||||
|
paintbuffer[i + right_phase].right += right;
|
||||||
}
|
}
|
||||||
#undef PAINT_CHANNELS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue