Open Ephys GUI
 All Classes Functions Variables Pages
SignalGenerator.h
1 /*
2  ------------------------------------------------------------------
3 
4  This file is part of the Open Ephys GUI
5  Copyright (C) 2012 Open Ephys
6 
7  ------------------------------------------------------------------
8 
9  This program is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __SIGNALGENERATOR_H_EAA44B0B__
25 #define __SIGNALGENERATOR_H_EAA44B0B__
26 
27 
28 #include "../../JuceLibraryCode/JuceHeader.h"
29 #include "GenericProcessor.h"
30 #include "Editors/SignalGeneratorEditor.h"
31 
32 /**
33 
34  Outputs synthesized data of one of 5 different waveform types.
35 
36  @see GenericProcessor, SignalGeneratorEditor
37 
38 */
39 
41 
42 {
43 public:
44 
46  ~SignalGenerator();
47 
48  void process(AudioSampleBuffer &buffer, MidiBuffer &midiMessages, int& nSamples);
49 
50  void setParameter (int parameterIndex, float newValue);
51 
52  float getSampleRate() {return 44100.0;}
53 
54  AudioProcessorEditor* createEditor();
55  bool hasEditor() const {return true;}
56 
57  bool enable();
58  bool disable();
59 
60  bool isSource() {return true;}
61 
62  void updateSettings();
63 
64  int getDefaultNumOutputs() {return nOut;}
65 
66  int nOut;
67 
68 private:
69 
70  double defaultFrequency;
71  double defaultAmplitude;
72 
73  float sampleRateRatio;
74 
75  //void updateWaveform(int chan);
76 
77  enum wvfrm
78  {
79  TRIANGLE, SINE, SQUARE, SAW, NOISE
80  };
81 
82  Array<int> waveformType;
83  Array<double> frequency;
84  Array<double> amplitude;
85  Array<double> phase;
86  Array<double> phasePerSample;
87  Array<double> currentPhase;
88 
89  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SignalGenerator);
90 
91 };
92 
93 
94 
95 
96 
97 #endif // __SIGNALGENERATOR_H_EAA44B0B__