[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,1.32,1.33 imuse.h,1.8,1.9 sound.cpp,1.27,1.28 sound.h,1.9,1.10

Pawe? Ko?odziejski aquadran at users.sourceforge.net
Fri Oct 4 01:05:08 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv27203a

Modified Files:
	imuse.cpp imuse.h sound.cpp sound.h 
Log Message:
added looping voc samples in imuse(not tested)

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- imuse.cpp	3 Oct 2002 23:16:10 -0000	1.32
+++ imuse.cpp	4 Oct 2002 08:04:34 -0000	1.33
@@ -4866,8 +4866,8 @@
 				continue;
 			}
 
-			if ((_channel[l]._jump[0]._numLoops == 0) && (_channel[l]._isLoop == true)) {
-				_channel[l]._isLoop = false;
+			if ((_channel[l]._jump[0]._numLoops == 0) && (_channel[l]._isJump == true)) {
+				_channel[l]._isJump = false;
 			}
 
 			uint32 new_size = _channel[l]._mixerSize;
@@ -4881,11 +4881,15 @@
 				new_mixer = false;
 			}
 
-			if (_channel[l]._isLoop == false) {
+			if (_channel[l]._isJump == false) {
 				if (_channel[l]._offset + mixer_size > _channel[l]._size) {
 					new_size = _channel[l]._size - _channel[l]._offset;
-					_channel[l]._toBeRemoved = true;
-					mixer_size = new_size;
+					if (_channel[l]._numLoops > 0) {
+						_channel[l]._numLoops--;
+					} else {
+						_channel[l]._toBeRemoved = true;
+						mixer_size = new_size;
+					}
 				}
 			} else {
 				if (_channel[l]._jump[0]._numLoops != 500) {
@@ -4898,9 +4902,12 @@
 
 			byte *buf = (byte*)malloc(mixer_size);
 			memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
-			if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
+			if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isJump == true)) {
 				memcpy(buf + new_size, _channel[l]._data + _channel[l]._jump[0]._dest, mixer_size - new_size);
 			}
+			if ((_channel[l]._numLoops > 0) && (new_size != _channel[l]._mixerSize)) {
+				memcpy(buf + new_size, _channel[l]._data, mixer_size - new_size);
+			}
 
 			if (_channel[l]._volumeFade != -1) {
 				if (_channel[l]._volume > _channel[l]._volumeFade) {
@@ -4937,8 +4944,9 @@
 															 _channel[l]._freq, _channel[l]._mixerFlags);
 			}
 
-			if ((new_size != mixer_size) && (_channel[l]._isLoop == true)) {
+			if ((new_size != mixer_size) && (_channel[l]._isJump == true)) {
 				_channel[l]._offset = _channel[l]._jump[0]._dest + (mixer_size - new_size);
+			} else if ((_channel[l]._numLoops > 0) && (new_size != _channel[l]._mixerSize)) {
 			} else {
 				_channel[l]._offset += mixer_size;
 			}
@@ -4970,34 +4978,29 @@
 
 			if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
 				_channel[l]._bits = 8;
-				_channel[l]._channels = 1;
+				_channel[l]._channels = 2;
 				_channel[l]._mixerTrack = -1;
 				_channel[l]._mixerSize = (22050 / 5) * 2;
-				_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO;
-				byte * t_ptr= _scumm->_sound->readCreativeVocFile(ptr, size, _channel[l]._freq);
+				_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO | SoundMixer::FLAG_UNSIGNED;
+				byte * t_ptr= _scumm->_sound->readCreativeVocFile(ptr, size, _channel[l]._freq, _channel[l]._numLoops);
+
 				if (_channel[l]._freq == 22222) {
 					_channel[l]._freq = 22050;
+				} else if (_channel[l]._freq == 10989) {
+					_channel[l]._freq = 11025;
 				}
+				
 				if (_channel[l]._freq == 11025) {
 					_channel[l]._mixerSize /= 2;
 				}
-				if (_channel[l]._bits == 8) {
-					_channel[l]._mixerFlags |= SoundMixer::FLAG_UNSIGNED;
-					if (_channel[l]._channels == 1) {
-						size *= 2;
-						_channel[l]._channels = 2;
-						_channel[l]._data = (byte *)malloc(size);
-						for (t = 0; t < size / 2; t++) {
-							*(_channel[l]._data + t * 2 + 0) = *(t_ptr + t);
-							*(_channel[l]._data + t * 2 + 1) = *(t_ptr + t);
-						}
-					} else {
-						_channel[l]._data = (byte *)malloc(size);
-						memcpy(_channel[l]._data, t_ptr, size);
-					}
-					free(t_ptr);
-					_channel[l]._size = size;
+				size *= 2;
+				_channel[l]._data = (byte *)malloc(size);
+				for (t = 0; t < size / 2; t++) {
+					*(_channel[l]._data + t * 2 + 0) = *(t_ptr + t);
+					*(_channel[l]._data + t * 2 + 1) = *(t_ptr + t);
 				}
+				free(t_ptr);
+				_channel[l]._size = size;
 			} else if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')) {
 				ptr += 16;
 				for (;;) {
@@ -5038,7 +5041,7 @@
 							_channel[l]._jump[_channel[l]._numJumps]._dest = READ_BE_UINT32(ptr); ptr += 4;
 							_channel[l]._jump[_channel[l]._numJumps]._id = READ_BE_UINT32(ptr); ptr += 4;
 							_channel[l]._jump[_channel[l]._numJumps]._numLoops = READ_BE_UINT32(ptr); ptr += 4;
-							_channel[l]._isLoop = true;
+							_channel[l]._isJump = true;
 							_channel[l]._numJumps++;
 						break;
 						case MKID_BE('DATA'):

Index: imuse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- imuse.h	3 Oct 2002 07:42:25 -0000	1.8
+++ imuse.h	4 Oct 2002 08:04:34 -0000	1.9
@@ -83,7 +83,8 @@
 		int8 _volumeRight;
 		int8 _volume;
 		int8 _volumeFade;
-		bool _isLoop;
+		bool _isJump;
+		uint32 _numLoops;
 		uint32 _offsetStop;
 		jump _jump[MAX_IMUSE_JUMPS];
 		uint32 _numJumps;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- sound.cpp	3 Oct 2002 23:16:10 -0000	1.27
+++ sound.cpp	4 Oct 2002 08:04:34 -0000	1.28
@@ -125,19 +125,19 @@
 	_soundQuePos = 0;
 }
 
-byte * Sound::readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate) {
+byte * Sound::readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate, uint32 & loops) {
 	assert(strncmp((char*)ptr, "Creative Voice File\x1A", 20) == 0);
 	int32 offset = READ_LE_UINT16(ptr + 20);
-	short version = READ_LE_UINT16(ptr + 22);
-	short code = READ_LE_UINT16(ptr + 24);
+	int16 version = READ_LE_UINT16(ptr + 22);
+	int16 code = READ_LE_UINT16(ptr + 24);
 	assert(version == 0x010A || version == 0x0114);
 	assert(code == ~version + 0x1234);
 	bool quit = 0;
-	byte * ret_sound = 0; size = 0;
+	byte * ret_sound = 0; size = 0, loops = 0;
 	while(!quit) {
 		int len = READ_LE_UINT32(ptr + offset);
 		offset += 4;
-		int code = len & 0xFF;		// FIXME not sure this is endian correct
+		int code = len & 0xFF;
 		len >>= 8;
 		switch(code) {
 			case 0: quit = 1; break;
@@ -160,7 +160,7 @@
 				}
 				} break;
 			case 6:	// begin of loop
-				debug(3, "loops in Creative files not supported");
+				loops = len + 1;
 				break;
 			case 7:	// end of loop
 				break;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sound.h	3 Oct 2002 23:16:10 -0000	1.9
+++ sound.h	4 Oct 2002 08:04:35 -0000	1.10
@@ -123,7 +123,7 @@
 	void bundleMusicHandler(Scumm * scumm);
 	void stopBundleMusic();
 	void playBundleSound(char *sound);
-	byte * readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate);
+	byte * readCreativeVocFile(byte * ptr, uint32 & size, uint32 & rate, uint32 & loops);
 	int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned);
 	int playSfxSound_MP3(void *sound, uint32 size);
 





More information about the Scummvm-git-logs mailing list