diff options
Diffstat (limited to 'apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c')
-rw-r--r-- | apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c index 61485a1ca0..e44e432434 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/mv_mix.c | |||
@@ -65,7 +65,7 @@ int MV_cubic(int position) | |||
65 | } | 65 | } |
66 | */ | 66 | */ |
67 | 67 | ||
68 | static int MV_cubic16(const short *src, int position, int rate) | 68 | static inline int MV_cubic16(const short *src, int position, int rate) |
69 | { | 69 | { |
70 | int temp, hpos = position >> 16; | 70 | int temp, hpos = position >> 16; |
71 | 71 | ||
@@ -88,7 +88,7 @@ static int MV_cubic16(const short *src, int position, int rate) | |||
88 | return do_cubic ? MV_cubic(position) : gval(3); | 88 | return do_cubic ? MV_cubic(position) : gval(3); |
89 | } | 89 | } |
90 | 90 | ||
91 | static int MV_cubic8to16(const unsigned char *src, int position, int rate) | 91 | static inline int MV_cubic8to16(const unsigned char *src, int position, int rate) |
92 | { | 92 | { |
93 | int temp, hpos = position >> 16; | 93 | int temp, hpos = position >> 16; |
94 | 94 | ||
@@ -394,15 +394,17 @@ void MV_MixFPMono8( uint32_t position, | |||
394 | 394 | ||
395 | for (i = 0; i < length; i++) { | 395 | for (i = 0; i < length; i++) { |
396 | int s = MV_cubic8to16(src, position, rate) << FRACBITS; | 396 | int s = MV_cubic8to16(src, position, rate) << FRACBITS; |
397 | long out; | 397 | int out; |
398 | |||
399 | /* output is long in range [0, 2^16) */ | ||
400 | out = (s * MV_LeftScale) >> (FRACBITS * 2); | ||
398 | 401 | ||
399 | out = (s * MV_LeftScale) >> FRACBITS; | ||
400 | *dest += out; | 402 | *dest += out; |
401 | 403 | ||
402 | position += rate; | 404 | position += rate; |
403 | dest += MV_Channels; | 405 | dest += MV_Channels; |
404 | } | 406 | } |
405 | 407 | ||
406 | MV_MixPosition = position; | 408 | MV_MixPosition = position; |
407 | MV_MixDestination = (char *)dest; | 409 | MV_MixDestination = (char *)dest; |
408 | } | 410 | } |
@@ -423,8 +425,8 @@ void MV_MixFPStereo8( uint32_t position, | |||
423 | int s = MV_cubic8to16(src, position, rate) << FRACBITS; | 425 | int s = MV_cubic8to16(src, position, rate) << FRACBITS; |
424 | long left, right; | 426 | long left, right; |
425 | 427 | ||
426 | left = (s * MV_LeftScale) >> FRACBITS; | 428 | left = (s * MV_LeftScale) >> (FRACBITS * 2); |
427 | right = (s * MV_RightScale) >> FRACBITS; | 429 | right = (s * MV_RightScale) >> (FRACBITS * 2); |
428 | 430 | ||
429 | dest[0] += left; | 431 | dest[0] += left; |
430 | dest[1] += right; | 432 | dest[1] += right; |
@@ -452,9 +454,9 @@ void MV_MixFPMono16( uint32_t position, | |||
452 | 454 | ||
453 | for (i = 0; i < length; i++) { | 455 | for (i = 0; i < length; i++) { |
454 | int s = MV_cubic16(src, position, rate) << FRACBITS; | 456 | int s = MV_cubic16(src, position, rate) << FRACBITS; |
455 | long out; | 457 | int out; |
456 | 458 | ||
457 | out = (s * MV_LeftScale) >> FRACBITS; | 459 | out = (s * MV_LeftScale) >> (FRACBITS * 2); |
458 | *dest += out; | 460 | *dest += out; |
459 | 461 | ||
460 | position += rate; | 462 | position += rate; |
@@ -480,10 +482,10 @@ void MV_MixFPStereo16( uint32_t position, | |||
480 | for (i = 0; i < length; i++) { | 482 | for (i = 0; i < length; i++) { |
481 | int s = MV_cubic16(src, position, rate) << FRACBITS; | 483 | int s = MV_cubic16(src, position, rate) << FRACBITS; |
482 | 484 | ||
483 | long left, right; | 485 | int left, right; |
484 | 486 | ||
485 | left = (s * MV_LeftScale) >> FRACBITS; | 487 | left = (s * MV_LeftScale) >> (FRACBITS * 2); |
486 | right = (s * MV_RightScale) >> FRACBITS; | 488 | right = (s * MV_RightScale) >> (FRACBITS * 2); |
487 | 489 | ||
488 | dest[0] += left; | 490 | dest[0] += left; |
489 | dest[1] += right; | 491 | dest[1] += right; |