1 /*
2   ZynAddSubFX - a software synthesizer
3 
4   LFOParams.h - Parameters for LFO
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 LFO_PARAMS_H
15 #define LFO_PARAMS_H
16 
17 #include <Misc/Time.h>
18 #include <rtosc/ports.h>
19 #include "Presets.h"
20 
21 #define LFO_SINE      0
22 #define LFO_TRIANGLE  1
23 #define LFO_SQUARE    2
24 #define LFO_RAMPUP    3
25 #define LFO_RAMPDOWN  4
26 #define LFO_EXP_DOWN1 5
27 #define LFO_EXP_DOWN2 6
28 #define LFO_RANDOM    7
29 
30 namespace zyn {
31 
32 class XMLwrapper;
33 
34 class LFOParams:public Presets
35 {
36     public:
37         LFOParams(const AbsTime* time_ = nullptr);
38         LFOParams(consumer_location_t loc,
39                   const AbsTime* time_ = nullptr);
40         LFOParams(float freq_,
41                   char Pintensity_,
42                   char Pstartphase_,
43                   char Pcutoff_,
44                   char PLFOtype_,
45                   char Prandomness_,
46                   float delay_,
47                   float fadein_,
48                   float fadeout_,
49                   char Pcontinous,
50                   consumer_location_t loc,
51                   const AbsTime* time_ = nullptr);
52         ~LFOParams() override;
53 
54         void add2XML(XMLwrapper& xml) override;
55         void defaults();
56         /**Loads the LFO from the xml*/
57         void getfromXML(XMLwrapper& xml);
58         void paste(LFOParams &);
59 
60         /*  MIDI Parameters*/
61         float         freq;      /**<frequency*/
62         unsigned char Pintensity; /**<intensity*/
63         unsigned char Pstartphase; /**<start phase (0=random)*/
64         unsigned char Pcutoff; /**<cutoff */
65         unsigned char PLFOtype; /**<LFO type (sin,triangle,square,ramp,...)*/
66         unsigned char Prandomness; /**<randomness (0=off)*/
67         unsigned char Pfreqrand; /**<frequency randomness (0=off)*/
68         float         delay; /**<delay (0=off)*/
69         float         fadein; /**<fadein, relative to delay*/
70         float         fadeout; /**<fadeout on key release (10.0=off)*/
71         unsigned char Pcontinous; /**<1 if LFO is continous*/
72         int           numerator;  /**<numerator for integer ratio between system tempo and LFO freq (0=off)*/
73         int           denominator;/**<denominator for integer ratio between system tempo and LFO freq (0=off)*/
74         unsigned char Pstretch; /**<how the LFO is "stretched" according the note frequency (64=no stretch)*/
75 
76         //! what kind is the LFO (0 - frequency, 1 - amplitude, 2 - filter)
77         consumer_location_type_t fel;
78         int loc; //!< consumer location
79 
80         const AbsTime *time;
81         int64_t last_update_timestamp;
82 
83         static const rtosc::Ports &ports;
84     private:
85         //! common functionality of ctors
86         void setup();
87 
88         /* Default parameters */
89         float         Dfreq;
90         unsigned char Dintensity;
91         unsigned char Dstartphase;
92         unsigned char Dcutoff;
93         unsigned char DLFOtype;
94         unsigned char Drandomness;
95         float         Ddelay;
96         float         Dfadein;
97         float         Dfadeout;
98         unsigned char Dcontinous;
99 };
100 
101 }
102 
103 #endif
104