projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20020427-2-src
[rocksndiamonds.git]
/
src
/
libgame
/
sound.c
diff --git
a/src/libgame/sound.c
b/src/libgame/sound.c
index 75634f1467f73b06c688f0ec11b796628308d34b..144dd1ad5dccc26ee07e419f34b81fb7cd168ece 100644
(file)
--- a/
src/libgame/sound.c
+++ b/
src/libgame/sound.c
@@
-401,11
+401,9
@@
void SoundServer(void)
sample_size = max_sample_size;
}
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;
/* 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 &&
/* 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++)
/* 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)
{
>> 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] =
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] =
>> 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];
>> 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++)
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 */
}
/* delete completed sound entries from the playlist */
@@
-464,29
+462,15
@@
void SoundServer(void)
}
/* put last mixing buffer to final playing buffer */
}
/* 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++)
{
for(i=0; i<fragment_size; i++)
{
- if (premix_last_buffer[i] < -
25
5)
- playing_buffer[i] = -
12
7;
- else if (premix_last_buffer[i] >
25
5)
- playing_buffer[i] =
12
7;
+ if (premix_last_buffer[i] < -
6553
5)
+ playing_buffer[i] = -
3276
7;
+ else if (premix_last_buffer[i] >
6553
5)
+ playing_buffer[i] =
3276
7;
else
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);
/* finally play the sound fragment */
write(audio.device_fd, playing_buffer, fragment_size);