diff options
author | Bad Diode <bd@badd10de.dev> | 2024-01-15 16:06:05 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-01-15 16:06:05 +0100 |
commit | f6efcdd98b32f1cd0d5a4a52abb333437c04b44f (patch) | |
tree | f4542a21ceb080af21b684250650368de7fc9e3e /src/patterns.c | |
parent | 65089bc6ca9e31878afd583e133cb376ef03f268 (diff) | |
download | stepper-f6efcdd98b32f1cd0d5a4a52abb333437c04b44f.tar.gz stepper-f6efcdd98b32f1cd0d5a4a52abb333437c04b44f.zip |
[WIP] Add decay control and attack/decay params on ch3
Diffstat (limited to 'src/patterns.c')
-rw-r--r-- | src/patterns.c | 105 |
1 files changed, 61 insertions, 44 deletions
diff --git a/src/patterns.c b/src/patterns.c index a1f8f24..8dd0f5c 100644 --- a/src/patterns.c +++ b/src/patterns.c | |||
@@ -7,7 +7,7 @@ typedef struct TriggerNote { | |||
7 | Note note; | 7 | Note note; |
8 | } TriggerNote; | 8 | } TriggerNote; |
9 | 9 | ||
10 | typedef struct ChannelSquareParams { | 10 | typedef struct ChannelSquare1Params { |
11 | u8 env_volume; | 11 | u8 env_volume; |
12 | u8 env_time; | 12 | u8 env_time; |
13 | u8 env_direction; | 13 | u8 env_direction; |
@@ -17,7 +17,16 @@ typedef struct ChannelSquareParams { | |||
17 | u8 sweep_direction; | 17 | u8 sweep_direction; |
18 | u8 prob; | 18 | u8 prob; |
19 | s8 pan; | 19 | s8 pan; |
20 | } ChannelSquareParams; | 20 | } ChannelSquare1Params; |
21 | |||
22 | typedef struct ChannelSquare2Params { | ||
23 | u8 env_volume; | ||
24 | u8 env_time; | ||
25 | u8 env_direction; | ||
26 | u8 duty_cycle; | ||
27 | u8 prob; | ||
28 | s8 pan; | ||
29 | } ChannelSquare2Params; | ||
21 | 30 | ||
22 | typedef struct ChannelWaveParams { | 31 | typedef struct ChannelWaveParams { |
23 | u8 wave_volume; | 32 | u8 wave_volume; |
@@ -26,6 +35,8 @@ typedef struct ChannelWaveParams { | |||
26 | u8 type_a; | 35 | u8 type_a; |
27 | u8 shape_b; | 36 | u8 shape_b; |
28 | u8 type_b; | 37 | u8 type_b; |
38 | u8 wave_attack; | ||
39 | u8 wave_decay; | ||
29 | u8 prob; | 40 | u8 prob; |
30 | s8 pan; | 41 | s8 pan; |
31 | } ChannelWaveParams; | 42 | } ChannelWaveParams; |
@@ -39,11 +50,17 @@ typedef struct ChannelNoiseParams { | |||
39 | s8 pan; | 50 | s8 pan; |
40 | } ChannelNoiseParams; | 51 | } ChannelNoiseParams; |
41 | 52 | ||
42 | typedef struct ChannelSquare { | 53 | typedef struct ChannelSquare1 { |
43 | bool active; | 54 | bool active; |
44 | TriggerNote notes[16]; | 55 | TriggerNote notes[16]; |
45 | ChannelSquareParams params[16]; | 56 | ChannelSquare1Params params[16]; |
46 | } ChannelSquare; | 57 | } ChannelSquare1; |
58 | |||
59 | typedef struct ChannelSquare2 { | ||
60 | bool active; | ||
61 | TriggerNote notes[16]; | ||
62 | ChannelSquare2Params params[16]; | ||
63 | } ChannelSquare2; | ||
47 | 64 | ||
48 | typedef struct ChannelWave { | 65 | typedef struct ChannelWave { |
49 | bool active; | 66 | bool active; |
@@ -58,8 +75,8 @@ typedef struct ChannelNoise { | |||
58 | } ChannelNoise; | 75 | } ChannelNoise; |
59 | 76 | ||
60 | typedef struct Pattern { | 77 | typedef struct Pattern { |
61 | ChannelSquare ch1; | 78 | ChannelSquare1 ch1; |
62 | ChannelSquare ch2; | 79 | ChannelSquare2 ch2; |
63 | ChannelWave ch3; | 80 | ChannelWave ch3; |
64 | ChannelNoise ch4; | 81 | ChannelNoise ch4; |
65 | int bpm; | 82 | int bpm; |
@@ -71,7 +88,7 @@ typedef struct Pattern { | |||
71 | // Defaults. | 88 | // Defaults. |
72 | // | 89 | // |
73 | 90 | ||
74 | const ChannelSquare default_ch1 = { | 91 | const ChannelSquare1 default_ch1 = { |
75 | .notes = { | 92 | .notes = { |
76 | {true, NOTE_C_4}, | 93 | {true, NOTE_C_4}, |
77 | {true, NOTE_D_SHARP_4}, | 94 | {true, NOTE_D_SHARP_4}, |
@@ -111,7 +128,7 @@ const ChannelSquare default_ch1 = { | |||
111 | .active = true, | 128 | .active = true, |
112 | }; | 129 | }; |
113 | 130 | ||
114 | const ChannelSquare default_ch2 = { | 131 | const ChannelSquare2 default_ch2 = { |
115 | .notes = { | 132 | .notes = { |
116 | {true, NOTE_C_3}, | 133 | {true, NOTE_C_3}, |
117 | {true, NOTE_C_3}, | 134 | {true, NOTE_C_3}, |
@@ -131,22 +148,22 @@ const ChannelSquare default_ch2 = { | |||
131 | {true, NOTE_C_3}, | 148 | {true, NOTE_C_3}, |
132 | }, | 149 | }, |
133 | .params = { | 150 | .params = { |
134 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 151 | {8, 4, 0, 2, PROB_100, 0}, |
135 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 152 | {8, 4, 0, 2, PROB_100, 0}, |
136 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 153 | {8, 4, 0, 2, PROB_100, 0}, |
137 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 154 | {8, 4, 0, 2, PROB_100, 0}, |
138 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 155 | {8, 4, 0, 2, PROB_100, 0}, |
139 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 156 | {8, 4, 0, 2, PROB_100, 0}, |
140 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 157 | {8, 4, 0, 2, PROB_100, 0}, |
141 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 158 | {8, 4, 0, 2, PROB_100, 0}, |
142 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 159 | {8, 4, 0, 2, PROB_100, 0}, |
143 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 160 | {8, 4, 0, 2, PROB_100, 0}, |
144 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 161 | {8, 4, 0, 2, PROB_100, 0}, |
145 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 162 | {8, 4, 0, 2, PROB_100, 0}, |
146 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 163 | {8, 4, 0, 2, PROB_100, 0}, |
147 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 164 | {8, 4, 0, 2, PROB_100, 0}, |
148 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 165 | {8, 4, 0, 2, PROB_100, 0}, |
149 | {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}, | 166 | {8, 4, 0, 2, PROB_100, 0}, |
150 | }, | 167 | }, |
151 | .active = true, | 168 | .active = true, |
152 | }; | 169 | }; |
@@ -171,22 +188,22 @@ const ChannelWave default_ch3 = { | |||
171 | {true, NOTE_G_5}, | 188 | {true, NOTE_G_5}, |
172 | }, | 189 | }, |
173 | .params = { | 190 | .params = { |
174 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 191 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
175 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 192 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
176 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 193 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
177 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 194 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
178 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 195 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
179 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 196 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
180 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 197 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
181 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 198 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
182 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 199 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
183 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 200 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
184 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 201 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
185 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 202 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
186 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 203 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
187 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 204 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
188 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 205 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
189 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}, | 206 | {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}, |
190 | }, | 207 | }, |
191 | .active = true, | 208 | .active = true, |
192 | }; | 209 | }; |
@@ -244,7 +261,7 @@ static Pattern patterns[8] = { | |||
244 | {default_ch1, default_ch2, default_ch3, default_ch4, default_bpm, 0, true}, | 261 | {default_ch1, default_ch2, default_ch3, default_ch4, default_bpm, 0, true}, |
245 | }; | 262 | }; |
246 | 263 | ||
247 | static ChannelSquareParams ch1_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; | 264 | static ChannelSquare1Params ch1_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; |
248 | static ChannelSquareParams ch2_params = {8, 4, 0, 2, 0, 0, 0, PROB_100, 0}; | 265 | static ChannelSquare2Params ch2_params = {8, 4, 0, 2, PROB_100, 0}; |
249 | static ChannelWaveParams ch3_params = {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, PROB_100, 0}; | 266 | static ChannelWaveParams ch3_params = {3, 0, WAVE_SIN, 0, WAVE_SAW, 0, 0, 0, PROB_100, 0}; |
250 | static ChannelNoiseParams ch4_params = {0xF, 0x2, 0, 0, PROB_100, 0}; | 267 | static ChannelNoiseParams ch4_params = {0xF, 0x2, 0, 0, PROB_100, 0}; |