1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2019 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef PARAMETERMODULATOR_H 26 #define PARAMETERMODULATOR_H 27 28 #include "basetypes.h" 29 class ModulatedParameter; 30 31 class ParameterModulator 32 { 33 public: 34 // Initialize a modulator 35 ParameterModulator(ModulatorData &modData, bool isPrst, int initialKey, int keyForComputation, int velForComputation); 36 37 // Try to merge an existing modulator with another one, return true if success 38 bool merge(ModulatorData &modData); 39 40 // Get info about the modulator getOuputType()41 quint16 getOuputType() { return _data.destOper; } getIndex()42 quint16 getIndex() { return _data.index; } 43 44 // Set the output 45 void setOutput(ModulatedParameter * parameter); 46 void setOutput(ParameterModulator * modulator); 47 48 // Compute the input based on midi values 49 void processInput(); 50 51 // Process the output and return true or return false if the input is not computed yet 52 bool processOutput(); 53 54 private: 55 // Input coming from another modulator 56 void setInput(double value); 57 58 // Add 1 to the number of input to wait before computing the result waitForAnInput()59 void waitForAnInput() { _inputNumber++; } 60 61 // Get a current input value 62 double getValue(SFModulator sfMod); 63 64 ModulatorData _data; 65 66 int _inputNumber, _inputCount; 67 bool _computed; 68 double _input1, _input2; 69 ModulatedParameter * _outputParameter; 70 ParameterModulator * _outputModulator; 71 bool _isPrst; 72 73 // Distinction between the initial key that triggered the sound (still useful for the aftertouch) 74 // and the value used for the modulators (keynum and velocity might be overridden) 75 int _initialKey, _keyForComputation, _velForComputation; 76 }; 77 78 #endif // PARAMETERMODULATOR_H 79