[Scummvm-cvs-logs] SF.net SVN: scummvm:[47431] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Fri Jan 22 05:24:10 CET 2010


Revision: 47431
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47431&view=rev
Author:   mthreepwood
Date:     2010-01-22 04:24:04 +0000 (Fri, 22 Jan 2010)

Log Message:
-----------
Always loop sounds declared in the VIEW resources of Myst. While Myst specifies in the metadata of its sound resources, Myst ME does not have that feature so we have to specify the looping. Looping now works in Myst ME.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/sound.cpp
    scummvm/trunk/engines/mohawk/sound.h

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-01-22 03:50:49 UTC (rev 47430)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-01-22 04:24:04 UTC (rev 47431)
@@ -397,7 +397,10 @@
 		_sound->stopSound();
 		// TODO: Need to keep sound handle and add function to change volume of
 		// looped running sound for kMystSoundActionChangeVolume type
-		_sound->playSound(soundAction, true, soundActionVolume);
+
+		// NOTE: All sounds are looped when played via the sound section of the
+		// VIEW resources.
+		_sound->playSound(soundAction, true, soundActionVolume, true);
 	} else {
 		error("Unknown sound action %d", soundAction);
 	}

Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp	2010-01-22 03:50:49 UTC (rev 47430)
+++ scummvm/trunk/engines/mohawk/sound.cpp	2010-01-22 04:24:04 UTC (rev 47431)
@@ -87,13 +87,13 @@
 	_midiParser->setTimerRate(_midiDriver->getBaseTempo());
 }
 
-Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume) {
+Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume, bool loop) {
 	debug (0, "Playing sound %d", id);
 	
 	SndHandle *handle = getHandle();
 	handle->type = kUsedHandle;
 	
-	Audio::AudioStream* audStream = NULL;
+	Audio::AudioStream *audStream = NULL;
 
 	switch (_vm->getGameType()) {
 	case GType_MYST:
@@ -136,6 +136,10 @@
 	}
 	
 	if (audStream) {
+		// Set the stream to loop here if it's requested
+		if (loop)
+			audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0);
+	
 		_vm->_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream, -1, volume);
 		return &handle->handle;
 	}
@@ -292,8 +296,12 @@
 	sndHandle.id = id;
 	_currentSLSTSounds.push_back(sndHandle);
 	
-	Audio::AudioStream *audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id), loop);
+	Audio::AudioStream *audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id));
 	
+	// Loop here if necessary
+	if (loop)
+		audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0);
+	
 	// The max mixer volume is 255 and the max Riven volume is 256. Just change it to 255.
 	if (volume == 256)
 		volume = 255;
@@ -329,7 +337,7 @@
 	return audStream;
 }
 
-Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stream, bool loop) {
+Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stream) {
 	bool foundData = false;
 	uint32 tag = 0;
 	ADPC_Chunk adpc;
@@ -419,6 +427,12 @@
 			data_chunk.loopStart = stream->readUint32BE();
 			data_chunk.loopEnd = stream->readUint32BE();
 
+			// NOTE: We currently ignore all of the loop parameters here. Myst uses the loop
+			// variable but the loopStart and loopEnd are always 0 and the size of the sample.
+			// Myst ME doesn't use the Mohawk Sound format and just standard WAVE files and
+			// therefore does not contain any of this metadata and we have to specify whether
+			// or not to loop elsewhere.
+
 			data_chunk.audio_data = (byte *)malloc(data_chunk.size);
 			stream->read(data_chunk.audio_data, data_chunk.size);
 			foundData = true;
@@ -436,20 +450,19 @@
 	// The sound in the DVD version of Riven is encoded in MPEG-2 Layer II or Intel DVI ADPCM
 	if (data_chunk.encoding == kCodecRaw) {
 		byte flags = Audio::FLAG_UNSIGNED;
+
 		if (data_chunk.channels == 2)
 			flags |= Audio::FLAG_STEREO;
-		if (data_chunk.loop == 0xFFFF || loop)
-			flags |= Audio::FLAG_LOOP;
-		return Audio::makeRawMemoryStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES, data_chunk.sample_rate, flags, data_chunk.loopStart, data_chunk.loopEnd);
+
+		return Audio::makeRawMemoryStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES, data_chunk.sample_rate, flags);
 	} else if (data_chunk.encoding == kCodecADPCM) {
 		Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES);
 		uint32 blockAlign = data_chunk.channels * data_chunk.bitsPerSample / 8;
-
-		return makeLoopingAudioStream(Audio::makeADPCMStream(dataStream, true, data_chunk.size, Audio::kADPCMIma, data_chunk.sample_rate, data_chunk.channels, blockAlign), loop ? 0 : 1);
+		return Audio::makeADPCMStream(dataStream, true, data_chunk.size, Audio::kADPCMIma, data_chunk.sample_rate, data_chunk.channels, blockAlign);
 	} else if (data_chunk.encoding == kCodecMPEG2) {
 #ifdef USE_MAD
 		Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES);
-		return Audio::makeLoopingAudioStream(Audio::makeMP3Stream(dataStream, DisposeAfterUse::YES), loop ? 0 : 1);
+		return Audio::makeMP3Stream(dataStream, DisposeAfterUse::YES);
 #else
 		warning ("MAD library not included - unable to play MP2 audio");
 #endif
@@ -460,7 +473,7 @@
 	return NULL;
 }
 
-Audio::AudioStream *Sound::makeOldMohawkWaveStream(Common::SeekableReadStream *stream, bool loop) {
+Audio::AudioStream *Sound::makeOldMohawkWaveStream(Common::SeekableReadStream *stream) {
 	uint16 header = stream->readUint16BE();
 	uint16 rate = 0;
 	uint32 size = 0;
@@ -481,9 +494,7 @@
 	stream->read(data, size);
 	delete stream;
 	
-	return Audio::makeLoopingAudioStream(
-			Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, Audio::FLAG_UNSIGNED),
-			loop ? 0 : 1);
+	return Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, Audio::FLAG_UNSIGNED);
 }
 
 SndHandle *Sound::getHandle() {

Modified: scummvm/trunk/engines/mohawk/sound.h
===================================================================
--- scummvm/trunk/engines/mohawk/sound.h	2010-01-22 03:50:49 UTC (rev 47430)
+++ scummvm/trunk/engines/mohawk/sound.h	2010-01-22 04:24:04 UTC (rev 47431)
@@ -121,7 +121,7 @@
 	~Sound();
 	
 	void loadRivenSounds(uint16 stack);
-	Audio::SoundHandle *playSound(uint16 id, bool mainSoundFile = true, byte volume = Audio::Mixer::kMaxChannelVolume);
+	Audio::SoundHandle *playSound(uint16 id, bool mainSoundFile = true, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
 	void playMidi(uint16 id);
 	void stopSound();
 	void pauseSound();
@@ -139,8 +139,8 @@
 	MidiParser *_midiParser;
 
 	static Audio::AudioStream *getCSAmtrakMusic(uint16 id);
-	static Audio::AudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream, bool loop = false);
-	static Audio::AudioStream *makeOldMohawkWaveStream(Common::SeekableReadStream *stream, bool loop = false);
+	static Audio::AudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream);
+	static Audio::AudioStream *makeOldMohawkWaveStream(Common::SeekableReadStream *stream);
 	void initMidi();
 
 	Common::Array<SndHandle> _handles;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list