DOSBox-X
|
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_POLY_H 00019 #define MT32EMU_POLY_H 00020 00021 #include "FileStream.h" 00022 00023 namespace MT32Emu { 00024 00025 class Synth; 00026 class Part; 00027 00028 enum PolyState { 00029 POLY_Playing, 00030 POLY_Held, // This marks keys that have been released on the keyboard, but are being held by the pedal 00031 POLY_Releasing, 00032 POLY_Inactive 00033 }; 00034 00035 class Poly { 00036 private: 00037 Synth *synth; 00038 Part *part; 00039 unsigned int key; 00040 unsigned int velocity; 00041 unsigned int activePartialCount; 00042 bool sustain; 00043 00044 PolyState state; 00045 00046 Partial* partials[4] = {}; 00047 00048 Poly *next; 00049 00050 public: 00051 Poly(Synth *useSynth, Part *usePart); 00052 void reset(unsigned int newKey, unsigned int newVelocity, bool newSustain, Partial **newPartials); 00053 bool noteOff(bool pedalHeld); 00054 bool stopPedalHold(); 00055 bool startDecay(); 00056 bool startAbort(); 00057 void terminate(); 00058 00059 void backupCacheToPartials(PatchCache cache[4]); 00060 00061 unsigned int getKey() const; 00062 unsigned int getVelocity() const; 00063 bool canSustain() const; 00064 PolyState getState() const; 00065 unsigned int getActivePartialCount() const; 00066 bool isActive() const; 00067 00068 void partialDeactivated(Partial *partial); 00069 00070 Poly *getNext(); 00071 void setNext(Poly *poly); 00072 00073 void saveState( std::ostream &stream ); 00074 void loadState( std::istream &stream ); 00075 00076 // savestate debugging 00077 void rawVerifyState( char *name, Synth *synth ); 00078 }; 00079 00080 } 00081 00082 #endif /* POLY_H_ */