-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOscillator.h
More file actions
39 lines (33 loc) · 748 Bytes
/
Oscillator.h
File metadata and controls
39 lines (33 loc) · 748 Bytes
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
/**
* Based od Arduino for Musicians
* Brent Edstrom, 2013
*
* Author: Pavel Husa
*
* Desc: Oscillator class returns value 0-4095.
*/
#ifndef SYNTH_OSCILLATOR
#define SYNTH_OSCILLATOR
#include <Arduino.h>
#include "Tables.h"
class Oscillator {
private:
volatile uint32_t osc_accumulator;
volatile uint32_t osc_increment;
public:
Oscillator();
unsigned char osc_detune;
unsigned char osc_note;
void setNote(unsigned char note);
void detune(unsigned char d);
void reset();
/*
* Time critical - MUST BE INLINE!!!
* This method is overriden in oscilator-shapes subclass.
*/
inline virtual uint32_t getSample() {
osc_accumulator += osc_increment;
return osc_accumulator;
}
};
#endif