aboutsummaryrefslogtreecommitdiff
path: root/backends/midi/mt32/partial.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/midi/mt32/partial.cpp')
-rw-r--r--backends/midi/mt32/partial.cpp12
1 files changed, 8 insertions, 4 deletions
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() {