Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Oscillator.h
1 #pragma once
2 
3 class Oscillator {
4 public:
5  typedef enum {
6  sine,
7  triangle,
8  square,
9  sawtooth,
10  numOscTypes,
11  } Type;
12 
13  Oscillator(){};
14  Oscillator(float fs, Oscillator::Type type = sine)
15  {
16  setup(fs, type);
17  }
18  ~Oscillator(){};
19 
20  void setup(float fs, Oscillator::Type type = sine);
21 
22  float process();
23  float process(float frequency);
24  void setType(Oscillator::Type type) {
25  type_ = type;
26  }
27  void setFrequency(float frequency) {
28  frequency_ = frequency;
29  }
30  void setPhase(float phase) {
31  phase_ = phase;
32  }
33 
34  float getPhase() { return phase_; }
35  float getFrequency() { return frequency_; }
36  int getType() { return type_; }
37 
38 private:
39  float phase_;
40  float frequency_;
41  float invSampleRate_;
42  unsigned int type_ = sine;
43  void computePhase();
44 };
Definition: Oscillator.h:3