aboutsummaryrefslogtreecommitdiff
path: root/backends/midi
diff options
context:
space:
mode:
Diffstat (limited to 'backends/midi')
-rw-r--r--backends/midi/mt32/part.cpp6
-rw-r--r--backends/midi/mt32/partial.cpp12
-rw-r--r--backends/midi/mt32/partial.h2
-rw-r--r--backends/midi/mt32/partialManager.cpp10
-rw-r--r--backends/midi/mt32/structures.h2
-rw-r--r--backends/midi/mt32/synth.cpp11
6 files changed, 23 insertions, 20 deletions
diff --git a/backends/midi/mt32/part.cpp b/backends/midi/mt32/part.cpp
index c240874143..5aee1202b2 100644
--- a/backends/midi/mt32/part.cpp
+++ b/backends/midi/mt32/part.cpp
@@ -46,7 +46,7 @@ bool dpoly::isActive() const {
return partials[0] != NULL || partials[1] != NULL || partials[2] != NULL || partials[3] != NULL;
}
-Bit64s dpoly::getAge() const {
+Bit32u dpoly::getAge() const {
for (int i = 0; i < 4; i++) {
if (partials[i] != NULL) {
return partials[i]->age;
@@ -582,7 +582,7 @@ void Part::stopNote(unsigned int key) {
// Find oldest poly... yes, the MT-32 can be reconfigured to kill different poly first
// This is simplest
int oldest = -1;
- Bit64s oldage = -1;
+ Bit32u oldage = 0;
for (int q = 0; q < MT32EMU_MAX_POLY; q++) {
dpoly *tpoly = &polyTable[q];
@@ -595,7 +595,7 @@ void Part::stopNote(unsigned int key) {
}
}
- if (oldest!=-1) {
+ if (oldest != -1) {
startDecayPoly(&polyTable[oldest]);
}
}
diff --git a/backends/midi/mt32/partial.cpp b/backends/midi/mt32/partial.cpp
index 34da887718..ef7b79376b 100644
--- a/backends/midi/mt32/partial.cpp
+++ b/backends/midi/mt32/partial.cpp
@@ -716,7 +716,7 @@ bool Partial::shouldReverb() {
}
Bit32u Partial::getAmpEnvelope() {
- Bit32u tc;
+ Bit32s tc;
EnvelopeStatus *tStat = &envs[EnvelopeType_amp];
@@ -726,8 +726,8 @@ Bit32u Partial::getAmpEnvelope() {
if (tStat->decaying) {
tc = tStat->envbase;
tc = (tc + ((tStat->envdist * tStat->envpos) / tStat->envsize));
- //if (tc < 0) // tc is unsigned, so it will *never* be less than 0
- // tc = 0;
+ if (tc < 0)
+ tc = 0;
if ((tStat->envpos >= tStat->envsize) || (tc == 0)) {
play = false;
// Don't have to worry about prevlevel storage or anything, this partial's about to die
@@ -814,7 +814,11 @@ PastCalc:
}
}
}
- return tc;
+ if (tc < 0) {
+ synth->printDebug("*** ERROR: tc < 0 (%d) at getAmpEnvelope()", tc);
+ tc = 0;
+ }
+ return (Bit32u)tc;
}
Bit32s Partial::getPitchEnvelope() {
diff --git a/backends/midi/mt32/partial.h b/backends/midi/mt32/partial.h
index 52b07bfeb1..0834a64c15 100644
--- a/backends/midi/mt32/partial.h
+++ b/backends/midi/mt32/partial.h
@@ -113,7 +113,7 @@ public:
Partial *pair;
bool alreadyOutputed;
- Bit64s age;
+ Bit32u age;
Partial(Synth *synth);
~Partial();
diff --git a/backends/midi/mt32/partialManager.cpp b/backends/midi/mt32/partialManager.cpp
index 01fb57b026..776276edda 100644
--- a/backends/midi/mt32/partialManager.cpp
+++ b/backends/midi/mt32/partialManager.cpp
@@ -219,7 +219,7 @@ bool PartialManager::freePartials(unsigned int needed, int partNum) {
}*/
// Then kill those with the lowest part priority -- oldest at the moment
while (needed > 0) {
- Bit64s prior = -1;
+ Bit32u prior = 0;
int priornum = -1;
for (int i = 0; i < MT32EMU_MAX_PARTIALS; i++) {
@@ -229,7 +229,7 @@ bool PartialManager::freePartials(unsigned int needed, int partNum) {
prior = mt32ram.system.reserveSettings[partialTable[i]->ownerPart];
priornum = i;
}*/
- if (partialTable[i]->age > prior) {
+ if (partialTable[i]->age >= prior) {
prior = partialTable[i]->age;
priornum = i;
}
@@ -245,11 +245,11 @@ bool PartialManager::freePartials(unsigned int needed, int partNum) {
// Kill off the oldest partials within this part
while (needed > 0) {
- Bit64s oldest = -1;
- Bit64s oldlist = -1;
+ Bit32u oldest = 0;
+ int oldlist = -1;
for (int i = 0; i < MT32EMU_MAX_PARTIALS; i++) {
if (partialTable[i]->getOwnerPart() == partNum && partialTable[i]->isActive()) {
- if (partialTable[i]->age > oldest) {
+ if (partialTable[i]->age >= oldest) {
oldest = partialTable[i]->age;
oldlist = i;
}
diff --git a/backends/midi/mt32/structures.h b/backends/midi/mt32/structures.h
index 047f69f8bd..b04d98b0fd 100644
--- a/backends/midi/mt32/structures.h
+++ b/backends/midi/mt32/structures.h
@@ -274,7 +274,7 @@ struct dpoly {
bool sustain;
bool isActive() const;
- Bit64s getAge() const;
+ Bit32u getAge() const;
};
}
diff --git a/backends/midi/mt32/synth.cpp b/backends/midi/mt32/synth.cpp
index 40812feef6..ef0766018c 100644
--- a/backends/midi/mt32/synth.cpp
+++ b/backends/midi/mt32/synth.cpp
@@ -278,7 +278,7 @@ bool Synth::loadPCMROM(const char *filename) {
return rc;
}
-struct TempPCMStruct
+struct ControlROMPCMStruct
{
Bit8u pos;
Bit8u len;
@@ -287,7 +287,7 @@ struct TempPCMStruct
};
void Synth::initPCMList() {
- TempPCMStruct *tps = (TempPCMStruct *)&controlROMData[0x3000];
+ ControlROMPCMStruct *tps = (ControlROMPCMStruct *)&controlROMData[0x3000];
for (int i = 0; i < 128; i++) {
int rAddr = tps[i].pos * 0x800;
int rLenExp = (tps[i].len & 0x70) >> 4;
@@ -322,11 +322,10 @@ void Synth::initRhythmTimbre(int timbreNum, const Bit8u *mem) {
}
void Synth::initRhythmTimbres() {
- //TempPCMStruct *tps = (TempPCMStruct *)&controlROMData[0x3000];
- //const Bit8u *drumMap = &controlROMData[0x3200];
+ const Bit8u *drumMap = &controlROMData[0x3200];
int timbreNum = 192;
- for (Bit16u i = 0x3200; i < 0x323C; i += 2) {
- Bit16u address = (controlROMData[i + 1] << 8) | controlROMData[i];
+ for (Bit16u i = 0; i < 60; i += 2) {
+ Bit16u address = (drumMap[i + 1] << 8) | drumMap[i];
initRhythmTimbre(timbreNum++, &controlROMData[address]);
}
}