aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth/mt32/TVA.cpp
diff options
context:
space:
mode:
authorColin Snover2016-11-25 12:24:08 -0600
committerColin Snover2016-11-25 12:24:08 -0600
commitdf4a503622a524ad8ef47e1c325ac4a711549921 (patch)
tree29ac9e6d51fd4cd17e4ebe9d1f66ff93abd0cd9d /audio/softsynth/mt32/TVA.cpp
parentb4dbd6d3c275097b4be964b7da4478ff930cbaa7 (diff)
downloadscummvm-rg350-df4a503622a524ad8ef47e1c325ac4a711549921.tar.gz
scummvm-rg350-df4a503622a524ad8ef47e1c325ac4a711549921.tar.bz2
scummvm-rg350-df4a503622a524ad8ef47e1c325ac4a711549921.zip
Revert "MT32: Update Munt to 2.0.0"
This reverts commit b4dbd6d3c275097b4be964b7da4478ff930cbaa7.
Diffstat (limited to 'audio/softsynth/mt32/TVA.cpp')
-rw-r--r--audio/softsynth/mt32/TVA.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/audio/softsynth/mt32/TVA.cpp b/audio/softsynth/mt32/TVA.cpp
index 465480a24e..894e53f14a 100644
--- a/audio/softsynth/mt32/TVA.cpp
+++ b/audio/softsynth/mt32/TVA.cpp
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -19,23 +19,19 @@
* This class emulates the calculations performed by the 8095 microcontroller in order to configure the LA-32's amplitude ramp for a single partial at each stage of its TVA envelope.
* Unless we introduced bugs, it should be pretty much 100% accurate according to Mok's specifications.
*/
+//#include <cmath>
+#include "mt32emu.h"
+#include "mmath.h"
#include "internals.h"
-#include "TVA.h"
-#include "Part.h"
-#include "Partial.h"
-#include "Poly.h"
-#include "Synth.h"
-#include "Tables.h"
-
namespace MT32Emu {
// CONFIRMED: Matches a table in ROM - haven't got around to coming up with a formula for it yet.
static Bit8u biasLevelToAmpSubtractionCoeff[13] = {255, 187, 137, 100, 74, 54, 40, 29, 21, 15, 10, 5, 0};
TVA::TVA(const Partial *usePartial, LA32Ramp *useAmpRamp) :
- partial(usePartial), ampRamp(useAmpRamp), system(&usePartial->getSynth()->mt32ram.system), phase(TVA_PHASE_DEAD) {
+ partial(usePartial), ampRamp(useAmpRamp), system_(&usePartial->getSynth()->mt32ram.system), phase(TVA_PHASE_DEAD) {
}
void TVA::startRamp(Bit8u newTarget, Bit8u newIncrement, int newPhase) {
@@ -99,11 +95,11 @@ static int calcVeloAmpSubtraction(Bit8u veloSensitivity, unsigned int velocity)
return absVelocityMult - (velocityMult >> 8); // PORTABILITY NOTE: Assumes arithmetic shift
}
-static int calcBasicAmp(const Tables *tables, const Partial *partial, const MemParams::System *system, const TimbreParam::PartialParam *partialParam, const MemParams::PatchTemp *patchTemp, const MemParams::RhythmTemp *rhythmTemp, int biasAmpSubtraction, int veloAmpSubtraction, Bit8u expression) {
+static int calcBasicAmp(const Tables *tables, const Partial *partial, const MemParams::System *system_, const TimbreParam::PartialParam *partialParam, const MemParams::PatchTemp *patchTemp, const MemParams::RhythmTemp *rhythmTemp, int biasAmpSubtraction, int veloAmpSubtraction, Bit8u expression) {
int amp = 155;
if (!partial->isRingModulatingSlave()) {
- amp -= tables->masterVolToAmpSubtraction[system->masterVol];
+ amp -= tables->masterVolToAmpSubtraction[system_->masterVol];
if (amp < 0) {
return 0;
}
@@ -144,7 +140,7 @@ static int calcBasicAmp(const Tables *tables, const Partial *partial, const MemP
return amp;
}
-static int calcKeyTimeSubtraction(Bit8u envTimeKeyfollow, int key) {
+int calcKeyTimeSubtraction(Bit8u envTimeKeyfollow, int key) {
if (envTimeKeyfollow == 0) {
return 0;
}
@@ -169,7 +165,7 @@ void TVA::reset(const Part *newPart, const TimbreParam::PartialParam *newPartial
biasAmpSubtraction = calcBiasAmpSubtractions(partialParam, key);
veloAmpSubtraction = calcVeloAmpSubtraction(partialParam->tva.veloSensitivity, velocity);
- int newTarget = calcBasicAmp(tables, partial, system, partialParam, patchTemp, newRhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
+ int newTarget = calcBasicAmp(tables, partial, system_, partialParam, patchTemp, newRhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
int newPhase;
if (partialParam->tva.envTime[0] == 0) {
// Initially go to the TVA_PHASE_ATTACK target amp, and spend the next phase going from there to the TVA_PHASE_2 target amp
@@ -221,7 +217,7 @@ void TVA::recalcSustain() {
}
// We're sustaining. Recalculate all the values
const Tables *tables = &Tables::getInstance();
- int newTarget = calcBasicAmp(tables, partial, system, partialParam, patchTemp, rhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
+ int newTarget = calcBasicAmp(tables, partial, system_, partialParam, patchTemp, rhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
newTarget += partialParam->tva.envLevel[3];
// Since we're in TVA_PHASE_SUSTAIN at this point, we know that target has been reached and an interrupt fired, so we can rely on it being the current amp.
int targetDelta = newTarget - target;
@@ -283,7 +279,7 @@ void TVA::nextPhase() {
int envPointIndex = phase;
if (!allLevelsZeroFromNowOn) {
- newTarget = calcBasicAmp(tables, partial, system, partialParam, patchTemp, rhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
+ newTarget = calcBasicAmp(tables, partial, system_, partialParam, patchTemp, rhythmTemp, biasAmpSubtraction, veloAmpSubtraction, part->getExpression());
if (newPhase == TVA_PHASE_SUSTAIN || newPhase == TVA_PHASE_RELEASE) {
if (partialParam->tva.envLevel[3] == 0) {
@@ -367,4 +363,4 @@ void TVA::nextPhase() {
startRamp((Bit8u)newTarget, (Bit8u)newIncrement, newPhase);
}
-} // namespace MT32Emu
+}