diff options
Diffstat (limited to 'apps/plugins/doom')
-rw-r--r-- | apps/plugins/doom/i_sound.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/plugins/doom/i_sound.c b/apps/plugins/doom/i_sound.c index 2f4f594077..35cecd8abb 100644 --- a/apps/plugins/doom/i_sound.c +++ b/apps/plugins/doom/i_sound.c | |||
@@ -48,7 +48,7 @@ | |||
48 | // mixing buffer, and the samplerate of the raw data. | 48 | // mixing buffer, and the samplerate of the raw data. |
49 | 49 | ||
50 | // Needed for calling the actual sound output. | 50 | // Needed for calling the actual sound output. |
51 | #define SAMPLECOUNT 512 | 51 | #define SAMPLECOUNT 128 |
52 | 52 | ||
53 | #define NUM_CHANNELS 24 | 53 | #define NUM_CHANNELS 24 |
54 | // It is 2 for 16bit, and 2 for two channels. | 54 | // It is 2 for 16bit, and 2 for two channels. |
@@ -99,6 +99,13 @@ int *vol_lookup; // Volume lookups. | |||
99 | 99 | ||
100 | int *steptable; // Pitch to stepping lookup. (Not setup properly right now) | 100 | int *steptable; // Pitch to stepping lookup. (Not setup properly right now) |
101 | 101 | ||
102 | static inline int32_t clip_sample16(int32_t sample) | ||
103 | { | ||
104 | if ((int16_t)sample != sample) | ||
105 | sample = 0x7fff ^ (sample >> 31); | ||
106 | return sample; | ||
107 | } | ||
108 | |||
102 | // | 109 | // |
103 | // This function loads the sound data from the WAD lump for single sound. | 110 | // This function loads the sound data from the WAD lump for single sound. |
104 | // It is used to cache all the sounddata at startup. | 111 | // It is used to cache all the sounddata at startup. |
@@ -371,7 +378,7 @@ void I_UpdateSound( void ) | |||
371 | signed short* leftend; | 378 | signed short* leftend; |
372 | 379 | ||
373 | // Step in mixbuffer, left and right, thus two. | 380 | // Step in mixbuffer, left and right, thus two. |
374 | int step; | 381 | const int step = 2; |
375 | 382 | ||
376 | // Mixing channel index. | 383 | // Mixing channel index. |
377 | int chan; | 384 | int chan; |
@@ -380,7 +387,6 @@ void I_UpdateSound( void ) | |||
380 | // are in global mixbuffer, alternating. | 387 | // are in global mixbuffer, alternating. |
381 | leftout = mixbuffer; | 388 | leftout = mixbuffer; |
382 | rightout = mixbuffer +1; | 389 | rightout = mixbuffer +1; |
383 | step = 2; | ||
384 | 390 | ||
385 | // Determine end, for left channel only | 391 | // Determine end, for left channel only |
386 | // (right channel is implicit). | 392 | // (right channel is implicit). |
@@ -431,20 +437,10 @@ void I_UpdateSound( void ) | |||
431 | // else if (dl < -128) *leftout = -128; | 437 | // else if (dl < -128) *leftout = -128; |
432 | // else *leftout = dl; | 438 | // else *leftout = dl; |
433 | 439 | ||
434 | if (dl > 0x7fff) | 440 | *leftout = clip_sample16(dl); |
435 | *leftout = 0x7fff; | ||
436 | else if (dl < -0x8000) | ||
437 | *leftout = -0x8000; | ||
438 | else | ||
439 | *leftout = (signed short)dl; | ||
440 | 441 | ||
441 | // Same for right hardware channel. | 442 | // Same for right hardware channel. |
442 | if (dr > 0x7fff) | 443 | *rightout = clip_sample16(dr); |
443 | *rightout = 0x7fff; | ||
444 | else if (dr < -0x8000) | ||
445 | *rightout = -0x8000; | ||
446 | else | ||
447 | *rightout = (signed short)dr; | ||
448 | 444 | ||
449 | // Increment current pointers in mixbuffer. | 445 | // Increment current pointers in mixbuffer. |
450 | leftout += step; | 446 | leftout += step; |