DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/mt32/PartialManager.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_PARTIALMANAGER_H
00019 #define MT32EMU_PARTIALMANAGER_H
00020 
00021 namespace MT32Emu {
00022 
00023 class Synth;
00024 
00025 class PartialManager {
00026 private:
00027         Synth *synth; // Only used for sending debug output
00028         Part **parts;
00029 
00030     Partial* partialTable[MT32EMU_MAX_PARTIALS] = {};
00031     Bit8u numReservedPartialsForPart[9] = {};
00032 
00033         bool abortFirstReleasingPolyWhereReserveExceeded(int minPart);
00034         bool abortFirstPolyPreferHeldWhereReserveExceeded(int minPart);
00035 
00036 public:
00037 
00038         PartialManager(Synth *useSynth, Part **useParts);
00039         ~PartialManager();
00040         Partial *allocPartial(int partNum);
00041         unsigned int getFreePartialCount(void);
00042         void getPerPartPartialUsage(unsigned int perPartPartialUsage[9]);
00043         bool freePartials(unsigned int needed, int partNum);
00044         unsigned int setReserve(Bit8u *rset);
00045         void deactivateAll();
00046         bool produceOutput(int i, float *leftBuf, float *rightBuf, Bit32u bufferLength);
00047         bool shouldReverb(int i);
00048         void clearAlreadyOutputed();
00049         const Partial *getPartial(unsigned int partialNum) const;
00050 };
00051 
00052 }
00053 
00054 #endif