DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/mt32/TVF.h
00001 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
00002  * Copyright (C) 2011, 2012, 2013 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
00003  *
00004  *  This program is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 2.1 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef MT32EMU_TVF_H
00019 #define MT32EMU_TVF_H
00020 
00021 namespace MT32Emu {
00022 
00023 class TVF {
00024 private:
00025         const Partial * const partial;
00026         LA32Ramp *cutoffModifierRamp;
00027         const TimbreParam::PartialParam *partialParam;
00028 
00029         Bit8u baseCutoff = 0;
00030         int keyTimeSubtraction = 0;
00031         unsigned int levelMult = 0;
00032 
00033         Bit8u target = 0;
00034         unsigned int phase = 0;
00035 
00036         void startRamp(Bit8u newTarget, Bit8u newIncrement, int newPhase);
00037         void nextPhase();
00038 
00039 public:
00040         TVF(const Partial *usePartial, LA32Ramp *useCutoffModifierRamp);
00041         void reset(const TimbreParam::PartialParam *newPartialParam, Bit32u basePitch);
00042         // Returns the base cutoff (without envelope modification).
00043         // The base cutoff is calculated when reset() is called and remains static
00044         // for the lifetime of the partial.
00045         // Barring bugs, the number returned is confirmed accurate
00046         // (based on specs from Mok).
00047         Bit8u getBaseCutoff() const;
00048         void handleInterrupt();
00049         void startDecay();
00050 
00051         void saveState( std::ostream &stream );
00052         void loadState( std::istream &stream );
00053 
00054         // savestate debugging
00055         void rawVerifyState( char *name, Synth *synth );
00056 };
00057 
00058 }
00059 
00060 #endif