diff options
Diffstat (limited to 'audio/softsynth/mt32/Part.cpp')
-rwxr-xr-x[-rw-r--r--] | audio/softsynth/mt32/Part.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/audio/softsynth/mt32/Part.cpp b/audio/softsynth/mt32/Part.cpp index cffc3ed744..c4d5b94551 100644..100755 --- a/audio/softsynth/mt32/Part.cpp +++ b/audio/softsynth/mt32/Part.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher - * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * Copyright (C) 2011-2016 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 @@ -15,12 +15,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -//#include <cstdio> -//#include <cstring> +#include <cstdio> +#include <cstring> -#include "mt32emu.h" #include "internals.h" + +#include "Part.h" +#include "Partial.h" #include "PartialManager.h" +#include "Poly.h" +#include "Synth.h" namespace MT32Emu { @@ -112,7 +116,7 @@ Bit32s Part::getPitchBend() const { void Part::setBend(unsigned int midiBend) { // CONFIRMED: - pitchBend = (((signed)midiBend - 8192) * pitchBenderRange) >> 14; // PORTABILITY NOTE: Assumes arithmetic shift + pitchBend = ((signed(midiBend) - 8192) * pitchBenderRange) >> 14; // PORTABILITY NOTE: Assumes arithmetic shift } Bit8u Part::getModulation() const { @@ -120,7 +124,7 @@ Bit8u Part::getModulation() const { } void Part::setModulation(unsigned int midiModulation) { - modulation = (Bit8u)midiModulation; + modulation = Bit8u(midiModulation); } void Part::resetAllControllers() { @@ -162,7 +166,7 @@ void Part::refresh() { patchCache[t].reverb = patchTemp->patch.reverbSwitch > 0; } memcpy(currentInstr, timbreTemp->common.name, 10); - synth->newTimbreSet(partNum, patchTemp->patch.timbreGroup, currentInstr); + synth->newTimbreSet(partNum, patchTemp->patch.timbreGroup, patchTemp->patch.timbreNum, currentInstr); updatePitchBenderRange(); } @@ -255,26 +259,26 @@ void Part::cacheTimbre(PatchCache cache[4], const TimbreParam *timbre) { switch (t) { case 0: - cache[t].PCMPartial = (PartialStruct[(int)timbre->common.partialStructure12] & 0x2) ? true : false; - cache[t].structureMix = PartialMixStruct[(int)timbre->common.partialStructure12]; + cache[t].PCMPartial = (PartialStruct[int(timbre->common.partialStructure12)] & 0x2) ? true : false; + cache[t].structureMix = PartialMixStruct[int(timbre->common.partialStructure12)]; cache[t].structurePosition = 0; cache[t].structurePair = 1; break; case 1: - cache[t].PCMPartial = (PartialStruct[(int)timbre->common.partialStructure12] & 0x1) ? true : false; - cache[t].structureMix = PartialMixStruct[(int)timbre->common.partialStructure12]; + cache[t].PCMPartial = (PartialStruct[int(timbre->common.partialStructure12)] & 0x1) ? true : false; + cache[t].structureMix = PartialMixStruct[int(timbre->common.partialStructure12)]; cache[t].structurePosition = 1; cache[t].structurePair = 0; break; case 2: - cache[t].PCMPartial = (PartialStruct[(int)timbre->common.partialStructure34] & 0x2) ? true : false; - cache[t].structureMix = PartialMixStruct[(int)timbre->common.partialStructure34]; + cache[t].PCMPartial = (PartialStruct[int(timbre->common.partialStructure34)] & 0x2) ? true : false; + cache[t].structureMix = PartialMixStruct[int(timbre->common.partialStructure34)]; cache[t].structurePosition = 0; cache[t].structurePair = 3; break; case 3: - cache[t].PCMPartial = (PartialStruct[(int)timbre->common.partialStructure34] & 0x1) ? true : false; - cache[t].structureMix = PartialMixStruct[(int)timbre->common.partialStructure34]; + cache[t].PCMPartial = (PartialStruct[int(timbre->common.partialStructure34)] & 0x1) ? true : false; + cache[t].structureMix = PartialMixStruct[int(timbre->common.partialStructure34)]; cache[t].structurePosition = 1; cache[t].structurePair = 2; break; @@ -308,7 +312,7 @@ const char *Part::getName() const { void Part::setVolume(unsigned int midiVolume) { // CONFIRMED: This calculation matches the table used in the control ROM - patchTemp->outputLevel = (Bit8u)(midiVolume * 100 / 127); + patchTemp->outputLevel = Bit8u(midiVolume * 100 / 127); //synth->printDebug("%s (%s): Set volume to %d", name, currentInstr, midiVolume); } @@ -322,7 +326,7 @@ Bit8u Part::getExpression() const { void Part::setExpression(unsigned int midiExpression) { // CONFIRMED: This calculation matches the table used in the control ROM - expression = (Bit8u)(midiExpression * 100 / 127); + expression = Bit8u(midiExpression * 100 / 127); } void RhythmPart::setPan(unsigned int midiPan) { @@ -337,9 +341,9 @@ void Part::setPan(unsigned int midiPan) { // NOTE: Panning is inverted compared to GM. // CM-32L: Divide by 8.5 - patchTemp->panpot = (Bit8u)((midiPan << 3) / 68); + patchTemp->panpot = Bit8u((midiPan << 3) / 68); // FIXME: MT-32: Divide by 9 - //patchTemp->panpot = (Bit8u)(midiPan / 9); + //patchTemp->panpot = Bit8u(midiPan / 9); //synth->printDebug("%s (%s): Set pan to %d", name, currentInstr, panpot); } @@ -507,7 +511,7 @@ void Part::playPoly(const PatchCache cache[4], const MemParams::RhythmTemp *rhyt #if MT32EMU_MONITOR_PARTIALS > 1 synth->printPartialUsage(); #endif - synth->polyStateChanged(partNum); + synth->reportHandler->onPolyStateChanged(Bit8u(partNum)); } void Part::allNotesOff() { @@ -593,16 +597,14 @@ void Part::partialDeactivated(Poly *poly) { if (!poly->isActive()) { activePolys.remove(poly); synth->partialManager->polyFreed(poly); - synth->polyStateChanged(partNum); + synth->reportHandler->onPolyStateChanged(Bit8u(partNum)); } } -//#define POLY_LIST_DEBUG - PolyList::PolyList() : firstPoly(NULL), lastPoly(NULL) {} bool PolyList::isEmpty() const { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if ((firstPoly == NULL || lastPoly == NULL) && firstPoly != lastPoly) { printf("PolyList: desynchronised firstPoly & lastPoly pointers\n"); } @@ -619,7 +621,7 @@ Poly *PolyList::getLast() const { } void PolyList::prepend(Poly *poly) { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if (poly->getNext() != NULL) { printf("PolyList: Non-NULL next field in a Poly being prepended is ignored\n"); } @@ -632,14 +634,14 @@ void PolyList::prepend(Poly *poly) { } void PolyList::append(Poly *poly) { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if (poly->getNext() != NULL) { printf("PolyList: Non-NULL next field in a Poly being appended is ignored\n"); } #endif poly->setNext(NULL); if (lastPoly != NULL) { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if (lastPoly->getNext() != NULL) { printf("PolyList: Non-NULL next field in the lastPoly\n"); } @@ -656,7 +658,7 @@ Poly *PolyList::takeFirst() { Poly *oldFirst = firstPoly; firstPoly = oldFirst->getNext(); if (firstPoly == NULL) { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if (lastPoly != oldFirst) { printf("PolyList: firstPoly != lastPoly in a list with a single Poly\n"); } @@ -675,7 +677,7 @@ void PolyList::remove(Poly * const polyToRemove) { for (Poly *poly = firstPoly; poly != NULL; poly = poly->getNext()) { if (poly->getNext() == polyToRemove) { if (polyToRemove == lastPoly) { -#ifdef POLY_LIST_DEBUG +#ifdef MT32EMU_POLY_LIST_DEBUG if (lastPoly->getNext() != NULL) { printf("PolyList: Non-NULL next field in the lastPoly\n"); } @@ -689,4 +691,4 @@ void PolyList::remove(Poly * const polyToRemove) { } } -} +} // namespace MT32Emu |