EffectLFO.h (2394B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 EffectLFO.h - Stereo LFO used by some 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 EFFECT_LFO_H 15 #define EFFECT_LFO_H 16 17 #include "../globals.h" 18 19 namespace zyn { 20 21 /**LFO for some of the Effect objects 22 * \todo see if this should inherit LFO*/ 23 class EffectLFO 24 { 25 public: 26 /** 27 * Constructs an EffectLFO object. 28 * 29 * @param srate_f Sample rate. 30 * @param bufsize_f Buffer size. 31 */ 32 EffectLFO(float srate_f, float bufsize_f); 33 34 /** 35 * Destructs the EffectLFO object. 36 */ 37 ~EffectLFO(); 38 39 // if phaseOffset!=0 we don't want to update the phase but get a phased shifted output of the last one. 40 /** 41 * calculate the output of the effect LFO for two signals (stereo) 42 * @param outl Pointer to the left output channel. 43 * @param outr Pointer to the right output channel. 44 * @param phaseOffset phaseoffset 45 * if phaseOffset is not 0 we don't want to update the phase 46 * but get the phased shifted output of the last one. 47 */ 48 void effectlfoout(float *outl, float *outr, float phaseOffset = 0.0f); 49 50 /** 51 * Updates the LFO parameters based on the current settings. 52 */ 53 void updateparams(void); 54 55 unsigned char Pfreq; //!< Frequency parameter (0-127) 56 unsigned char Prandomness; //!< Randomness parameter (0-127) 57 unsigned char PLFOtype; //!< LFO type parameter (0-2) 58 unsigned char Pstereo; //!< Stereo parameter (-64 to 64) 59 60 private: 61 /** 62 * Calculates the LFO shape based on the current phase and type. 63 * 64 * @param x Phase value (0-1). 65 * @return The calculated LFO shape value. 66 */ 67 float getlfoshape(float x); 68 69 float xl, xr; //!< Phase accumulators for left and right channels 70 float incx; //!< Increment for phase accumulators 71 float ampl1, ampl2, ampr1, ampr2; //!< Amplitude modulation parameters 72 float lfornd; //!< Randomness factor 73 char lfotype; //!< Current LFO type 74 75 // Current setup 76 float samplerate_f; //!< Sample rate 77 float buffersize_f; //!< Buffer size 78 }; 79 80 } 81 82 #endif