CLAM-Development  1.4.0
SimpleOscillator.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef __SimpleOscillator_hxx__
23 #define __SimpleOscillator_hxx__
24 
25 #include "Processing.hxx"
26 #include "ProcessingData.hxx"
27 #include "OSDefines.hxx"
28 #include "Audio.hxx"
29 #include "AudioOutPort.hxx"
30 #include "InControl.hxx"
31 #include "Enum.hxx"
32 #include <string>
33 
34 namespace CLAM
35 {
36 
37 class EOscillatorControls : public Enum
38 {
39 public:
40 
43  EOscillatorControls(std::string s) : Enum(ValueTable(), s) { }
45 
46  Component * Species() const
47  {
48  return new EOscillatorControls;
49  }
50  typedef enum
51  {
52  pitch=0,
56  } tEnum;
58  {
59  static tEnumValue sEnumValues[] =
60  {
61  { pitch, "pitch" },
62  { amplitude, "amplitude" },
63  { modidx, "modidx" },
64  { phase, "phase" },
65  { 0, NULL }
66  };
67  return sEnumValues;
68  }
69 };
70 
72 {
73 public:
75  DYN_ATTRIBUTE (0, public, TData, Frequency);
76  DYN_ATTRIBUTE (1, public, TData, Amplitude);
77  DYN_ATTRIBUTE (2, public, TData, Phase);
78  DYN_ATTRIBUTE (3, public, TData, SamplingRate);
79 
80 protected:
81  void DefaultInit(void);
82 };
83 
85 {
86 protected:
94 
99  //xamat: kludge to convert this into an LFO, eventually separate into a different class
101 
102 protected:
103 
105  {
106  if ( mFreqUpdated )
107  {
109  mFreqUpdated = false;
110  }
111  if ( mAmpUpdated )
112  {
114  mAmpUpdated = false;
115  }
116  }
117 
118  void UpdateFreq( TControlData );
119  void UpdateAmp( TControlData );
120 
121 public:
122 
124 
125  virtual ~SimpleOscillator();
126 
127  const char * GetClassName() const {return "SimpleOscillator";}
128 
129  virtual const ProcessingConfig &GetConfig() const { return mConfig;}
130 
131  virtual bool ConcreteConfigure(const ProcessingConfig& c);
132 
133  virtual bool Do(void);
134 
135  // "Generative Do"
136  bool Do(Audio& out);
138  bool Do(TData& out);
139 };
140 
141 }
142 
143 #endif
144 
145