rnd-20020427-2-src
authorHolger Schemel <info@artsoft.org>
Sat, 27 Apr 2002 00:55:02 +0000 (02:55 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:07 +0000 (10:37 +0200)
src/libgame/sound.c
src/libgame/sound.h

index 75634f1467f73b06c688f0ec11b796628308d34b..144dd1ad5dccc26ee07e419f34b81fb7cd168ece 100644 (file)
@@ -401,11 +401,9 @@ void SoundServer(void)
              sample_size = max_sample_size;
            }
 
-#if 0
            /* expand sample from 8 to 16 bit */
            for(j=0; j<sample_size; j++)
              premix_second_buffer[j] = premix_first_buffer[j] << 8;
-#endif
 
            /* decrease volume if sound is fading out */
            if (playlist[i].fade_sound &&
@@ -415,24 +413,24 @@ void SoundServer(void)
            /* adjust volume of actual sound sample */
            if (playlist[i].volume != PSND_MAX_VOLUME)
              for(j=0; j<sample_size; j++)
-               premix_first_buffer[j] =
-                 (playlist[i].volume * (int)premix_first_buffer[j])
+               premix_second_buffer[j] =
+                 (playlist[i].volume * (int)premix_second_buffer[j])
                    >> PSND_MAX_VOLUME_BITS;
 
            /* fill the last mixing buffer with stereo or mono sound */
            if (stereo)
            {
-             int middle_pos = PSND_MAX_LEFT2RIGHT/2;
+             int middle_pos = PSND_MAX_LEFT2RIGHT / 2;
              int left_volume = stereo_volume[middle_pos + playlist[i].stereo];
              int right_volume= stereo_volume[middle_pos - playlist[i].stereo];
 
              for(j=0; j<sample_size; j++)
              {
                premix_left_buffer[j] =
-                 (left_volume * (int)premix_first_buffer[j])
+                 (left_volume * premix_second_buffer[j])
                    >> PSND_MAX_LEFT2RIGHT_BITS;
                premix_right_buffer[j] =
-                 (right_volume * (int)premix_first_buffer[j])
+                 (right_volume * premix_second_buffer[j])
                    >> PSND_MAX_LEFT2RIGHT_BITS;
 
                premix_last_buffer[2 * j + 0] += premix_left_buffer[j];
@@ -442,7 +440,7 @@ void SoundServer(void)
            else
            {
              for(j=0; j<sample_size; j++)
-               premix_last_buffer[j] += (int)premix_first_buffer[j];
+               premix_last_buffer[j] += premix_second_buffer[j];
            }
 
            /* delete completed sound entries from the playlist */
@@ -464,29 +462,15 @@ void SoundServer(void)
          }
 
          /* put last mixing buffer to final playing buffer */
-#if 0
-         for(i=0; i<fragment_size; i++)
-         {
-           if (premix_last_buffer[i] < -255)
-             playing_buffer[i] = 0;
-           else if (premix_last_buffer[i] > 255)
-             playing_buffer[i] = 255;
-           else
-             playing_buffer[i] = (premix_last_buffer[i] >> 1) ^ 0x80;
-         }
-#else
          for(i=0; i<fragment_size; i++)
          {
-           if (premix_last_buffer[i] < -255)
-             playing_buffer[i] = -127;
-           else if (premix_last_buffer[i] > 255)
-             playing_buffer[i] = 127;
+           if (premix_last_buffer[i] < -65535)
+             playing_buffer[i] = -32767;
+           else if (premix_last_buffer[i] > 65535)
+             playing_buffer[i] = 32767;
            else
-             playing_buffer[i] = (premix_last_buffer[i] >> 1);
-
-           playing_buffer[i] <<= 8;
+             playing_buffer[i] = (short)(premix_last_buffer[i] >> 1);
          }
-#endif
 
          /* finally play the sound fragment */
          write(audio.device_fd, playing_buffer, fragment_size);
index ebca45f5eb6be619b2ed1a69998ca7d654ea8dea..cb606b0b4424f5b227a0d215fab24cf0840442a6 100644 (file)
@@ -92,7 +92,7 @@
 #if !defined(PLATFORM_MSDOS)
 
 #define PSND_SILENCE           0
-#define PSND_MAX_VOLUME_BITS   7
+#define PSND_MAX_VOLUME_BITS   15
 #define PSND_MIN_VOLUME                0
 #define PSND_MAX_VOLUME                (1 << PSND_MAX_VOLUME_BITS)
 #define PSND_MIDDLE            0