diff options
author | Lionel Ulmer | 2002-05-20 20:35:25 +0000 |
---|---|---|
committer | Lionel Ulmer | 2002-05-20 20:35:25 +0000 |
commit | f6b934e068f9d59a2a8b6a02b7dc27e68e02e1de (patch) | |
tree | 371a1e7546ab98a20f5e7afda6679473086b957f /sound | |
parent | 1db4ae7c2f233c1825a9b4719134b39942cd23e3 (diff) | |
download | scummvm-rg350-f6b934e068f9d59a2a8b6a02b7dc27e68e02e1de.tar.gz scummvm-rg350-f6b934e068f9d59a2a8b6a02b7dc27e68e02e1de.tar.bz2 scummvm-rg350-f6b934e068f9d59a2a8b6a02b7dc27e68e02e1de.zip |
Add volume control like it is done for MP3 to the 16 bit 'mixers' (ie
using a 32 level only volume range).
svn-id: r4365
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mixer.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index d790122a3b..de5681b3dd 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -264,12 +264,13 @@ static void mix_unsigned_stereo_8(int16 *data, uint len, byte **s_ptr, uint32 *f } static void mix_signed_mono_16(int16 *data, uint len, byte **s_ptr, uint32 *fp_pos_ptr, int fp_speed, const int16 *vol_tab) { uint32 fp_pos = *fp_pos_ptr; + unsigned char volume = ((int) vol_tab[1]) * 32 / 255; byte *s = *s_ptr; do { + int16 sample = (int16) (((int32) ((*s << 8) | *(s + 1))) * volume / 32); fp_pos += fp_speed; - // FIXME: missing volume table - *data++ += ((*s << 8) | *(s + 1)); - *data++ += ((*s << 8) | *(s + 1)); + *data++ += sample; + *data++ += sample; s += (fp_pos >> 16) << 1; fp_pos &= 0x0000FFFF; } while (--len); @@ -282,12 +283,12 @@ static void mix_unsigned_mono_16(int16 *data, uint len, byte **s_ptr, uint32 *fp } static void mix_signed_stereo_16(int16 *data, uint len, byte **s_ptr, uint32 *fp_pos_ptr, int fp_speed, const int16 *vol_tab) { uint32 fp_pos = *fp_pos_ptr; + unsigned char volume = ((int) vol_tab[1]) * 32 / 255; byte *s = *s_ptr; do { fp_pos += fp_speed; - // FIXME: missing volume table - *data++ += ((*s << 8) | *(s + 1)); - *data++ += ((*(s + 2) << 8) | *(s + 3)); + *data++ += (int16) ((((int32) ((*(s ) << 8) | *(s + 1))) * volume) / 32); + *data++ += (int16) ((((int32) ((*(s + 2) << 8) | *(s + 3))) * volume) / 32); s += (fp_pos >> 16) << 2; fp_pos &= 0x0000FFFF; } while (--len); |