aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-11 18:55:34 +0200
committerBad Diode <bd@badd10de.dev>2021-06-11 18:55:34 +0200
commitb7e6e742bee3d1c3b0d5f7a15fea31107da3540e (patch)
treed0fbb85b550e00318924a4fc7bff490bce816b6e
parentc4fc5e9607ab9cc4bab7cfecfda12ae378b1e2d7 (diff)
downloadstepper-b7e6e742bee3d1c3b0d5f7a15fea31107da3540e.tar.gz
stepper-b7e6e742bee3d1c3b0d5f7a15fea31107da3540e.zip
Add parametric colors
-rw-r--r--src/sequencer.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 31d5490..b5182c1 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -12,6 +12,14 @@
12#define COL_CYAN 4 12#define COL_CYAN 4
13#define COL_GREY 5 13#define COL_GREY 5
14 14
15// Theme colors.
16#define COL_CURSOR COL_BLUE
17#define COL_NOTE_PRESSED COL_BLUE
18#define COL_CURRENT_CHANNEL COL_FG
19#define COL_CURRENT_TRIG COL_FG
20#define COL_WAVE_A COL_RED
21#define COL_WAVE_B COL_CYAN
22
15// 23//
16// Assets. 24// Assets.
17// 25//
@@ -674,8 +682,8 @@ draw_parameters_ch3(void) {
674 size_t y = PARAMS_START_Y + 2; 682 size_t y = PARAMS_START_Y + 2;
675 683
676 // Wave Patterns. 684 // Wave Patterns.
677 draw_wave_pattern(wave_a, x, y, COL_RED); 685 draw_wave_pattern(wave_a, x, y, COL_WAVE_A);
678 draw_wave_pattern(wave_b, x + 70, y, COL_CYAN); 686 draw_wave_pattern(wave_b, x + 70, y, COL_WAVE_B);
679 687
680 // Wave text. 688 // Wave text.
681 x -= 2; 689 x -= 2;
@@ -936,10 +944,10 @@ handle_channel_selection(void) {
936 trig_selection_loc = 0; 944 trig_selection_loc = 0;
937 param_selection_loc = 0; 945 param_selection_loc = 0;
938 input_handler = handle_trigger_selection; 946 input_handler = handle_trigger_selection;
939 draw_channel_cursor(channel_selection_loc, COL_GREY); 947 draw_channel_cursor(channel_selection_loc, COL_CURRENT_CHANNEL);
940 draw_trig_cursor(trig_selection_loc, COL_BLUE); 948 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
941 TriggerNote *trig = get_current_trig(); 949 TriggerNote *trig = get_current_trig();
942 draw_note(trig->note, COL_BLUE); 950 draw_note(trig->note, COL_NOTE_PRESSED);
943 draw_parameters(); 951 draw_parameters();
944 } else if (key_tap(KEY_UP)) { 952 } else if (key_tap(KEY_UP)) {
945 draw_channel_cursor(channel_selection_loc, COL_BG); 953 draw_channel_cursor(channel_selection_loc, COL_BG);
@@ -948,7 +956,7 @@ handle_channel_selection(void) {
948 } else { 956 } else {
949 channel_selection_loc = MAX(channel_selection_loc - 1, 0); 957 channel_selection_loc = MAX(channel_selection_loc - 1, 0);
950 } 958 }
951 draw_channel_cursor(channel_selection_loc, COL_BLUE); 959 draw_channel_cursor(channel_selection_loc, COL_CURSOR);
952 draw_triggers(); 960 draw_triggers();
953 } else if (key_tap(KEY_DOWN)) { 961 } else if (key_tap(KEY_DOWN)) {
954 draw_channel_cursor(channel_selection_loc, COL_BG); 962 draw_channel_cursor(channel_selection_loc, COL_BG);
@@ -957,7 +965,7 @@ handle_channel_selection(void) {
957 } else { 965 } else {
958 channel_selection_loc = MIN(channel_selection_loc + 1, SEQ_N_CHANNELS); 966 channel_selection_loc = MIN(channel_selection_loc + 1, SEQ_N_CHANNELS);
959 } 967 }
960 draw_channel_cursor(channel_selection_loc, COL_BLUE); 968 draw_channel_cursor(channel_selection_loc, COL_CURSOR);
961 draw_triggers(); 969 draw_triggers();
962 } 970 }
963} 971}
@@ -967,7 +975,7 @@ handle_param_selection_ch1(void) {
967 if (key_tap(KEY_A)) { 975 if (key_tap(KEY_A)) {
968 // TODO: draw param cursor. 976 // TODO: draw param cursor.
969 input_handler = handle_trigger_selection; 977 input_handler = handle_trigger_selection;
970 draw_trig_cursor(trig_selection_loc, COL_BLUE); 978 draw_trig_cursor(trig_selection_loc, COL_CURRENT_TRIG);
971 } 979 }
972 // // Move through the selected synth parameters. 980 // // Move through the selected synth parameters.
973 // if (key_tap(KEY_LEFT)) { 981 // if (key_tap(KEY_LEFT)) {
@@ -1036,7 +1044,7 @@ handle_param_selection_ch2(void) {
1036 if (key_tap(KEY_A)) { 1044 if (key_tap(KEY_A)) {
1037 // TODO: draw param cursor. 1045 // TODO: draw param cursor.
1038 input_handler = handle_trigger_selection; 1046 input_handler = handle_trigger_selection;
1039 draw_trig_cursor(trig_selection_loc, COL_BLUE); 1047 draw_trig_cursor(trig_selection_loc, COL_CURRENT_TRIG);
1040 } 1048 }
1041 // // Move through the selected synth parameters. 1049 // // Move through the selected synth parameters.
1042 // if (key_tap(KEY_LEFT)) { 1050 // if (key_tap(KEY_LEFT)) {
@@ -1106,7 +1114,7 @@ handle_param_selection_ch3(void) {
1106 // Go back to trigger selection. 1114 // Go back to trigger selection.
1107 draw_params_cursor(param_selection_loc, COL_BG); 1115 draw_params_cursor(param_selection_loc, COL_BG);
1108 input_handler = handle_trigger_selection; 1116 input_handler = handle_trigger_selection;
1109 draw_trig_cursor(trig_selection_loc, COL_BLUE); 1117 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1110 } 1118 }
1111 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { 1119 if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) {
1112 int inc = 0; 1120 int inc = 0;
@@ -1132,7 +1140,7 @@ handle_param_selection_ch3(void) {
1132 } 1140 }
1133 draw_params_cursor_ch3(param_selection_loc, COL_BG); 1141 draw_params_cursor_ch3(param_selection_loc, COL_BG);
1134 param_selection_loc = CLAMP(loc + inc, 0, 73); 1142 param_selection_loc = CLAMP(loc + inc, 0, 73);
1135 draw_params_cursor_ch3(param_selection_loc, COL_BLUE); 1143 draw_params_cursor_ch3(param_selection_loc, COL_CURSOR);
1136 } 1144 }
1137 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { 1145 if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) {
1138 int inc = 0; 1146 int inc = 0;
@@ -1188,7 +1196,7 @@ handle_param_selection_ch3(void) {
1188 } 1196 }
1189 draw_params_cursor_ch3(param_selection_loc, COL_BG); 1197 draw_params_cursor_ch3(param_selection_loc, COL_BG);
1190 param_selection_loc = CLAMP(loc + inc, 0, 73); 1198 param_selection_loc = CLAMP(loc + inc, 0, 73);
1191 draw_params_cursor_ch3(param_selection_loc, COL_BLUE); 1199 draw_params_cursor_ch3(param_selection_loc, COL_CURSOR);
1192 } 1200 }
1193 if (key_tap(KEY_R) || key_tap(KEY_L)) { 1201 if (key_tap(KEY_R) || key_tap(KEY_L)) {
1194 int odd = param_selection_loc & 0x1; 1202 int odd = param_selection_loc & 0x1;
@@ -1267,7 +1275,7 @@ handle_param_selection_ch3(void) {
1267 *wave_volume = CLAMP(*wave_volume + inc, 0, 4); 1275 *wave_volume = CLAMP(*wave_volume + inc, 0, 4);
1268 } 1276 }
1269 draw_parameters(); 1277 draw_parameters();
1270 draw_params_cursor(param_selection_loc, COL_BLUE); 1278 draw_params_cursor(param_selection_loc, COL_CURSOR);
1271 } 1279 }
1272} 1280}
1273 1281
@@ -1284,7 +1292,7 @@ handle_trigger_selection(void) {
1284 if (trig->active) { 1292 if (trig->active) {
1285 draw_note(trig->note, COL_FG); 1293 draw_note(trig->note, COL_FG);
1286 trig->note = MAX(trig->note - 1, NOTE_C_2); 1294 trig->note = MAX(trig->note - 1, NOTE_C_2);
1287 draw_note(trig->note, COL_BLUE); 1295 draw_note(trig->note, COL_NOTE_PRESSED);
1288 clear_trigger(trig_selection_loc); 1296 clear_trigger(trig_selection_loc);
1289 draw_trigger(channel_selection_loc, trig_selection_loc); 1297 draw_trigger(channel_selection_loc, trig_selection_loc);
1290 } 1298 }
@@ -1293,7 +1301,7 @@ handle_trigger_selection(void) {
1293 if (trig->active) { 1301 if (trig->active) {
1294 draw_note(trig->note, COL_FG); 1302 draw_note(trig->note, COL_FG);
1295 trig->note = MIN( trig->note + 1, NOTE_C_8 - 1); 1303 trig->note = MIN( trig->note + 1, NOTE_C_8 - 1);
1296 draw_note(trig->note, COL_BLUE); 1304 draw_note(trig->note, COL_NOTE_PRESSED);
1297 clear_trigger(trig_selection_loc); 1305 clear_trigger(trig_selection_loc);
1298 draw_trigger(channel_selection_loc, trig_selection_loc); 1306 draw_trigger(channel_selection_loc, trig_selection_loc);
1299 } 1307 }
@@ -1306,15 +1314,15 @@ handle_trigger_selection(void) {
1306 draw_trig_cursor(trig_selection_loc, COL_BG); 1314 draw_trig_cursor(trig_selection_loc, COL_BG);
1307 draw_note(trig->note, COL_FG); 1315 draw_note(trig->note, COL_FG);
1308 input_handler = handle_channel_selection; 1316 input_handler = handle_channel_selection;
1309 draw_channel_cursor(channel_selection_loc, COL_BLUE); 1317 draw_channel_cursor(channel_selection_loc, COL_CURSOR);
1310 clear_parameters(); 1318 clear_parameters();
1311 } else { 1319 } else {
1312 draw_trig_cursor(trig_selection_loc, COL_BG); 1320 draw_trig_cursor(trig_selection_loc, COL_BG);
1313 draw_note(trig->note, COL_FG); 1321 draw_note(trig->note, COL_FG);
1314 trig_selection_loc = MAX(trig_selection_loc - 1, 0); 1322 trig_selection_loc = MAX(trig_selection_loc - 1, 0);
1315 trig = get_current_trig(); 1323 trig = get_current_trig();
1316 draw_trig_cursor(trig_selection_loc, COL_BLUE); 1324 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1317 draw_note(trig->note, COL_BLUE); 1325 draw_note(trig->note, COL_NOTE_PRESSED);
1318 draw_parameters(); 1326 draw_parameters();
1319 } 1327 }
1320 } else if (key_tap(KEY_RIGHT)) { 1328 } else if (key_tap(KEY_RIGHT)) {
@@ -1323,8 +1331,8 @@ handle_trigger_selection(void) {
1323 draw_note(trig->note, COL_FG); 1331 draw_note(trig->note, COL_FG);
1324 trig_selection_loc = MIN(trig_selection_loc + 1, 15); 1332 trig_selection_loc = MIN(trig_selection_loc + 1, 15);
1325 trig = get_current_trig(); 1333 trig = get_current_trig();
1326 draw_trig_cursor(trig_selection_loc, COL_BLUE); 1334 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1327 draw_note(trig->note, COL_BLUE); 1335 draw_note(trig->note, COL_NOTE_PRESSED);
1328 draw_parameters(); 1336 draw_parameters();
1329 } 1337 }
1330 } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { 1338 } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) {
@@ -1332,8 +1340,8 @@ handle_trigger_selection(void) {
1332 draw_note(trig->note, COL_FG); 1340 draw_note(trig->note, COL_FG);
1333 trig_selection_loc = (trig_selection_loc + 8) % 16; 1341 trig_selection_loc = (trig_selection_loc + 8) % 16;
1334 trig = get_current_trig(); 1342 trig = get_current_trig();
1335 draw_trig_cursor(trig_selection_loc, COL_BLUE); 1343 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1336 draw_note(trig->note, COL_BLUE); 1344 draw_note(trig->note, COL_NOTE_PRESSED);
1337 draw_parameters(); 1345 draw_parameters();
1338 } else if (key_tap(KEY_A)) { 1346 } else if (key_tap(KEY_A)) {
1339 // Switch to parameter selection. 1347 // Switch to parameter selection.
@@ -1348,8 +1356,8 @@ handle_trigger_selection(void) {
1348 input_handler = handle_param_selection_ch3; 1356 input_handler = handle_param_selection_ch3;
1349 } break; 1357 } break;
1350 } 1358 }
1351 draw_params_cursor(param_selection_loc, COL_BLUE); 1359 draw_params_cursor(param_selection_loc, COL_CURSOR);
1352 draw_trig_cursor(trig_selection_loc, COL_GREY); 1360 draw_trig_cursor(trig_selection_loc, COL_CURRENT_TRIG);
1353 } 1361 }
1354} 1362}
1355 1363
@@ -1393,13 +1401,13 @@ sequencer_init(void) {
1393 draw_channels(); 1401 draw_channels();
1394 draw_piano(); 1402 draw_piano();
1395 TriggerNote *trig = get_current_trig(); 1403 TriggerNote *trig = get_current_trig();
1396 draw_note(trig->note, COL_BLUE); 1404 draw_note(trig->note, COL_NOTE_PRESSED);
1397 1405
1398 // Initialize input handler. 1406 // Initialize input handler.
1399 channel_selection_loc = 2; // DEBUG: Starting on CH3 1407 channel_selection_loc = 2; // DEBUG: Starting on CH3
1400 input_handler = handle_trigger_selection; 1408 input_handler = handle_trigger_selection;
1401 draw_trig_cursor(trig_selection_loc, 3); 1409 draw_trig_cursor(trig_selection_loc, COL_CURSOR);
1402 draw_channel_cursor(channel_selection_loc, 5); 1410 draw_channel_cursor(channel_selection_loc, COL_CURRENT_CHANNEL);
1403 draw_parameters(); 1411 draw_parameters();
1404 1412
1405 // Initialize sound system. 1413 // Initialize sound system.