[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.112,1.113 d_sound.h,1.46,1.47

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sat Jul 17 07:01:12 CEST 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv866/driver

Modified Files:
	d_sound.cpp d_sound.h 
Log Message:
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.


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- d_sound.cpp	12 Jun 2004 09:53:45 -0000	1.112
+++ d_sound.cpp	17 Jul 2004 14:00:07 -0000	1.113
@@ -72,16 +72,23 @@
 	_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 @@
 		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();

Index: d_sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- d_sound.h	12 Jun 2004 09:53:45 -0000	1.46
+++ d_sound.h	17 Jul 2004 14:00:07 -0000	1.47
@@ -49,6 +49,7 @@
 
 class MusicHandle : public AudioStream {
 public:
+	RateConverter *_converter;
 	bool _firstTime;
 	bool _streaming;
 	bool _paused;
@@ -88,7 +89,6 @@
 	static int32 _musicVolTable[17];
 	MusicHandle _music[MAXMUS + 1];
 	char *savedMusicFilename;
-	RateConverter *_converter;
 	bool _musicMuted;
 	uint8 _musicVol;
 





More information about the Scummvm-git-logs mailing list