[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.119,1.120 d_sound.h,1.51,1.52

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sat Sep 4 02:28:29 CEST 2004


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

Modified Files:
	d_sound.cpp d_sound.h 
Log Message:
Added support for compressed music. I'm sure there are some glitches still
to fix, but it should work well enough for now.

In this rewrite of the music code, I removed the "save/restore music state"
function, since it just complicated things for a very small gain. It wasn't
in the original engine, and I added it just for the credits, so that the
previously playing music could be resumed afterwards. I might re-add it
later, but probably not.


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- d_sound.cpp	28 Aug 2004 14:50:44 -0000	1.119
+++ d_sound.cpp	4 Sep 2004 09:27:17 -0000	1.120
@@ -36,18 +36,115 @@
 
 namespace Sword2 {
 
+static AudioStream *makeCLUStream(File *fp, int size);
+
 static File fpMus;
 
 static void premix_proc(void *param, int16 *data, uint len) {
 	((Sound *) param)->streamMusic(data, len);
 }
 
[...1131 lines suppressed...]
+	// It's almost certainly a WAV file, but we still need to find its
+	// 'data' chunk.
+
+	while (READ_UINT32(data + offset) != MKID('data')) {
+		if (offset >= wavLength) {
+			warning("getWavInfo: Can't find 'data' chunk");
+			return false;
+		}
+		offset += (READ_LE_UINT32(data + offset + 4) + 8);
+	}
+
+	wavInfo->samples = READ_LE_UINT32(data + offset + 4);
+	wavInfo->data = data + offset + 8;
+	return true;
+}
+
+/**
  * @return the index of the sound effect with the ID passed in.
  */
 

Index: d_sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- d_sound.h	28 Aug 2004 14:50:44 -0000	1.51
+++ d_sound.h	4 Sep 2004 09:27:17 -0000	1.52
@@ -28,6 +28,8 @@
 
 namespace Sword2 {
 
+class MusicInputStream;
+
 // Max number of sound fx
 #define MAXFX 16
 #define MAXMUS 2
@@ -55,36 +57,6 @@
 	PlayingSoundHandle _handle;
 };
 
-class MusicHandle : public AudioStream {
-public:
-	RateConverter *_converter;
-	bool _firstTime;
-	bool _streaming;
-	bool _paused;
-	bool _looping;
-	int32 _fading;
-	int32 _fileStart;
-	int32 _filePos;
-	int32 _fileEnd;
-	uint16 _lastSample;
-
-	bool isStereo(void) const	{ return false; }
-	int getRate(void) const		{ return 22050; }
-
-	void fadeDown(void);
-	void fadeUp(void);
-	int32 play(uint32 musicId, bool looping);
-	void stop(void);
-	int readBuffer(int16 *buffer, const int numSamples);
-	bool endOfData(void) const;
-	// This stream never 'ends'
-	bool endOfStream(void) const { return false; }
-
-	MusicHandle() : _firstTime(false), _streaming(false), _paused(false),
-			_looping(false), _fading(0), _fileStart(0),
-			_filePos(0), _fileEnd(0), _lastSample(0) {}
-};
-
 class Sound {
 private:
 	Sword2Engine *_vm;
@@ -95,13 +67,13 @@
 	bool _soundOn;
 
 	static int32 _musicVolTable[17];
-	MusicHandle _music[MAXMUS + 1];
-	char *savedMusicFilename;
+	MusicInputStream *_music[MAXMUS];
+	RateConverter *_converter[MAXMUS];
+	bool _musicPaused;
 	bool _musicMuted;
 	uint8 _musicVol;
 
 	PlayingSoundHandle _soundHandleSpeech;
-	bool _speechStatus;
 	bool _speechPaused;
 	bool _speechMuted;
 	uint8 _speechVol;
@@ -114,9 +86,6 @@
 	int32 getFxIndex(int32 id);
 	void stopFxHandle(int i);
 
-	int openSoundFile(File *fp, const char *base);
-	AudioStream *getAudioStream(File *fp, const char *base, uint32 id, uint32 *numSamples);
-
 public:
 	Sound(Sword2Engine *vm);
 	~Sound();
@@ -133,8 +102,6 @@
 	void pauseMusic(void);
 	void unpauseMusic(void);
 	void stopMusic(void);
-	void saveMusicState(void);
-	void restoreMusicState(void);
 	void waitForLeadOut(void);
 	int32 streamCompMusic(uint32 musicId, bool looping);
 	int32 musicTimeRemaining(void);





More information about the Scummvm-git-logs mailing list