patch-2.1.67 linux/drivers/sound/softoss_rs.c

Next file: linux/drivers/sound/sound_calls.h
Previous file: linux/drivers/sound/softoss.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.66/linux/drivers/sound/softoss_rs.c linux/drivers/sound/softoss_rs.c
@@ -1,3 +1,4 @@
+
 /*
  * sound/softoss_rs.c
  *
@@ -17,123 +18,119 @@
 
 #include "sound_config.h"
 
-#ifdef CONFIG_SOFTOSS
+#if defined(CONFIG_SOFTOSS) || defined(MODULE)
 #include "softoss.h"
 
 void
-softsynth_resample_loop (short *buf, int loops)
+softsynth_resample_loop(short *buf, int loops)
 {
-  int             iloop, voice;
-  volatile voice_info *v;
+	int             iloop, voice;
+	volatile voice_info *v;
 
 #ifdef OSS_BIG_ENDIAN
-  unsigned char  *cbuf = (unsigned char *) buf;
+	unsigned char  *cbuf = (unsigned char *) buf;
 
 #endif
 
-  for (iloop = 0; iloop < loops; iloop++)
-    {				/* Mix one sample */
+	for (iloop = 0; iloop < loops; iloop++)
+	  {			/* Mix one sample */
 
-      int             accum, left = 0, right = 0;
-      int             ix, position;
+		  int             accum, left = 0, right = 0;
+		  int             ix, position;
 
-      for (voice = 0; voice < devc->maxvoice; voice++)
-	if (voice_active[voice])
-	  {			/* Compute voice */
+		  for (voice = 0; voice < devc->maxvoice; voice++)
+			  if (voice_active[voice])
+			    {	/* Compute voice */
 
-	    v = &softoss_voices[voice];
+				    v = &softoss_voices[voice];
 #ifdef SOFTOSS_TEST
-	    ix = iloop << 3;
-	    position = v->ptr;
+				    ix = iloop << 3;
+				    position = v->ptr;
 #else
-	    ix = (position = v->ptr) >> 9;
+				    ix = (position = v->ptr) >> 9;
 #endif
-	    /* Interpolation (resolution of 512 steps) */
-	    {
-	      int             fract = v->ptr & 0x1f;	/* 9 bits */
-
-	      /* This method works with less arithmetic operations */
-	      register int    v1 = v->wave[ix];
-
-	      accum = v1 + ((((v->wave[ix + 1] - v1)) * (fract)) >> 9);
-	    }
-
-	    left += (accum * v->leftvol);
-	    right += (accum * v->rightvol);
-
-	    /* Update sample pointer */
-
-	    position += v->step;
-	    if (position <= v->endloop)
-	      v->ptr = position;
-	    else if (v->mode & WAVE_LOOPING)
-	      {
-		if (v->mode & WAVE_BIDIR_LOOP)
-		  {
-		    v->mode ^= WAVE_LOOP_BACK;	/* Turn around */
-		    v->step *= -1;
-		  }
-		else
-		  {
-		    position -= v->looplen;
-		    v->ptr = position;
-		  }
-	      }
-	    /*  else leave the voice looping the current sample */
-
-	    if (v->mode & WAVE_LOOP_BACK && position < v->startloop)
-	      {
-		if (v->mode & WAVE_BIDIR_LOOP)
-		  {
-		    v->mode ^= WAVE_LOOP_BACK;	/* Turn around */
-		    v->step *= -1;
-		  }
-		else
-		  {
-		    position += v->looplen;
-		    v->ptr = position;
-		  }
-	      }
-
-	  }			/* Compute voice */
-
+				    /* Interpolation (resolution of 512 steps) */
+				    {
+					    int             fract = v->ptr & 0x1f;	/* 9 bits */
+
+					    /* This method works with less arithmetic operations */
+					    register int    v1 = v->wave[ix];
+
+					    accum = v1 + ((((v->wave[ix + 1] - v1)) * (fract)) >> 9);
+				    }
+
+				    left += (accum * v->leftvol);
+				    right += (accum * v->rightvol);
+
+				    /* Update sample pointer */
+
+				    position += v->step;
+				    if (position <= v->endloop)
+					    v->ptr = position;
+				    else if (v->mode & WAVE_LOOPING)
+				      {
+					      if (v->mode & WAVE_BIDIR_LOOP)
+						{
+							v->mode ^= WAVE_LOOP_BACK;	/* Turn around */
+							v->step *= -1;
+					      } else
+						{
+							position -= v->looplen;
+							v->ptr = position;
+						}
+				      }
+				    /*  else leave the voice looping the current sample */
+
+				    if (v->mode & WAVE_LOOP_BACK && position < v->startloop)
+				      {
+					      if (v->mode & WAVE_BIDIR_LOOP)
+						{
+							v->mode ^= WAVE_LOOP_BACK;	/* Turn around */
+							v->step *= -1;
+					      } else
+						{
+							position += v->looplen;
+							v->ptr = position;
+						}
+				      }
+			    }	/* Compute voice */
 #if 1				/* Delay */
-      left += left_delay[delayp];
-      right += right_delay[delayp];
+		  left += left_delay[delayp];
+		  right += right_delay[delayp];
 
-      left_delay[delayp] = right >> 2;
-      right_delay[delayp] = left >> 2;
-      delayp = (delayp + 1) % devc->delay_size;
+		  left_delay[delayp] = right >> 2;
+		  right_delay[delayp] = left >> 2;
+		  delayp = (delayp + 1) % devc->delay_size;
 #endif
 
 #define AFTERSCALE devc->afterscale;
 
-      left >>= AFTERSCALE;
-      right >>= AFTERSCALE;
+		  left >>= AFTERSCALE;
+		  right >>= AFTERSCALE;
 
-      if (left > 32767)
-	left = 32767;
-      if (left < -32768)
-	left = -32768;
-      if (right > 32767)
-	right = 32767;
-      if (right < -32768)
-	right = -32768;
+		  if (left > 32767)
+			  left = 32767;
+		  if (left < -32768)
+			  left = -32768;
+		  if (right > 32767)
+			  right = 32767;
+		  if (right < -32768)
+			  right = -32768;
 
 #ifdef OSS_BIG_ENDIAN
-      *cbuf++ = left & 0xff;
-      *cbuf++ = (left >> 8) & 0xff;
-      *cbuf++ = right & 0xff;
-      *cbuf++ = (right >> 8) & 0xff;
+		  *cbuf++ = left & 0xff;
+		  *cbuf++ = (left >> 8) & 0xff;
+		  *cbuf++ = right & 0xff;
+		  *cbuf++ = (right >> 8) & 0xff;
 #else
-      *buf++ = left;
-      *buf++ = right;
+		  *buf++ = left;
+		  *buf++ = right;
 #endif
-      if (devc->control_counter++ >= devc->control_rate)
-	{
-	  devc->control_counter = 0;
-	  softsyn_control_loop ();
-	}
-    }				/* Mix one sample */
+		  if (devc->control_counter++ >= devc->control_rate)
+		    {
+			    devc->control_counter = 0;
+			    softsyn_control_loop();
+		    }
+	  }			/* Mix one sample */
 }
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov