[Scummvm-cvs-logs] CVS: scummvm/backends/midi/mt32 partial.cpp,1.13,1.14 synth.cpp,1.30,1.31 synth.h,1.11,1.12

Jerome Fisher kingguppy at users.sourceforge.net
Thu Dec 2 15:01:03 CET 2004


Update of /cvsroot/scummvm/scummvm/backends/midi/mt32
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29744

Modified Files:
	partial.cpp synth.cpp synth.h 
Log Message:
Synched with upstream (Munt 0.1.1).
Memory timbres are now loaded into the correct location again, and reaching the end of a PCM sample has been improved. The latter change is probably the only one relevant to ScummVM, and even that is unlikely to be audible.


Index: partial.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/partial.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- partial.cpp	28 Nov 2004 21:08:36 -0000	1.13
+++ partial.cpp	2 Dec 2004 23:00:14 -0000	1.14
@@ -102,7 +102,6 @@
 #else
 	float newPitchInt;
 	float newPitchFract = modff(newPitch, &newPitchInt);
-	synth->printDebug("Really: newPitch=%f, newPitchInt=%f, newPitchFract=%f", newPitch, newPitchInt, newPitchFract);
 	if (newPitchFract > 0.5f) {
 		newPitchInt += 1.0f;
 		newPitchFract -= 1.0f;
@@ -239,7 +238,7 @@
 		int delta;
 		// These two are only for PCM partials, obviously
 		PCMWaveEntry *pcmWave = NULL; // Initialise to please compiler
-		int pcmAddr = 0; // Initialise to please compiler
+		Bit32u pcmAddr = 0; // Initialise to please compiler
 
 		// Wrap positions or end if necessary
 		if (patchCache->PCMPartial) {
@@ -283,13 +282,22 @@
 			if (patchCache->PCMPartial) {
 				// Render PCM sample
 				int ra, rb, dist;
-				int taddr;
+				Bit32u taddr;
 				if (delta < 0x10000) {
 					// Linear sound interpolation
 					taddr = pcmAddr + partialOff.pcmplace;
 					ra = synth->romfile[taddr];
-					//FIXME:KG: Deal with condition that taddr + 1 is past PCM length
-					rb = synth->romfile[taddr + 1];
+					taddr++;
+					if (taddr == pcmAddr + pcmWave->len) {
+						// Past end of PCM
+						if (pcmWave->loop) {
+							rb = synth->romfile[pcmAddr];
+						} else {
+							rb = 0;
+						}
+					} else {
+						rb = synth->romfile[taddr];
+					}
 					dist = rb - ra;
 					sample = (ra + ((dist * (Bit32s)(partialOff.pcmoffset >> 8)) >> 8));
 				} else {
@@ -298,9 +306,19 @@
 					// a point.  This is too slow.  The following approximates this as fast as possible
 					int idelta = delta >> 16;
 					taddr = pcmAddr + partialOff.pcmplace;
-					ra = 0;
-					for (int ix = 0; ix < idelta; ix++)
+					ra = synth->romfile[taddr++];
+					for (int ix = 0; ix < idelta - 1; ix++) {
+						if (taddr == pcmAddr + pcmWave->len) {
+							// Past end of PCM
+							if (pcmWave->loop) {
+								taddr = pcmAddr;
+							} else {
+								// Behave as if all subsequent samples were 0
+								break;
+							}
+						}
 						ra += synth->romfile[taddr++];
+					}
 					sample = ra / idelta;
 				}
 			} else {

Index: synth.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/synth.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- synth.cpp	29 Nov 2004 02:21:35 -0000	1.30
+++ synth.cpp	2 Dec 2004 23:00:15 -0000	1.31
@@ -344,9 +344,17 @@
 		return false;
 
 	myProp = useProp;
+	if (useProp.baseDir != NULL) {
+		myProp.baseDir = new char[strlen(useProp.baseDir) + 1];
+		strcpy(myProp.baseDir, useProp.baseDir);
+	}
 
 	// This is to help detect bugs
 	memset(&mt32ram, '?', sizeof(mt32ram));
+	for (int i = 128; i < 192; i++) {
+		// If something sets a patch to point to an uninitialised memory timbre, don't play anything
+		mt32ram.timbres[i].timbre.common.pmute = 0;
+	}
 
 	printDebug("Loading Control ROM");
 	if (!loadControlROM("MT32_CONTROL.ROM")) {
@@ -476,7 +484,10 @@
 			parts[i] = NULL;
 		}
 	}
-
+	if (myProp.baseDir != NULL) {
+		delete myProp.baseDir;
+		myProp.baseDir = NULL;
+	}
 	isOpen = false;
 }
 
@@ -794,18 +805,7 @@
 		}
 		unsigned int firstTimbre = off / sizeof (MemParams::PaddedTimbre);
 		off %= sizeof (MemParams::PaddedTimbre);
-		switch (initmode) {
-			case 0:
-				// Write into first built-in timbre group
-				break;
-			case 1:
-				// Write into second built-in timbre group
-				firstTimbre += 64;
-				break;
-			default:
-				firstTimbre += 128;
-				// Write into user timbre group
-		}
+		firstTimbre += 128;
 		for (unsigned int m = 0; m < len; m++)
 			((Bit8u *)&mt32ram.timbres[firstTimbre])[off + m] = sysex[m];
 		unsigned int lastTimbre = firstTimbre + NUMTOUCHED(len + off, MemParams::PaddedTimbre) - 1;

Index: synth.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/synth.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- synth.h	28 Nov 2004 07:25:18 -0000	1.11
+++ synth.h	2 Dec 2004 23:00:15 -0000	1.12
@@ -133,7 +133,6 @@
 	float masterTune;
 	Bit16u masterVolume;
 
-	unsigned char initmode;
 	bool isOpen;
 
 	PartialManager *partialManager;





More information about the Scummvm-git-logs mailing list