1 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher 2 * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, either version 2.1 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef MT32EMU_POLY_H 19 #define MT32EMU_POLY_H 20 21 #include "globals.h" 22 #include "internals.h" 23 24 namespace MT32Emu { 25 26 class Part; 27 class Partial; 28 struct PatchCache; 29 30 class Poly { 31 private: 32 Part *part; 33 unsigned int key; 34 unsigned int velocity; 35 unsigned int activePartialCount; 36 bool sustain; 37 38 PolyState state; 39 40 Partial *partials[4]; 41 42 Poly *next; 43 44 public: 45 Poly(); 46 void setPart(Part *usePart); 47 void reset(unsigned int key, unsigned int velocity, bool sustain, Partial **partials); 48 bool noteOff(bool pedalHeld); 49 bool stopPedalHold(); 50 bool startDecay(); 51 bool startAbort(); 52 53 void backupCacheToPartials(PatchCache cache[4]); 54 55 unsigned int getKey() const; 56 unsigned int getVelocity() const; 57 bool canSustain() const; 58 PolyState getState() const; 59 unsigned int getActivePartialCount() const; 60 bool isActive() const; 61 62 void partialDeactivated(Partial *partial); 63 64 Poly *getNext() const; 65 void setNext(Poly *poly); 66 }; // class Poly 67 68 } // namespace MT32Emu 69 70 #endif // #ifndef MT32EMU_POLY_H 71