1 /* 2 ADnoteParameters.h - Parameters for ADnote (ADsynth) 3 4 Original ZynAddSubFX author Nasca Octavian Paul 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Copyright 2009-2011, Alan Calvert 7 Copyright 2017-2018, Will Godfrey 8 Copyright 2020-2021 Kristian Amlie, Will Godfrey 9 10 This file is part of yoshimi, which is free software: you can redistribute 11 it and/or modify it under the terms of the GNU Library General Public 12 License as published by the Free Software Foundation; either version 2 of 13 the License, or (at your option) any later version. 14 15 yoshimi is distributed in the hope that it will be useful, but WITHOUT ANY 16 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 17 FOR A PARTICULAR PURPOSE. See the GNU General Public License (version 2 or 18 later) for more details. 19 20 You should have received a copy of the GNU General Public License along with 21 yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin 22 Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 24 This file is derivative of ZynAddSubFX original code. 25 26 */ 27 28 #ifndef AD_NOTE_PARAMETERS_H 29 #define AD_NOTE_PARAMETERS_H 30 31 #include "Params/EnvelopeParams.h" 32 #include "Params/LFOParams.h" 33 #include "Params/FilterParams.h" 34 #include "Params/OscilParameters.h" 35 #include "Synth/Resonance.h" 36 #include "Synth/OscilGen.h" 37 #include "Misc/XMLwrapper.h" 38 #include "DSP/FFTwrapper.h" 39 #include "Params/Presets.h" 40 41 enum FMTYPE { NONE, MORPH, RING_MOD, PHASE_MOD, FREQ_MOD, PW_MOD }; 42 43 extern int ADnote_unison_sizes[]; 44 45 class SynthEngine; 46 47 /*****************************************************************/ 48 /* GLOBAL PARAMETERS */ 49 /*****************************************************************/ 50 51 struct ADnoteGlobalParam { 52 bool PStereo; 53 54 // Frequency global parameters 55 unsigned short int PDetune; // fine detune 56 unsigned short int PCoarseDetune; // coarse detune + octave 57 unsigned char PDetuneType; // detune type 58 unsigned char PBandwidth; // how much the relative fine detunes of 59 // the voices are changed 60 EnvelopeParams *FreqEnvelope; // Frequency Envelope 61 LFOParams *FreqLfo; // Frequency LFO 62 63 // Amplitude global parameters 64 char PPanning; // 1 - left, 64 - center, 127 - right 65 bool PRandom; 66 char PWidth; 67 float pangainL; // derived from PPanning 68 float pangainR; // ^ 69 unsigned char PVolume; 70 unsigned char PAmpVelocityScaleFunction; 71 unsigned char PPunchStrength; 72 unsigned char PPunchTime; 73 unsigned char PPunchStretch; 74 unsigned char PPunchVelocitySensing; 75 76 EnvelopeParams *AmpEnvelope; 77 LFOParams *AmpLfo; 78 79 // Adjustment factor for anti-pop fadein 80 unsigned char Fadein_adjustment; 81 82 FilterParams *GlobalFilter; // Filter global parameters 83 unsigned char PFilterVelocityScale; // Filter velocity sensing 84 unsigned char PFilterVelocityScaleFunction; 85 EnvelopeParams *FilterEnvelope; 86 LFOParams *FilterLfo; 87 Resonance *Reson; 88 unsigned char Hrandgrouping; // how the randomness is applied to the harmonics 89 // on more voices using the same oscillator 90 }; 91 92 93 struct ADnoteVoiceParam { // Voice parameters 94 unsigned char Enabled; 95 unsigned char Unison_size; // How many subvoices are used in this voice 96 unsigned char Unison_frequency_spread; // How subvoices are spread 97 unsigned char Unison_phase_randomness; // How much phase randomization 98 unsigned char Unison_stereo_spread; // Stereo spread of the subvoices 99 unsigned char Unison_vibratto; // Vibratto of the subvoices (which makes the unison more "natural") 100 unsigned char Unison_vibratto_speed; // Medium speed of the vibratto of the subvoices 101 unsigned char Unison_invert_phase; // Unison invert phase 102 // 0 = none, 1 = random, 2 = 50%, 3 = 33%, 4 = 25% 103 unsigned char Type; // Type of the voice 0 = Sound, 1 = Noise 104 unsigned char PDelay; // Voice Delay 105 unsigned char Presonance; // If resonance is enabled for this voice 106 short int Pextoscil, // What external oscil should I use, 107 PextFMoscil; // -1 for internal POscil & POscilFM 108 // it is not allowed that the externoscil, 109 // externFMoscil => current voice 110 unsigned char Poscilphase, PFMoscilphase; // oscillator phases 111 unsigned char Pfilterbypass; // filter bypass 112 OscilParameters *POscil; 113 OscilGen *OscilSmp; 114 115 // Frequency parameters 116 unsigned char Pfixedfreq; // If the base frequency is fixed to 440 Hz 117 unsigned char PfixedfreqET; // Equal temperate (this is used only if the 118 // Pfixedfreq is enabled). If this parameter is 0, 119 // the frequency is fixed (to 440 Hz); if this 120 // parameter is 64, 1 MIDI halftone -> 1 frequency 121 // halftone 122 unsigned short int PDetune; 123 unsigned short int PCoarseDetune; 124 unsigned char PDetuneType; 125 126 unsigned char PBendAdjust; // Pitch Bend 127 unsigned char POffsetHz; 128 129 unsigned char PFreqEnvelopeEnabled; // Frequency Envelope 130 EnvelopeParams *FreqEnvelope; 131 132 unsigned char PFreqLfoEnabled; // Frequency LFO 133 LFOParams *FreqLfo; 134 135 // Amplitude parameters 136 unsigned char PPanning; // 1 - left, 64 - center, 127 - right 137 // panning is ignored if the instrument is mono 138 bool PRandom; 139 char PWidth; 140 float pangainL; // derived from PPanning 141 float pangainR; // ^ 142 unsigned char PVolume; 143 unsigned char PVolumeminus; // reverse voice phase relative to others 144 145 unsigned char PAmpVelocityScaleFunction; // Velocity sensing 146 147 unsigned char PAmpEnvelopeEnabled; // Amplitude Envelope 148 EnvelopeParams *AmpEnvelope; 149 150 unsigned char PAmpLfoEnabled; // Amplitude LFO 151 LFOParams *AmpLfo; 152 153 // Filter parameters 154 unsigned char PFilterEnabled; // Voice Filter 155 FilterParams *VoiceFilter; 156 157 unsigned char PFilterEnvelopeEnabled; // Filter Envelope 158 EnvelopeParams *FilterEnvelope; 159 160 unsigned char PFilterLfoEnabled; // LFO Envelope 161 LFOParams *FilterLfo; 162 163 unsigned char PFilterVelocityScale; 164 unsigned char PFilterVelocityScaleFunction; 165 166 167 short int PVoice; // Voice that I use as external oscillator. 168 // It is -1 if I use POscil(default). 169 // It may not be equal or bigger than current voice 170 171 // Modullator parameters 172 unsigned char PFMEnabled; // 0 = off, 1 = Morph, 2 = RM, 3 = PM, 4 = FM, 5 = PWM 173 bool PFMringToSide; // allow carrier through 174 short int PFMVoice; // Voice that I use as modullator instead of POscilFM. 175 // It is -1 if I use POscilFM(default). 176 // It may not be equal or bigger than current voice 177 OscilParameters *POscilFM;// Modullator oscillator 178 OscilGen *FMSmp; 179 180 unsigned char PFMVolume; // Modulator Volume 181 unsigned char PFMVolumeDamp; // Modulator damping at higher frequencies 182 unsigned char PFMVelocityScaleFunction; // Modulator Velocity Sensing 183 unsigned char PFMDetuneFromBaseOsc; // Whether we inherit the base oscillator's detuning 184 unsigned short int PFMDetune; // Fine Detune of the Modulator 185 unsigned short int PFMCoarseDetune; // Coarse Detune of the Modulator 186 unsigned char PFMDetuneType; // The detune type 187 unsigned char PFMFixedFreq; // FM base freq fixed at 440Hz 188 unsigned char PFMFreqEnvelopeEnabled; // Frequency Envelope of the Modulator 189 EnvelopeParams *FMFreqEnvelope; 190 unsigned char PFMAmpEnvelopeEnabled; // Frequency Envelope of the Modulator 191 EnvelopeParams *FMAmpEnvelope; 192 }; 193 194 195 class ADnoteParameters : public Presets 196 { 197 public: 198 ADnoteParameters(FFTwrapper *fft_, SynthEngine *_synth); 199 ~ADnoteParameters(); 200 void defaults(void); 201 void add2XML(XMLwrapper *xml); 202 void getfromXML(XMLwrapper *xml); 203 float getLimits(CommandBlock *getData); 204 float getBandwidthDetuneMultiplier(void); 205 float getUnisonFrequencySpreadCents(int nvoice); 206 void setGlobalPan(char pan, unsigned char panLaw); 207 void setVoicePan(int voice, char pan, unsigned char panLaw); 208 ADnoteGlobalParam GlobalPar; 209 ADnoteVoiceParam VoicePar[NUM_VOICES]; 210 static int ADnote_unison_sizes[15]; 211 212 private: 213 void defaults(int n); // n is the nvoice 214 void enableVoice(int nvoice); 215 void killVoice(int nvoice); 216 void add2XMLsection(XMLwrapper *xml, int n); 217 void getfromXMLsection(XMLwrapper *xml, int n); 218 219 FFTwrapper *fft; 220 }; 221 222 #endif 223