zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

ADnoteParameters.h (9584B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   ADnoteParameters.h - Parameters for ADnote (ADsynth)
      5   Copyright (C) 2002-2005 Nasca Octavian Paul
      6   Author: Nasca Octavian Paul
      7 
      8   This program is free software; you can redistribute it and/or
      9   modify it under the terms of the GNU General Public License
     10   as published by the Free Software Foundation; either version 2
     11   of the License, or (at your option) any later version.
     12 */
     13 
     14 #ifndef AD_NOTE_PARAMETERS_H
     15 #define AD_NOTE_PARAMETERS_H
     16 
     17 #include "../globals.h"
     18 #include "PresetsArray.h"
     19 #include <cstdint>
     20 
     21 namespace zyn {
     22 
     23 enum class FMTYPE {
     24     NONE, MIX, RING_MOD, PHASE_MOD, FREQ_MOD, PW_MOD
     25 };
     26 
     27 /*****************************************************************/
     28 /*                    GLOBAL PARAMETERS                          */
     29 /*****************************************************************/
     30 
     31 struct ADnoteGlobalParam {
     32     ADnoteGlobalParam(const AbsTime* time_ = nullptr);
     33     ~ADnoteGlobalParam();
     34     void defaults();
     35     void add2XML(XMLwrapper& xml);
     36     void getfromXML(XMLwrapper& xml);
     37     void paste(ADnoteGlobalParam &a);
     38     /* The instrument type  - MONO/STEREO
     39     If the mode is MONO, the panning of voices are not used
     40     Stereo=1, Mono=0. */
     41 
     42     unsigned char PStereo;
     43 
     44 
     45     /******************************************
     46     *     FREQUENCY GLOBAL PARAMETERS        *
     47     ******************************************/
     48     unsigned short int PDetune; //fine detune
     49     unsigned short int PCoarseDetune; //coarse detune+octave
     50     unsigned char      PDetuneType; //detune type
     51 
     52     unsigned char PBandwidth;      //how much the relative fine detunes of the voices are changed
     53 
     54     EnvelopeParams *FreqEnvelope;    //Frequency Envelope
     55 
     56     LFOParams *FreqLfo; //Frequency LFO
     57 
     58     /********************************************
     59     *     AMPLITUDE GLOBAL PARAMETERS          *
     60     ********************************************/
     61 
     62     /* Panning -  0 - random
     63               1 - left
     64              64 - center
     65             127 - right */
     66     unsigned char PPanning;
     67 
     68     float Volume;
     69 
     70     unsigned char PAmpVelocityScaleFunction;
     71 
     72     EnvelopeParams *AmpEnvelope;
     73 
     74     LFOParams *AmpLfo;
     75 
     76     /* Adjustment factor for anti-pop fadein */
     77     unsigned char Fadein_adjustment;
     78 
     79     unsigned char PPunchStrength, PPunchTime, PPunchStretch,
     80                   PPunchVelocitySensing;
     81 
     82     /******************************************
     83     *        FILTER GLOBAL PARAMETERS        *
     84     ******************************************/
     85     FilterParams *GlobalFilter;
     86 
     87     // filter velocity sensing
     88     unsigned char PFilterVelocityScale;
     89 
     90     // filter velocity sensing
     91     unsigned char PFilterVelocityScaleFunction;
     92 
     93     EnvelopeParams *FilterEnvelope;
     94 
     95     LFOParams *FilterLfo;
     96 
     97     // RESONANCE
     98     Resonance *Reson;
     99 
    100     //how the randomness is applied to the harmonics on more voices using the same oscillator
    101     unsigned char Hrandgrouping;
    102 
    103     const AbsTime *time;
    104     int64_t last_update_timestamp;
    105 
    106     static const rtosc::Ports &ports;
    107 };
    108 
    109 
    110 
    111 /***********************************************************/
    112 /*                    VOICE PARAMETERS                     */
    113 /***********************************************************/
    114 struct ADnoteVoiceParam {
    115     ADnoteVoiceParam() : time(nullptr), last_update_timestamp(0) { };
    116     void getfromXML(XMLwrapper& xml, unsigned nvoice);
    117     void add2XML(XMLwrapper& xml, bool fmoscilused);
    118     void paste(ADnoteVoiceParam &p);
    119     void defaults(void);
    120     void enable(const SYNTH_T &synth, FFTwrapper *fft, const Resonance *Reson,
    121                 const AbsTime *time);
    122     void kill(void);
    123     float getUnisonFrequencySpreadCents(void) const;
    124     /** If the voice is enabled */
    125     unsigned char Enabled;
    126 
    127     /** How many subvoices are used in this voice */
    128     unsigned char Unison_size;
    129 
    130     /** How subvoices are spread */
    131     unsigned char Unison_frequency_spread;
    132 
    133     /** How much phase randomization */
    134     unsigned char Unison_phase_randomness;
    135 
    136     /** Stereo spread of the subvoices*/
    137     unsigned char Unison_stereo_spread;
    138 
    139     /** Vibratto of the subvoices (which makes the unison more "natural")*/
    140     unsigned char Unison_vibratto;
    141 
    142     /** Medium speed of the vibratto of the subvoices*/
    143     unsigned char Unison_vibratto_speed;
    144 
    145     /** Unison invert phase */
    146     unsigned char Unison_invert_phase; //0=none,1=random,2=50%,3=33%,4=25%
    147 
    148     /** Type of the voice (0=Sound,1=Noise)*/
    149     unsigned char Type;
    150 
    151     /** Voice Delay */
    152     unsigned char PDelay;
    153 
    154     /** If the resonance is enabled for this voice */
    155     unsigned char Presonance;
    156 
    157     // What external oscil should I use, -1 for internal OscilSmp&FMSmp
    158     short int Pextoscil, PextFMoscil;
    159     // it is not allowed that the externoscil,externFMoscil => current voice
    160 
    161     // oscillator phases
    162     unsigned char Poscilphase, PFMoscilphase;
    163 
    164     // filter bypass
    165     unsigned char Pfilterbypass;
    166     unsigned char PfilterFcCtlBypass;
    167 
    168     /** Voice oscillator */
    169     OscilGen *OscilGn;
    170 
    171     /**********************************
    172     *     FREQUENCY PARAMETERS        *
    173     **********************************/
    174 
    175     /** If the base frequency is fixed to 440 Hz*/
    176     unsigned char Pfixedfreq;
    177 
    178     /* Equal temperate (this is used only if the Pfixedfreq is enabled)
    179        If this parameter is 0, the frequency is fixed (to 440 Hz);
    180        if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
    181     unsigned char PfixedfreqET;
    182 
    183     /** Fine detune */
    184     unsigned short int PDetune;
    185 
    186     /** Coarse detune + octave */
    187     unsigned short int PCoarseDetune;
    188 
    189     /** Detune type */
    190     unsigned char PDetuneType;
    191 
    192     /** Pitch bend adjustment */
    193     unsigned char PBendAdjust;
    194 
    195     /** Pitch offset Hz */
    196     unsigned char POffsetHz;
    197 
    198     /* Frequency Envelope */
    199     unsigned char   PFreqEnvelopeEnabled;
    200     EnvelopeParams *FreqEnvelope;
    201 
    202     /* Frequency LFO */
    203     unsigned char PFreqLfoEnabled;
    204     LFOParams    *FreqLfo;
    205 
    206 
    207     /***************************
    208     *   AMPLITUDE PARAMETERS   *
    209     ***************************/
    210 
    211     /* Panning   0 - random
    212                  1 - left
    213                 64 - center
    214                127 - right
    215        The Panning is ignored if the instrument is mono */
    216     unsigned char PPanning;
    217 
    218     /* Voice Volume */
    219     float volume;
    220 
    221     /* If the Volume negative */
    222     unsigned char PVolumeminus;
    223 
    224     /* if AntiAliasing is enabled */
    225     bool PAAEnabled;
    226 
    227     /* Velocity sensing */
    228     unsigned char PAmpVelocityScaleFunction;
    229 
    230     /* Amplitude Envelope */
    231     unsigned char   PAmpEnvelopeEnabled;
    232     EnvelopeParams *AmpEnvelope;
    233 
    234     /* Amplitude LFO */
    235     unsigned char PAmpLfoEnabled;
    236     LFOParams    *AmpLfo;
    237 
    238 
    239 
    240     /*************************
    241     *   FILTER PARAMETERS    *
    242     *************************/
    243 
    244     /* Voice Filter */
    245     unsigned char PFilterEnabled;
    246     FilterParams *VoiceFilter;
    247 
    248     /* Filter Envelope */
    249     unsigned char   PFilterEnvelopeEnabled;
    250     EnvelopeParams *FilterEnvelope;
    251 
    252     /* Filter LFO */
    253     unsigned char PFilterLfoEnabled;
    254     LFOParams    *FilterLfo;
    255 
    256     // filter velocity sensing
    257     unsigned char PFilterVelocityScale;
    258 
    259     // filter velocity sensing
    260     unsigned char PFilterVelocityScaleFunction;
    261 
    262     /****************************
    263     *   MODULLATOR PARAMETERS   *
    264     ****************************/
    265 
    266     /* Modulator Parameters (0=off,1=Mix,2=RM,3=PM,4=FM.. */
    267     FMTYPE PFMEnabled;
    268 
    269     /* Voice that I use as modulator instead of FMSmp.
    270        It is -1 if I use FMSmp(default).
    271        It maynot be equal or bigger than current voice */
    272     short int PFMVoice;
    273 
    274     /* Modulator oscillator */
    275     OscilGen *FmGn;
    276 
    277     /* Modulator Volume */
    278     float FMvolume;
    279 
    280     /* Modulator damping at higher frequencies */
    281     unsigned char PFMVolumeDamp;
    282 
    283     /* Modulator Velocity Sensing */
    284     unsigned char PFMVelocityScaleFunction;
    285 
    286     /* Fine Detune of the Modulator */
    287     unsigned short int PFMDetune;
    288 
    289     /* Coarse Detune of the Modulator */
    290     unsigned short int PFMCoarseDetune;
    291 
    292     /* The detune type */
    293     unsigned char PFMDetuneType;
    294 
    295     /* FM base freq fixed at 440Hz */
    296     unsigned char PFMFixedFreq;
    297 
    298     /* Frequency Envelope of the Modulator */
    299     unsigned char   PFMFreqEnvelopeEnabled;
    300     EnvelopeParams *FMFreqEnvelope;
    301 
    302     /* Frequency Envelope of the Modulator */
    303     unsigned char   PFMAmpEnvelopeEnabled;
    304     EnvelopeParams *FMAmpEnvelope;
    305 
    306     unsigned char *GlobalPDetuneType;
    307 
    308     const AbsTime *time;
    309     int64_t last_update_timestamp;
    310 
    311     static const rtosc::Ports &ports;
    312 };
    313 
    314 class ADnoteParameters:public PresetsArray
    315 {
    316     public:
    317         ADnoteParameters(const SYNTH_T &synth, FFTwrapper *fft_,
    318                          const AbsTime *time_ = nullptr);
    319         ~ADnoteParameters() override;
    320 
    321         ADnoteGlobalParam GlobalPar;
    322         ADnoteVoiceParam  VoicePar[NUM_VOICES];
    323 
    324         void defaults();
    325         void add2XML(XMLwrapper& xml) override;
    326         void getfromXML(XMLwrapper& xml);
    327 
    328         void paste(ADnoteParameters &a);
    329         void pasteArray(ADnoteParameters &a, int section);
    330 
    331 
    332         float getBandwidthDetuneMultiplier() const;
    333         float getUnisonFrequencySpreadCents(int nvoice) const;
    334         static const rtosc::Ports &ports;
    335         void defaults(int n); //n is the nvoice
    336         void add2XMLsection(XMLwrapper& xml, int n) override;
    337         void getfromXMLsection(XMLwrapper& xml, int n);
    338 
    339         const AbsTime *time;
    340         int64_t last_update_timestamp;
    341 
    342     private:
    343         void EnableVoice(const SYNTH_T &synth, int nvoice, const AbsTime* time);
    344         void KillVoice(int nvoice);
    345         FFTwrapper *fft;
    346 };
    347 
    348 }
    349 
    350 #endif