-
Notifications
You must be signed in to change notification settings - Fork 16
/
ModuleLFO.h
75 lines (65 loc) · 2.02 KB
/
ModuleLFO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* +----------------------+
* | ModuleLFO |
* |----------------------|
* > frequency_input |
* > wavetable_input |
* | |
* | output >
* +----------------------+
*/
// =============================================================================
//
// ModuleLFO is a low frequency oscillator based on wavetables with control
// over frequency and wavetable selection.
//
// Example usage:
//
// // Create an lfo, quantizer, and oscillator
// // They're going to be patched together like:
// //
// // lfo ---> quantizer ---> oscillator
// //
// ModuleLFO *lfo = new ModuleLFO();
// ModuleQuantizer *quantizer = new ModuleQuantizer();
// ModuleWavetableOsc *osc = new ModuleWavetableOsc();
//
// // Control the LFO rate and waveform via inputs
// lfo->frequency_input = inputs->sr;
// lfo->wavetable_input = inputs->param2;
//
// // Wire the output of the lfo to the input of the quantizer
// quantizer->scale_input = inputs->param1;
// quantizer->cv_input = lfo;
//
// // Wire the output of the quantizer to the frequency
// // input of the oscillator.
// osc->wavetable_input = inputs->mod;
// osc->frequency_input = quantizer;
//
// this->last_module = osc;
#ifndef ModuleLFO_h
#define ModuleLFO_h
#include "Arduino.h"
#include "Module.h"
class ModuleLFO : public Module
{
public:
ModuleLFO();
// Inputs
Module *frequency_input;
Module *wavetable_input;
private:
// Functions
uint16_t compute();
// Variables
uint32_t wavetable_index;
uint32_t frequency;
uint16_t wavetable; // The currenly selected wavetable
// 10.22 fixed point number (using the upper 10 bits for addressing the indexes
// up to 1024 (we only need 600), and an additional 22 bits (0-4194304) for simulating fractional values for
// use when incrementing the variable fractional values
uint32_t fixed_point_10_22_index;
uint32_t increment_by;
};
#endif