-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtableenv.h
More file actions
152 lines (104 loc) · 2.82 KB
/
Copy pathtableenv.h
File metadata and controls
152 lines (104 loc) · 2.82 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef TABLEENV_H
#define TABLEENV_H
#include "plugin.hpp"
#include "Menu.hpp"
#define TABLE_ENV_TABLE_SIZE 1024
struct FileHeader {
char magic[4];
uint8_t version;
uint8_t reserved;
int16_t count;
} __attribute__((packed));
struct Envelope {
char name[12];
float samples[TABLE_ENV_TABLE_SIZE];
} __attribute__((packed));
static_assert ( sizeof (FileHeader) == 8,"bad Header size");
static_assert ( sizeof (Envelope) == 12 + 1024*sizeof (float),"bad enveloppe size");
class TableEnv;
class ShowTable;
struct EnvelopeState;
enum PlayMode: int {
PM_FORWARD = 0,
PM_LOOP,
PM_REVERSE,
PM_REVLOOP,
PM_PONG,
PM_MAX
};
class ShowTable : public ParentMenu {
public:
ShowTable();
enum {
INTERNAL_PARAM_ENV_SELECT = 0,
INTERNAL_PARAM_COUNT
};
void init(EnvelopeState **envstate, size_t count);
void bindTable();
bool process() override;
void drawSelection(int xpos, int width);
void setEnvState(EnvelopeState* envstate);
MenuEntry* getCurrentMenu();
private:
bool m_stateEdit = false;
size_t m_currentState = 0;
EnvelopeState** m_allEnv = nullptr;
size_t m_allEnvCount = 0;
EnvelopeState* m_envstate = nullptr;
SetMenuEntry m_envelopeSelect;
size_t m_state = 0;
MenuEntry** m_params = nullptr;
size_t m_paramsCount = 0;
};
struct EnvelopeState {
EnvelopeState();
void init(TableEnv* parent);
void processTrigger(GateIn* );
void update();
void updatePhase();
void reset();
MenuEntry** bind(size_t& count);
SetMenuEntry m_tableParam;
RangeParamEntry m_timeParam;
float m_duration = 0.f;
SetMenuEntry m_loopParam;
PlayMode m_playMode = PM_FORWARD;
BoolMenuEntry m_invertParam;
bool m_invert = false;
RangeParamEntry m_tscaleParam;
float m_timeShape = 1.f;
RangeParamEntry m_vscaleParam;
float m_valShape = 1.f;
RangeParamEntry m_levelParam;
float m_level = 5.f;
#define ENV_STATE_COUNT_PARAM 7
MenuEntry* m_allParam[ENV_STATE_COUNT_PARAM];
Envelope* m_env = nullptr;
float m_phase = 0.f;
float m_delta = 0.f;
float m_val = 0;
bool m_running = false;
bool m_fwd = true;
TableEnv* m_parent = nullptr;
};
class TableEnv : public Plugin
{
public:
const char* name() const override { return "Table Env"; }
void init() override;
bool load() override;
void unload() override;
void AudioCallback(const float* const*, float**, unsigned int) override;
void processOled();
void processInput();
void processOutput();
void process() override;
public:
bool loadBank(const char* bankName);
Envelope* m_tables = nullptr;
size_t m_tableCount = 0;
const char** m_labels = nullptr;
ShowTable m_showTable;
friend struct EnvelopeState;
};
#endif // TABLEENV_H