DaisySP
Loading...
Searching...
No Matches
variableshapeosc.h
Go to the documentation of this file.
1/*
2Copyright (c) 2020 Electrosmith, Corp, Emilie Gillet
3
4Use of this source code is governed by an MIT-style
5license that can be found in the LICENSE file or at
6https://opensource.org/licenses/MIT.
7*/
8
9#pragma once
10#ifndef DSY_VARIABLESHAPEOSCILLATOR_H
11#define DSY_VARIABLESHAPEOSCILLATOR_H
12
13#include <stdint.h>
14#ifdef __cplusplus
15
18namespace daisysp
19{
30{
31 public:
34
38 void Init(float sample_rate);
39
42 float Process();
43
47 void SetFreq(float frequency);
48
52 void SetPW(float pw);
53
57 void SetWaveshape(float waveshape);
58
62 void SetSync(bool enable_sync);
63
67 void SetSyncFreq(float frequency);
68
69 private:
70 float ComputeNaiveSample(float phase,
71 float pw,
72 float slope_up,
73 float slope_down,
74 float triangle_amount,
75 float square_amount);
76
77 float sample_rate_;
78 bool enable_sync_;
79
80 // Oscillator state.
81 float master_phase_;
82 float slave_phase_;
83 float next_sample_;
84 float previous_pw_;
85 bool high_;
86
87 // For interpolation of parameters.
88 float master_frequency_;
89 float slave_frequency_;
90 float pw_;
91 float waveshape_;
92};
93} // namespace daisysp
94#endif
95#endif
Definition delayline.h:29
Variable Waveshape Oscillator.
Definition variableshapeosc.h:30
void SetWaveshape(float waveshape)
Definition variableshapeosc.cpp:150
void SetSyncFreq(float frequency)
Definition variableshapeosc.cpp:160
void SetSync(bool enable_sync)
Definition variableshapeosc.cpp:155
float Process()
Definition variableshapeosc.cpp:24
void Init(float sample_rate)
Definition variableshapeosc.cpp:7
void SetPW(float pw)
Definition variableshapeosc.cpp:137
void SetFreq(float frequency)
Definition variableshapeosc.cpp:130
FIR Filter implementation, generic and ARM CMSIS DSP based.
Definition adenv.h:16