On Sat, May 21, 2011 at 06:05:25PM +0000, Jacob Meuser wrote:
> On Sat, May 21, 2011 at 02:56:36AM -0700, Ryan Freeman wrote:
>
> > - sound is slightly modified snd_sndio.c from the games/quake port
> > (works actually better than existing quake port which has dreadful
> > audio sounding like its being overdriven by 100dB) i blame something
> > in the old ver of quakeforge over Jacob's snd_sndio.c ;)
>
> wtf? sound is indeed majorly mangled. this used to work perfectly.
>
it seems it worked by accident, probably the gcc switch exposed a bug
used to convert 8-bit to 16-bit samples. This diff fixes it and might
make it faster as a side effect.
-- Alexandre
Index: patches/patch-common_snd_dma_c
===================================================================
RCS file: patches/patch-common_snd_dma_c
diff -N patches/patch-common_snd_dma_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-common_snd_dma_c 21 Jun 2011 13:38:39 -0000
@@ -0,0 +1,11 @@
+--- common/snd_dma.c.old Tue Jun 21 15:12:41 2011
++++ common/snd_dma.c Tue Jun 21 15:22:12 2011
+@@ -213,8 +213,6 @@ void S_Init (void)
+ if (sound_started == 0) // sound startup failed? Bail out.
+ return;
+
+- SND_InitScaletable ();
+-
+ known_sfx = Hunk_AllocName (MAX_SFX*sizeof(sfx_t), "sfx_t");
+ num_sfx = 0;
+
Index: patches/patch-common_snd_mix_c
===================================================================
RCS file: patches/patch-common_snd_mix_c
diff -N patches/patch-common_snd_mix_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-common_snd_mix_c 21 Jun 2011 13:38:39 -0000
@@ -0,0 +1,115 @@
+--- common/snd_mix.c.old Tue Jun 21 15:12:34 2011
++++ common/snd_mix.c Tue Jun 21 15:26:32 2011
+@@ -29,38 +29,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+
+ #define PAINTBUFFER_SIZE 512
+ portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
+-int snd_scaletable[32][256];
+ int *snd_p, snd_linear_count, snd_vol;
+ short *snd_out;
+
+ void Snd_WriteLinearBlastStereo16 (void);
+
+-#if !id386
+ void Snd_WriteLinearBlastStereo16 (void)
+ {
+- int i;
+- int val;
+-
+- for (i=0 ; i<snd_linear_count ; i+=2)
++ short *outp;
++ int *inp, val, i;
++
++ for (outp = snd_out, inp = snd_p, i = snd_linear_count; i > 0; i--)
+ {
+- val = (snd_p[i]*snd_vol)>>8;
++ val = (*inp++ * snd_vol) >> 8;
+ if (val > 0x7fff)
+- snd_out[i] = 0x7fff;
++ val = 0x7fff;
+ else if (val < (short)0x8000)
+- snd_out[i] = (short)0x8000;
+- else
+- snd_out[i] = val;
+-
+- val = (snd_p[i+1]*snd_vol)>>8;
+- if (val > 0x7fff)
+- snd_out[i+1] = 0x7fff;
+- else if (val < (short)0x8000)
+- snd_out[i+1] = (short)0x8000;
+- else
+- snd_out[i+1] = val;
++ val = (short)0x8000;
++ *outp++ = val;
+ }
+ }
+-#endif
+
+ void S_TransferStereo16 (int endtime)
+ {
+@@ -331,47 +319,28 @@ void S_PaintChannels(int endtime)
+ }
+ }
+
+-void SND_InitScaletable (void)
+-{
+- int i, j;
+-
+- for (i=0 ; i<32 ; i++)
+- for (j=0 ; j<256 ; j++)
+- snd_scaletable[i][j] = ((signed char)j) * i * 8;
+-}
+-
+-
+-#if !id386
+-
+ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
+ {
+ int data;
+- int *lscale, *rscale;
+- unsigned char *sfx;
+- int i;
++ int lscale, rscale;
++ int i;
++ signed char *sfx;
+
+- if (ch->leftvol > 255)
+- ch->leftvol = 255;
+- if (ch->rightvol > 255)
+- ch->rightvol = 255;
+-
+- lscale = snd_scaletable[ch->leftvol >> 3];
+- rscale = snd_scaletable[ch->rightvol >> 3];
++ lscale = ch->leftvol / 4;
++ rscale = ch->rightvol / 4;
+ sfx = (signed char *)sc->data + ch->pos;
+
+ for (i=0 ; i<count ; i++)
+ {
+ data = sfx[i];
+- paintbuffer[i].left += lscale[data];
+- paintbuffer[i].right += rscale[data];
++ paintbuffer[i].left += lscale * data;
++ paintbuffer[i].right += rscale * data;
+ }
+
+ ch->pos += count;
+ }
+
+-#endif // !id386
+
+-
+ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
+ {
+ int data;
+@@ -380,8 +349,8 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t
+ signed short *sfx;
+ int i;
+
+- leftvol = ch->leftvol;
+- rightvol = ch->rightvol;
++ leftvol = ch->leftvol / 4;
++ rightvol = ch->rightvol / 4;
+ sfx = (signed short *)sc->data + ch->pos;
+
+ for (i=0 ; i<count ; i++)
Index: patches/patch-common_snd_mixa_s
===================================================================
RCS file: patches/patch-common_snd_mixa_s
diff -N patches/patch-common_snd_mixa_s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-common_snd_mixa_s 21 Jun 2011 13:38:39 -0000
@@ -0,0 +1,11 @@
+--- common/snd_mixa.s.old Tue Jun 21 15:33:46 2011
++++ common/snd_mixa.s Tue Jun 21 15:34:00 2011
+@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ #include "asm_i386.h"
+ #include "quakeasm.h"
+
+-#if id386
++#if 0
+
+ .text
+