aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-07-17 14:00:07 +0000
committerTorbjörn Andersson2004-07-17 14:00:07 +0000
commitf02a14427b33715bf79c4f83582a049dcbdd3733 (patch)
tree436ee373ed87ccaf32cd3047e0720066881c4b73 /sword2
parent002b9331a8a8f60671fd066d0c25db78a00c94df (diff)
downloadscummvm-rg350-f02a14427b33715bf79c4f83582a049dcbdd3733.tar.gz
scummvm-rg350-f02a14427b33715bf79c4f83582a049dcbdd3733.tar.bz2
scummvm-rg350-f02a14427b33715bf79c4f83582a049dcbdd3733.zip
Allowing both music streams to share the same rate converter only worked
by accident, and could cause bad noises during music cross-fades. This wasn't a problem in 0.6.0 since all music is sampled at 22050 Hz, which is the most likely output sample rate for ScummVM, so the converter didn't actually have to do anything. Now, however, the output sample rate could be anything. I've given the music streams one converter each. In BS1, which uses similar music code, it was already necessary to do this since some of its music is sampled at 11025 Hz. svn-id: r14237
Diffstat (limited to 'sword2')
-rw-r--r--sword2/driver/d_sound.cpp15
-rw-r--r--sword2/driver/d_sound.h2
2 files changed, 12 insertions, 5 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 04fc5b51ea..db45b18bec 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -72,16 +72,23 @@ Sound::Sound(Sword2Engine *vm) {
_musicVol = 16;
_musicMuted = false;
- _converter = makeRateConverter(_music[0].getRate(), _vm->_mixer->getOutputRate(), _music[0].isStereo(), false);
+ for (int i = 0; i < MAXMUS; i++)
+ _music[i]._converter = makeRateConverter(_music[i].getRate(), _vm->_mixer->getOutputRate(), _music[i].isStereo(), false);
_vm->_mixer->setupPremix(premix_proc, this);
}
Sound::~Sound() {
+ int i;
+
_vm->_mixer->setupPremix(0, 0);
- delete _converter;
- for (int i = 0; i < MAXFX; i++)
+
+ for (i = 0; i < MAXMUS; i++)
+ delete _music[i]._converter;
+
+ for (i = 0; i < MAXFX; i++)
stopFxHandle(i);
+
if (_mutex)
_vm->_system->deleteMutex(_mutex);
}
@@ -99,7 +106,7 @@ void Sound::streamMusic(int16 *data, uint len) {
st_volume_t volume = _musicMuted ? 0 : _musicVolTable[_musicVol];
fpMus.seek(_music[i]._filePos, SEEK_SET);
- _converter->flow(_music[i], data, len, volume, volume);
+ _music[i]._converter->flow(_music[i], data, len, volume, volume);
}
// DipMusic();
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index 7efdf22479..bc1c487b39 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -49,6 +49,7 @@ struct FxHandle {
class MusicHandle : public AudioStream {
public:
+ RateConverter *_converter;
bool _firstTime;
bool _streaming;
bool _paused;
@@ -88,7 +89,6 @@ private:
static int32 _musicVolTable[17];
MusicHandle _music[MAXMUS + 1];
char *savedMusicFilename;
- RateConverter *_converter;
bool _musicMuted;
uint8 _musicVol;