-
Notifications
You must be signed in to change notification settings - Fork 16
/
ModuleClockedRandom.h
58 lines (48 loc) · 1.21 KB
/
ModuleClockedRandom.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
/*
* +-------------------------+
* | ModuleClockedRandom |
* |-------------------------|
* > clock_input |
* | |
* | output >
* +-------------------------+
*
*/
// =============================================================================
//
// ModuleClockedRandom is a clocked random number generator. The output ranges
// from 0 to 4095.
//
// Example usage:
//
// ModuleWavetableOsc *osc = new ModuleWavetableOsc();
// ModuleClockedRandom *clocked_random = new ModuleClockedRandom();
// ModuleExtClock *ext_clock = new ModuleExtClock(120, EIGHTH_NOTE_CLOCK_DIVISION);
//
// ext_clock->clock_input = inputs->gate;
//
// clocked_random->clock_input = ext_clock;
//
// osc->frequency_input = clocked_random;
//
// this->last_module = osc;
//
#ifndef ModuleClockedRandom_h
#define ModuleClockedRandom_h
#include "Arduino.h"
#include "Module.h"
#include "Rand.h"
class ModuleClockedRandom : public Module
{
public:
ModuleClockedRandom();
uint16_t compute();
// Inputs
Module *clock_input;
private:
boolean clocked;
uint32_t old_clock;
uint32_t latched_output;
Rand rand;
};
#endif