aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Fisher2004-12-02 23:00:15 +0000
committerJerome Fisher2004-12-02 23:00:15 +0000
commit470a83e024ac06edf21ffc7cd979da5f2dde9a8b (patch)
tree24f0bbba2ba5cc4f310f008c64cb52037b34ba0a
parent5884c6735dc911fcf732b564324feebc4cf1c0cf (diff)
downloadscummvm-rg350-470a83e024ac06edf21ffc7cd979da5f2dde9a8b.tar.gz
scummvm-rg350-470a83e024ac06edf21ffc7cd979da5f2dde9a8b.tar.bz2
scummvm-rg350-470a83e024ac06edf21ffc7cd979da5f2dde9a8b.zip
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. svn-id: r15972
-rw-r--r--backends/midi/mt32/partial.cpp32
-rw-r--r--backends/midi/mt32/synth.cpp26
-rw-r--r--backends/midi/mt32/synth.h1
3 files changed, 38 insertions, 21 deletions
diff --git a/backends/midi/mt32/partial.cpp b/backends/midi/mt32/partial.cpp
index ef7b79376b..32ff9e9af7 100644
--- a/backends/midi/mt32/partial.cpp
+++ b/backends/midi/mt32/partial.cpp
@@ -102,7 +102,6 @@ void Partial::initKeyFollow(int key) {
#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 @@ Bit16s *Partial::generateSamples(long length) {
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 @@ Bit16s *Partial::generateSamples(long length) {
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 @@ Bit16s *Partial::generateSamples(long length) {
// 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 {
diff --git a/backends/midi/mt32/synth.cpp b/backends/midi/mt32/synth.cpp
index b2e4e31048..1ba543b581 100644
--- a/backends/midi/mt32/synth.cpp
+++ b/backends/midi/mt32/synth.cpp
@@ -344,9 +344,17 @@ bool Synth::open(SynthProperties &useProp) {
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 @@ void Synth::close(void) {
parts[i] = NULL;
}
}
-
+ if (myProp.baseDir != NULL) {
+ delete myProp.baseDir;
+ myProp.baseDir = NULL;
+ }
isOpen = false;
}
@@ -794,18 +805,7 @@ void Synth::playSysexWithoutHeader(unsigned char device, const Bit8u *sysex, Bit
}
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;
diff --git a/backends/midi/mt32/synth.h b/backends/midi/mt32/synth.h
index a944a3fc23..1501593cbd 100644
--- a/backends/midi/mt32/synth.h
+++ b/backends/midi/mt32/synth.h
@@ -133,7 +133,6 @@ private:
float masterTune;
Bit16u masterVolume;
- unsigned char initmode;
bool isOpen;
PartialManager *partialManager;