-
Notifications
You must be signed in to change notification settings - Fork 16
/
ModuleEquationPlayer.h
83 lines (71 loc) · 2.23 KB
/
ModuleEquationPlayer.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
76
77
78
79
80
81
82
83
/*
* +----------------------+
* | ModuleEquationPlayer |
* |----------------------|
* > equation_input |
* > sample_rate_input |
* > param1_input |
* > param2_input |
* > param3_input |
* > reset_input |
* | output>
* +----------------------+
*
*/
// =============================================================================
//
// ModuleEquationPlayer is a simple bytebeat equation player with control over
// equation selection, sample rate, and equation parameters. The reset input
// is used reset playback from the beginning.
//
// An equation bank must be passed in to the ModuleEquationPlayer via the
// constructor.
//
// Example usage:
//
// ModuleEquationPlayer *equation_player = new ModuleEquationPlayer(equation bank);
//
// equation_player->equation_input = inputs->mod;
// equation_player->sample_rate_input = inputs->sr;
// equation_player->param1_input = inputs->param1;
// equation_player->param2_input = inputs->param2;
// equation_player->param3_input = inputs->param3;
// equation_player->reset_input = inputs->gate;
//
// this->last_module = equation_player;
//
#ifndef ModuleEquationPlayer_h
#define ModuleEquationPlayer_h
#include "Arduino.h"
#include "Module.h"
#include "EquationBank.h"
class ModuleEquationPlayer : public Module
{
public:
ModuleEquationPlayer(EquationBank *equation_bank);
uint16_t compute();
// Inputs
Module *equation_input;
Module *sample_rate_input;
Module *param1_input;
Module *param2_input;
Module *param3_input;
Module *reset_input;
private:
int equation;
uint32_t t;
uint32_t p1;
uint32_t p2;
uint32_t p3;
EquationBank *equation_bank;
uint32_t reset;
uint32_t old_reset;
// 32.32 fixed point number (using the upper 32 bits for holding the usable
// numbers and an additional 32 bits). Originally I had used a 20.12
// fixed point number, but limiting the equation playback index to 20 bits
// ended up causing the sounds (especially melodic ones) to loop in odd places.
uint64_t fixed_point_32_32_index;
uint64_t increment_by;
uint32_t sample_rate;
};
#endif