diff options
author | Bad Diode <bd@badd10de.dev> | 2024-01-16 09:31:31 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-01-16 09:31:31 +0100 |
commit | 77374dacdee448b9dea733c0e444da07942b3238 (patch) | |
tree | 1fcb19f8e81c59a8ff5a48205b19a7eff052f0fe /src/globals.c | |
parent | 22ddbd9d1688aed3220122ac7a513742140ed3b6 (diff) | |
download | stepper-77374dacdee448b9dea733c0e444da07942b3238.tar.gz stepper-77374dacdee448b9dea733c0e444da07942b3238.zip |
[WIP] Refactor ch3 envelope
Diffstat (limited to 'src/globals.c')
-rw-r--r-- | src/globals.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/globals.c b/src/globals.c index 5063d69..c040585 100644 --- a/src/globals.c +++ b/src/globals.c | |||
@@ -1,15 +1,3 @@ | |||
1 | enum WAVES { | ||
2 | WAVE_SIN, | ||
3 | WAVE_SAW, | ||
4 | WAVE_SQUARE, | ||
5 | WAVE_MAX, | ||
6 | }; | ||
7 | |||
8 | #define WAVE_SIZE 4 | ||
9 | #define WAVE_VARS 4 | ||
10 | |||
11 | typedef u32 Wave[WAVE_SIZE]; | ||
12 | |||
13 | // | 1 | // |
14 | // Globals. | 2 | // Globals. |
15 | // | 3 | // |
@@ -221,9 +209,30 @@ bool redraw_scale = true; | |||
221 | bool update_bpm = false; | 209 | bool update_bpm = false; |
222 | u8 bar_counter = 0; | 210 | u8 bar_counter = 0; |
223 | 211 | ||
224 | static Wave wave_active = {0}; | 212 | typedef enum WaveEnv { |
225 | // static Wave wave_target = {0}; | 213 | WAV_ENV_START, |
226 | // TODO: wave env status: OFF, ATTACK, DECAY | 214 | WAV_ENV_ATTACK, |
215 | WAV_ENV_DECAY, | ||
216 | WAV_ENV_END, | ||
217 | WAV_ENV_OFF, | ||
218 | } WaveEnv; | ||
219 | |||
220 | enum WAVES { | ||
221 | WAVE_SIN, | ||
222 | WAVE_SAW, | ||
223 | WAVE_SQUARE, | ||
224 | WAVE_MAX, | ||
225 | }; | ||
226 | |||
227 | #define WAVE_SIZE 4 | ||
228 | #define WAVE_VARS 4 | ||
229 | |||
230 | typedef u32 Wave[WAVE_SIZE]; | ||
231 | |||
232 | static WaveEnv wave_env = WAV_ENV_OFF; | ||
233 | static const Wave *wave_target; | ||
234 | static u32 wave_freq; | ||
227 | static int wave_env_ticks = 0; | 235 | static int wave_env_ticks = 0; |
228 | static int wave_env_attack = 8; | 236 | static int wave_env_attack = 8; |
229 | static int wave_env_decay = 8; | 237 | static int wave_env_decay = 8; |
238 | static int wave_env_prog = 0; | ||