zynaddsubfx

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

Chorus.h (3517B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   Chorus.h - Chorus and Flange effects
      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 CHORUS_H
     15 #define CHORUS_H
     16 #include "Effect.h"
     17 #include "EffectLFO.h"
     18 #include "../Misc/Stereo.h"
     19 
     20 
     21 
     22 
     23 
     24 namespace zyn {
     25 
     26 #define MAX_CHORUS_DELAY 250.0f //ms
     27 
     28 // Chorus modes
     29 // CHORUS default chorus mode
     30 // FLANGE flanger mode (very short delays)
     31 // TRIPLE 120° triple phase chorus
     32 // DUAL   180° dual phase chorus
     33 
     34 #define CHORUS_MODES \
     35     CHORUS,\
     36     FLANGE,\
     37     TRIPLE,\
     38     DUAL
     39 
     40 /**Chorus and Flange effects*/
     41 class Chorus final:public Effect
     42 {
     43     public:
     44         enum ChorusModes {
     45             CHORUS_MODES
     46         };
     47 
     48         Chorus(EffectParams pars);
     49         /**Destructor*/
     50         ~Chorus();
     51         void out(const Stereo<float *> &input);
     52         unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
     53         void setpreset(unsigned char npreset);
     54         /**
     55          * Sets the value of the chosen variable
     56          *
     57          * The possible parameters are:
     58          *   -# Volume
     59          *   -# Panning
     60          *   -# LFO Frequency
     61          *   -# LFO Randomness
     62          *   -# LFO Type
     63          *   -# LFO stereo
     64          *   -# Depth
     65          *   -# Delay
     66          *   -# Feedback
     67          *   -# Flange Mode
     68          *   -# Subtractive
     69          * @param npar number of chosen parameter
     70          * @param value the new value
     71          */
     72         void changepar(int npar, unsigned char value);
     73         /**
     74          * Gets the value of the chosen variable
     75          *
     76          * The possible parameters are:
     77          *   -# Volume
     78          *   -# Panning
     79          *   -# LFO Frequency
     80          *   -# LFO Randomness
     81          *   -# LFO Type
     82          *   -# LFO stereo
     83          *   -# Depth
     84          *   -# Delay
     85          *   -# Feedback
     86          *   -# Flange Mode
     87          *   -# Subtractive
     88          * @param npar number of chosen parameter
     89          * @return the value of the parameter
     90          */
     91         unsigned char getpar(int npar) const;
     92         void cleanup(void);
     93 
     94         static rtosc::Ports ports;
     95     private:
     96         inline float getSample(float* delayline, float mdel, int dk);
     97 
     98         //Chorus Parameters
     99         unsigned char Pvolume;
    100         unsigned char Pdepth;      //the depth of the Chorus(ms)
    101         unsigned char Pdelay;      //the delay (ms)
    102         unsigned char Pfb;         //feedback
    103         unsigned char Pflangemode; //mode as described above in CHORUS_MODES
    104         unsigned char Poutsub;     //if I wish to subtract the output instead of the adding it
    105         EffectLFO     lfo;         //lfo-ul chorus
    106 
    107 
    108         //Parameter Controls
    109         void setvolume(unsigned char _Pvolume);
    110         void setdepth(unsigned char _Pdepth);
    111         void setdelay(unsigned char _Pdelay);
    112         void setfb(unsigned char _Pfb);
    113 
    114         //Internal Values
    115         float depth, delay, fb;
    116         float dlHist, dlNew, lfol;
    117         float drHist, drNew, lfor;
    118         float dlHist2, dlNew2;
    119         float drHist2, drNew2;
    120         float dlHist3, dlNew3;
    121         float drHist3, drNew3;
    122         int   maxdelay;
    123         Stereo<float *> delaySample;
    124         int dlk, drk;
    125         float getdelay(float xlfo);
    126 
    127         float output;
    128 };
    129 
    130 }
    131 
    132 #endif