fsh::stk
fantastic spatial holophonic synthesis toolkit
Loading...
Searching...
No Matches
Oscillator.h
1/***************************************************************************************************
2 ██████ █████ █████ █████
3 ███░░███ ░░███ ░░███ ░░███
4 ░███ ░░░ █████ ░███████ ██ ██ █████ ███████ ░███ █████
5 ███████ ███░░ ░███░░███ ░░ ░░ ███░░ ░░░███░ ░███░░███
6 ░░░███░ ░░█████ ░███ ░███ ░░█████ ░███ ░██████░
7 ░███ ░░░░███ ░███ ░███ ░░░░███ ░███ ███ ░███░░███
8 █████ ██████ ████ █████ ██ ██ ██████ ░░█████ ████ █████
9 ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░ ░░ ░░░░░░ ░░░░░ ░░░░ ░░░░░
10
11 fantastic spatial holophonic synthesis tool kit
12
13 copyright (c) fabian hummel
14 www.github.com/fshstk
15 www.fshstk.com
16
17 this file is part of the fantastic spatial holophonic synthesis toolkit (fsh::stk)
18 fsh::stk is free software: it is provided under the terms of the gnu general public license v3.0
19 www.gnu.org/licenses/gpl-3.0
20***************************************************************************************************/
21
22#pragma once
23
24namespace fsh::synth
25{
42{
43public:
46 enum class Waveform
47 {
48 TrueSaw,
50 Square,
51
52 Sine,
53 Saw,
54 Noise,
55 Triangle,
56 };
57
59 struct Params
60 {
61 double detune;
62 double amplitude;
64 };
65
67 void setSampleRate(double sampleRate);
68
70 void setFrequency(double);
71
73 void setParams(const Params&);
74
76 auto nextSample() -> float;
77
79 void reset();
80
81private:
82 Params _params;
83
84 double _phase;
85 double _deltaPhase;
86 double _sampleRate;
87};
88} // namespace fsh::synth
Represents a single band-limited oscillator with multiple waveforms.
Definition Oscillator.h:42
void setSampleRate(double sampleRate)
Set the sample rate in Hz.
Definition Oscillator.cpp:187
Waveform
Waveform.
Definition Oscillator.h:47
@ Triangle
Triangle wave with all positive harmonics≤
@ TrueSaw
True sawtooth wave with alternating sign harmonics.
@ Saw
Sawtooth wave with all positive positive harmonics.
@ TrueTriangle
True triangle wave with alternating sign harmonics≤
void reset()
Reset the oscillator's phase/freq/amplitude to zero.
Definition Oscillator.cpp:149
auto nextSample() -> float
Compute the oscillator's next sample.
Definition Oscillator.cpp:154
void setParams(const Params &)
Set the oscillator's parameters.
Definition Oscillator.cpp:192
void setFrequency(double)
Set the oscillator's frequency.
Definition Oscillator.cpp:197
Oscillator parameters.
Definition Oscillator.h:60
double amplitude
Amplitude multiplier.
Definition Oscillator.h:62
double detune
Factor that will be multiplied with the oscillator's frequency.
Definition Oscillator.h:61
Waveform waveform
Waveform.
Definition Oscillator.h:63