FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
Oscillator.h
1#pragma once
2
3#include <functional>
4
6{
7public:
8 enum OscType
9 {
10 SINE,
11 SQUARE,
12 SAW,
13 TRIANGLE,
14 NUM_TYPES
15 };
16
17 Oscillator(OscType oscType);
18 float generateSample();
19 void setAmplitude(float amplitude) { mAmplitude = amplitude; }
20 void setFrequency(float frequency) { mFrequency = frequency; }
21 void setType(OscType oscType);
22
23private:
24 OscType mOscType;
25 float mAmplitude;
26 float mFrequency;
27 float mAngle;
28 float mSampleRate;
29 std::function<float()> generateSampleFunc;
30
31 // Lambdas for waveform generation
32 std::function<float()> sineFunc;
33 std::function<float()> squareFunc;
34 std::function<float()> sawFunc;
35 std::function<float()> triangleFunc;
36};
Definition Oscillator.h:6