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
This commit is contained in:
Jerome Fisher 2004-12-02 23:00:15 +00:00
parent 5884c6735d
commit 470a83e024
3 changed files with 38 additions and 21 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -133,7 +133,6 @@ private:
float masterTune;
Bit16u masterVolume;
unsigned char initmode;
bool isOpen;
PartialManager *partialManager;