diff options
author | Bad Diode <bd@badd10de.dev> | 2024-01-08 14:03:17 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-01-08 14:03:17 +0100 |
commit | 2eb3cfba2bdd569ffeaf94e6e29faac9a83b5b77 (patch) | |
tree | add4d8b40b46ad66c1012dd7fb6d37d4d711db73 | |
parent | f6e253b14f7b4930f5a5e6e1d3ee2bd3009802dd (diff) | |
download | stepper-2eb3cfba2bdd569ffeaf94e6e29faac9a83b5b77.tar.gz stepper-2eb3cfba2bdd569ffeaf94e6e29faac9a83b5b77.zip |
Add trig nudging with B+D-PAD
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/sequencer.c | 113 |
2 files changed, 94 insertions, 25 deletions
@@ -23,8 +23,8 @@ WITH REGARD TO THIS SOFTWARE. | |||
23 | // + Channel params (ALL) editing should only copy the value under the cursor. | 23 | // + Channel params (ALL) editing should only copy the value under the cursor. |
24 | // + Fix scale being active for noise channel (makes no sense) | 24 | // + Fix scale being active for noise channel (makes no sense) |
25 | // + Save scale on metadata | 25 | // + Save scale on metadata |
26 | // + Allow using B + dpad to nudge trigs. This will potentially mean switching | ||
26 | // - Hold L/R retriggers at short intervals? | 27 | // - Hold L/R retriggers at short intervals? |
27 | // - Allow using B + dpad to nudge trigs. This will potentially mean switching | ||
28 | // to key release to enable trigs. | 28 | // to key release to enable trigs. |
29 | // - Fix any bugs we currently have | 29 | // - Fix any bugs we currently have |
30 | // - Add an envelope to ch3, would need to work with a timer in order to make | 30 | // - Add an envelope to ch3, would need to work with a timer in order to make |
@@ -36,10 +36,6 @@ WITH REGARD TO THIS SOFTWARE. | |||
36 | // | 36 | // |
37 | // Low priority: | 37 | // Low priority: |
38 | // | 38 | // |
39 | // UI tweaks. | ||
40 | // - Add custom user themes | ||
41 | // - Animations for cursor movement/current step highlight. (A fade out maybe?) | ||
42 | // | ||
43 | // Quality of life improvements. | 39 | // Quality of life improvements. |
44 | // - When not on play mode, adjusting a note or a parameter triggers the sound. | 40 | // - When not on play mode, adjusting a note or a parameter triggers the sound. |
45 | // This could get annoying, so maybe it should be a configuration option to | 41 | // This could get annoying, so maybe it should be a configuration option to |
diff --git a/src/sequencer.c b/src/sequencer.c index ee72389..a032481 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -1487,21 +1487,66 @@ handle_param_selection_noise() { | |||
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | void | 1489 | void |
1490 | nudge_trigs(int cur_loc, int next_loc) { | ||
1491 | Pattern *pat = &patterns[pattern_selection_loc]; | ||
1492 | switch (channel_selection_loc) { | ||
1493 | case 0: { | ||
1494 | ChannelSquareParams cur_params = pat->ch1.params[cur_loc]; | ||
1495 | TriggerNote cur_trig = pat->ch1.notes[cur_loc]; | ||
1496 | pat->ch1.params[cur_loc] = pat->ch1.params[next_loc]; | ||
1497 | pat->ch1.notes[cur_loc] = pat->ch1.notes[next_loc]; | ||
1498 | pat->ch1.params[next_loc] = cur_params; | ||
1499 | pat->ch1.notes[next_loc] = cur_trig; | ||
1500 | } break; | ||
1501 | case 1: { | ||
1502 | ChannelSquareParams cur_params = pat->ch2.params[cur_loc]; | ||
1503 | TriggerNote cur_trig = pat->ch2.notes[cur_loc]; | ||
1504 | pat->ch2.params[cur_loc] = pat->ch2.params[next_loc]; | ||
1505 | pat->ch2.notes[cur_loc] = pat->ch2.notes[next_loc]; | ||
1506 | pat->ch2.params[next_loc] = cur_params; | ||
1507 | pat->ch2.notes[next_loc] = cur_trig; | ||
1508 | } break; | ||
1509 | case 2: { | ||
1510 | ChannelWaveParams cur_params = pat->ch3.params[cur_loc]; | ||
1511 | TriggerNote cur_trig = pat->ch3.notes[cur_loc]; | ||
1512 | pat->ch3.params[cur_loc] = pat->ch3.params[next_loc]; | ||
1513 | pat->ch3.notes[cur_loc] = pat->ch3.notes[next_loc]; | ||
1514 | pat->ch3.params[next_loc] = cur_params; | ||
1515 | pat->ch3.notes[next_loc] = cur_trig; | ||
1516 | } break; | ||
1517 | case 3: { | ||
1518 | ChannelNoiseParams cur_params = pat->ch4.params[cur_loc]; | ||
1519 | TriggerNote cur_trig = pat->ch4.notes[cur_loc]; | ||
1520 | pat->ch4.params[cur_loc] = pat->ch4.params[next_loc]; | ||
1521 | pat->ch4.notes[cur_loc] = pat->ch4.notes[next_loc]; | ||
1522 | pat->ch4.params[next_loc] = cur_params; | ||
1523 | pat->ch4.notes[next_loc] = cur_trig; | ||
1524 | } break; | ||
1525 | default: break; | ||
1526 | } | ||
1527 | } | ||
1528 | |||
1529 | void | ||
1490 | handle_trigger_selection(void) { | 1530 | handle_trigger_selection(void) { |
1491 | TriggerNote *trig = get_current_trig(); | 1531 | TriggerNote *trig = get_current_trig(); |
1492 | 1532 | ||
1533 | static bool nudge = false; | ||
1493 | bool empty = patterns[pattern_selection_loc].empty; | 1534 | bool empty = patterns[pattern_selection_loc].empty; |
1494 | if (key_hold(KEY_B)) { | 1535 | if (key_hold(KEY_B)) { |
1495 | } else if (key_released(KEY_B)) { | 1536 | } else if (key_released(KEY_B)) { |
1496 | if (key_hold(KEY_SELECT)) { | 1537 | if (nudge) { |
1497 | clipboard_copy(); | 1538 | nudge = false; |
1498 | } else { | 1539 | } else { |
1499 | if (empty) { | 1540 | if (key_hold(KEY_SELECT)) { |
1500 | clear_pattern(pattern_selection_loc); | 1541 | clipboard_copy(); |
1542 | } else { | ||
1543 | if (empty) { | ||
1544 | clear_pattern(pattern_selection_loc); | ||
1545 | } | ||
1546 | trig->active ^= 1; | ||
1501 | } | 1547 | } |
1502 | trig->active ^= 1; | ||
1503 | redraw_trigs = true; | ||
1504 | } | 1548 | } |
1549 | redraw_trigs = true; | ||
1505 | } else if (key_tap(KEY_L)) { | 1550 | } else if (key_tap(KEY_L)) { |
1506 | s32 inc = -1; | 1551 | s32 inc = -1; |
1507 | if (key_hold(KEY_SELECT)) { | 1552 | if (key_hold(KEY_SELECT)) { |
@@ -1540,27 +1585,55 @@ handle_trigger_selection(void) { | |||
1540 | 1585 | ||
1541 | // Move trigger cursor. | 1586 | // Move trigger cursor. |
1542 | if (key_tap(KEY_LEFT)) { | 1587 | if (key_tap(KEY_LEFT)) { |
1543 | if (trig_selection_loc == 0 || trig_selection_loc == 8) { | 1588 | if (key_hold(KEY_B)) { |
1544 | // We are at the boundary, switch to channel selection. | 1589 | if (trig_selection_loc != 0 && trig_selection_loc != 8) { |
1545 | input_handler = handle_channel_selection; | 1590 | int next_selection_loc = MAX(trig_selection_loc - 1, 0); |
1591 | nudge_trigs(trig_selection_loc, next_selection_loc); | ||
1592 | nudge = true; | ||
1593 | trig_selection_loc = next_selection_loc; | ||
1594 | } | ||
1595 | redraw_trigs = true; | ||
1546 | } else { | 1596 | } else { |
1547 | trig_selection_loc = MAX(trig_selection_loc - 1, 0); | 1597 | if (trig_selection_loc == 0 || trig_selection_loc == 8) { |
1598 | // We are at the boundary, switch to channel selection. | ||
1599 | input_handler = handle_channel_selection; | ||
1600 | } else { | ||
1601 | trig_selection_loc = MAX(trig_selection_loc - 1, 0); | ||
1602 | } | ||
1548 | } | 1603 | } |
1549 | redraw_params = true; | 1604 | redraw_params = true; |
1550 | } else if (key_tap(KEY_RIGHT)) { | 1605 | } else if (key_tap(KEY_RIGHT)) { |
1551 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { | 1606 | if (key_hold(KEY_B)) { |
1552 | trig_selection_loc = MIN(trig_selection_loc + 1, 15); | 1607 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { |
1553 | } else if (trig_selection_loc == 7) { | 1608 | int next_selection_loc = MIN(trig_selection_loc + 1, 15); |
1554 | input_handler = handle_right_col_selection; | 1609 | nudge_trigs(trig_selection_loc, next_selection_loc); |
1555 | right_col_selection_loc = R_COL_BPM; | 1610 | nudge = true; |
1556 | } else if (trig_selection_loc == 15) { | 1611 | trig_selection_loc = next_selection_loc; |
1557 | right_col_selection_loc = R_COL_PLAY; | 1612 | } |
1558 | input_handler = handle_right_col_selection; | 1613 | redraw_trigs = true; |
1614 | } else { | ||
1615 | if (trig_selection_loc != 7 && trig_selection_loc != 15) { | ||
1616 | trig_selection_loc = MIN(trig_selection_loc + 1, 15); | ||
1617 | } else if (trig_selection_loc == 7) { | ||
1618 | input_handler = handle_right_col_selection; | ||
1619 | right_col_selection_loc = R_COL_BPM; | ||
1620 | } else if (trig_selection_loc == 15) { | ||
1621 | right_col_selection_loc = R_COL_PLAY; | ||
1622 | input_handler = handle_right_col_selection; | ||
1623 | } | ||
1559 | } | 1624 | } |
1560 | redraw_params = true; | 1625 | redraw_params = true; |
1561 | } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { | 1626 | } else if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { |
1562 | trig_selection_loc = (trig_selection_loc + 8) % 16; | 1627 | if (key_hold(KEY_B)) { |
1563 | redraw_params = true; | 1628 | int next_selection_loc = (trig_selection_loc + 8) % 16; |
1629 | nudge_trigs(trig_selection_loc, next_selection_loc); | ||
1630 | nudge = true; | ||
1631 | trig_selection_loc = next_selection_loc; | ||
1632 | redraw_trigs = true; | ||
1633 | } else { | ||
1634 | trig_selection_loc = (trig_selection_loc + 8) % 16; | ||
1635 | redraw_params = true; | ||
1636 | } | ||
1564 | } else if (key_tap(KEY_A)) { | 1637 | } else if (key_tap(KEY_A)) { |
1565 | if (key_hold(KEY_SELECT)) { | 1638 | if (key_hold(KEY_SELECT)) { |
1566 | if (patterns[pattern_selection_loc].empty) { | 1639 | if (patterns[pattern_selection_loc].empty) { |