CLAM-Development  1.4.0
Oscillator.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 __Oscillator_hxx__
23 #define __Oscillator_hxx__
24 
25 #include "SimpleOscillator.hxx"
26 #include "Processing.hxx"
27 #include "ProcessingConfig.hxx"
28 #include "Audio.hxx"
29 #include "AudioInPort.hxx"
30 #include "InControl.hxx"
31 #include <string>
32 
33 namespace CLAM
34 {
35 
37 {
38 public:
40  DYN_ATTRIBUTE (0, public, TData, Frequency);
41  DYN_ATTRIBUTE (1, public, TData, Amplitude);
42  DYN_ATTRIBUTE (2, public, TData, ModIndex);
43  DYN_ATTRIBUTE (3, public, TData, Phase);
44  DYN_ATTRIBUTE (4, public, TData, SamplingRate);
45 protected:
46  void DefaultInit(void);
47 };
48 
50 {
51  typedef OscillatorConfig Config;
52  Config mConfig;
53 
54  AudioInPort mInputPhaseMod;
55  AudioInPort mInputFreqMod;
56  TData mModIndex;
57 
58  bool mModIdxUpdated;
59  FloatInControl mModIdxCtl;
60 
61 
62  inline void ApplyControls()
63  {
65  if ( mModIdxUpdated )
66  {
67  mModIndex = mModIdxCtl.GetLastValue();
68  mModIdxUpdated = false;
69  }
70  }
71  void UpdateModIdx( TControlData );
72 
73 public:
74  Oscillator(const Config& c = Config());
75 
76  virtual ~Oscillator();
77  bool ConcreteConfigure( const ProcessingConfig& c );
78 
79  const char * GetClassName() const {return "Oscillator";}
80  const ProcessingConfig &GetConfig() const { return mConfig;}
81 
82  bool Do();
83  bool Do(Audio & out)
84  {
85  return SimpleOscillator::Do(out);
86  }
87  bool Do(const Audio& pitchModIn,const Audio& phaseModIn,Audio& out);
88  bool Do(const Audio& pitchModIn,const int& dum ,Audio& out);
89  bool Do(const int& dum ,const Audio& phaseModIn,Audio& out);
90 };
91 
92 }
93 
94 #endif //__Oscillator_hxx__
95