diff options
author | Bad Diode <bd@badd10de.dev> | 2023-07-21 20:28:27 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-07-21 20:28:27 +0200 |
commit | 804b7184744194dca5cab79726f31194b7f55b80 (patch) | |
tree | 6cc9dc7e4ad9b7f60dead7f0e497c9bfc28eb435 | |
parent | 8d28d55285d70353001a105cf86797cb76617183 (diff) | |
download | stepper-804b7184744194dca5cab79726f31194b7f55b80.tar.gz stepper-804b7184744194dca5cab79726f31194b7f55b80.zip |
Fix param cursor behaviour for square and noise channels
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/sequencer.c | 129 |
2 files changed, 82 insertions, 50 deletions
@@ -16,9 +16,10 @@ WITH REGARD TO THIS SOFTWARE. | |||
16 | // - Animations for cursor movement/current step highlight. (A fade out maybe?) | 16 | // - Animations for cursor movement/current step highlight. (A fade out maybe?) |
17 | // - Add panning support. | 17 | // - Add panning support. |
18 | // + Add new UI for the parameter pages | 18 | // + Add new UI for the parameter pages |
19 | // - Change cursor drawing for new parameter pages | 19 | // + Change cursor drawing for new parameter pages |
20 | // - Change cursor behaviour for new parameter pages | 20 | // - Change cursor behaviour for new parameter pages |
21 | // - Allow prob control (% based or 1:2, etc.) | 21 | // - Allow prob control (% based or 1:2, etc.) |
22 | // - Display notification when editing a parameter with the highest priority | ||
22 | // | 23 | // |
23 | // Quality of life improvements. | 24 | // Quality of life improvements. |
24 | // - When not on play mode, adjusting a note or a parameter triggers the sound. | 25 | // - When not on play mode, adjusting a note or a parameter triggers the sound. |
diff --git a/src/sequencer.c b/src/sequencer.c index c544f67..7a3ccb4 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -725,47 +725,33 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler | |||
725 | 725 | ||
726 | // Cursor movement. | 726 | // Cursor movement. |
727 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 727 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { |
728 | int inc = 0; | ||
729 | int loc = param_selection_loc; | ||
730 | if (key_tap(KEY_RIGHT)) { | 728 | if (key_tap(KEY_RIGHT)) { |
731 | if (loc < 5) { | 729 | if (param_selection_loc == 4) { |
732 | inc = 1; | 730 | param_selection_loc = 0; |
733 | } else if (loc == 6) { | 731 | } else if (param_selection_loc == 7) { |
734 | inc = -1; | 732 | param_selection_loc = 5; |
733 | } else if (param_selection_loc < 7) { | ||
734 | param_selection_loc++; | ||
735 | } | 735 | } |
736 | } else { | 736 | } else { |
737 | if (loc <= 5) { | 737 | if (param_selection_loc == 0) { |
738 | inc = -1; | 738 | param_selection_loc = 4; |
739 | } else if (loc == 6) { | 739 | } else if (param_selection_loc == 5) { |
740 | inc = -2; | 740 | param_selection_loc = 7; |
741 | } else if (param_selection_loc > 0) { | ||
742 | param_selection_loc--; | ||
741 | } | 743 | } |
742 | } | 744 | } |
743 | param_selection_loc = CLAMP(loc + inc, 0, 6); | ||
744 | redraw_params = true; | 745 | redraw_params = true; |
745 | return false; | 746 | return false; |
746 | } | 747 | } |
747 | 748 | ||
748 | if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { | 749 | if (key_tap(KEY_UP) || key_tap(KEY_DOWN)) { |
749 | int inc = 0; | 750 | if (param_selection_loc < 3) { |
750 | int loc = param_selection_loc; | 751 | param_selection_loc += 5; |
751 | if (key_tap(KEY_UP)) { | 752 | } else if (param_selection_loc > 4) { |
752 | if (loc == 4) { | 753 | param_selection_loc -= 5; |
753 | inc = 2; | ||
754 | } else if (loc == 5) { | ||
755 | inc = 1; | ||
756 | } else if (loc == 6) { | ||
757 | inc = -1; | ||
758 | } | ||
759 | } else { | ||
760 | if (loc == 4) { | ||
761 | inc = 2; | ||
762 | } else if (loc == 5) { | ||
763 | inc = 1; | ||
764 | } else if (loc == 6) { | ||
765 | inc = -1; | ||
766 | } | ||
767 | } | 754 | } |
768 | param_selection_loc = CLAMP(loc + inc, 0, 6); | ||
769 | redraw_params = true; | 755 | redraw_params = true; |
770 | return false; | 756 | return false; |
771 | } | 757 | } |
@@ -781,11 +767,20 @@ set_param_selection_sq1(ChannelSquareParams *params, InputHandler return_handler | |||
781 | switch (param_selection_loc) { | 767 | switch (param_selection_loc) { |
782 | case 0: { params->duty_cycle = CLAMP(params->duty_cycle + inc, 0, 3); } break; | 768 | case 0: { params->duty_cycle = CLAMP(params->duty_cycle + inc, 0, 3); } break; |
783 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; | 769 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; |
784 | case 2: { params->env_direction ^= 1; } break; | 770 | case 2: { |
785 | case 3: { params->env_time = CLAMP(params->env_time + inc, 0, 7); } break; | 771 | if (params->env_time == 7 && inc > 0) { |
786 | case 4: { params->sweep_number = CLAMP(params->sweep_number + inc, 0, 7); } break; | 772 | params->env_time = 0; |
787 | case 5: { params->sweep_time = CLAMP(params->sweep_time + inc, 0, 7); } break; | 773 | } else if (params->env_time == 0 && inc < 0) { |
788 | case 6: { params->sweep_direction ^= 1; } break; | 774 | params->env_time = 7; |
775 | } else if (params->env_time != 0) { | ||
776 | params->env_time = CLAMP(params->env_time + inc, 1, 7); | ||
777 | } | ||
778 | } break; | ||
779 | case 3: { params->env_direction ^= 1; } break; | ||
780 | case 4: { /* TODO: probability */ } break; | ||
781 | case 5: { params->sweep_number = CLAMP(params->sweep_number + inc, 0, 7); } break; | ||
782 | case 6: { params->sweep_time = CLAMP(params->sweep_time + inc, 0, 7); } break; | ||
783 | case 7: { params->sweep_direction ^= 1; } break; | ||
789 | } | 784 | } |
790 | redraw_params = true; | 785 | redraw_params = true; |
791 | return true; | 786 | return true; |
@@ -805,14 +800,23 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler | |||
805 | 800 | ||
806 | // Cursor movement. | 801 | // Cursor movement. |
807 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 802 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { |
808 | int inc = 0; | ||
809 | int loc = param_selection_loc; | ||
810 | if (key_tap(KEY_RIGHT)) { | 803 | if (key_tap(KEY_RIGHT)) { |
811 | inc = 1; | 804 | if (param_selection_loc == 4) { |
805 | param_selection_loc = 0; | ||
806 | } else if (param_selection_loc == 7) { | ||
807 | param_selection_loc = 5; | ||
808 | } else if (param_selection_loc < 7) { | ||
809 | param_selection_loc++; | ||
810 | } | ||
812 | } else { | 811 | } else { |
813 | inc = -1; | 812 | if (param_selection_loc == 0) { |
813 | param_selection_loc = 4; | ||
814 | } else if (param_selection_loc == 5) { | ||
815 | param_selection_loc = 7; | ||
816 | } else if (param_selection_loc > 0) { | ||
817 | param_selection_loc--; | ||
818 | } | ||
814 | } | 819 | } |
815 | param_selection_loc = CLAMP(loc + inc, 0, 3); | ||
816 | redraw_params = true; | 820 | redraw_params = true; |
817 | return false; | 821 | return false; |
818 | } | 822 | } |
@@ -828,8 +832,17 @@ set_param_selection_sq2(ChannelSquareParams *params, InputHandler return_handler | |||
828 | switch (param_selection_loc) { | 832 | switch (param_selection_loc) { |
829 | case 0: { params->duty_cycle = CLAMP(params->duty_cycle + inc, 0, 3); } break; | 833 | case 0: { params->duty_cycle = CLAMP(params->duty_cycle + inc, 0, 3); } break; |
830 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; | 834 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; |
831 | case 2: { params->env_direction ^= 1; } break; | 835 | case 2: { |
832 | case 3: { params->env_time = CLAMP(params->env_time + inc, 0, 7); } break; | 836 | if (params->env_time == 7 && inc > 0) { |
837 | params->env_time = 0; | ||
838 | } else if (params->env_time == 0 && inc < 0) { | ||
839 | params->env_time = 7; | ||
840 | } else if (params->env_time != 0) { | ||
841 | params->env_time = CLAMP(params->env_time + inc, 1, 7); | ||
842 | } | ||
843 | } break; | ||
844 | case 3: { params->env_direction ^= 1; } break; | ||
845 | case 4: { /* TODO: probability */ } break; | ||
833 | } | 846 | } |
834 | redraw_params = true; | 847 | redraw_params = true; |
835 | return true; | 848 | return true; |
@@ -1015,14 +1028,23 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle | |||
1015 | 1028 | ||
1016 | // Cursor movement. | 1029 | // Cursor movement. |
1017 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { | 1030 | if (key_tap(KEY_LEFT) || key_tap(KEY_RIGHT)) { |
1018 | int inc = 0; | ||
1019 | int loc = param_selection_loc; | ||
1020 | if (key_tap(KEY_RIGHT)) { | 1031 | if (key_tap(KEY_RIGHT)) { |
1021 | inc = 1; | 1032 | if (param_selection_loc == 4) { |
1033 | param_selection_loc = 0; | ||
1034 | } else if (param_selection_loc == 7) { | ||
1035 | param_selection_loc = 5; | ||
1036 | } else if (param_selection_loc < 7) { | ||
1037 | param_selection_loc++; | ||
1038 | } | ||
1022 | } else { | 1039 | } else { |
1023 | inc = -1; | 1040 | if (param_selection_loc == 0) { |
1041 | param_selection_loc = 4; | ||
1042 | } else if (param_selection_loc == 5) { | ||
1043 | param_selection_loc = 7; | ||
1044 | } else if (param_selection_loc > 0) { | ||
1045 | param_selection_loc--; | ||
1046 | } | ||
1024 | } | 1047 | } |
1025 | param_selection_loc = CLAMP(loc + inc, 0, 3); | ||
1026 | redraw_params = true; | 1048 | redraw_params = true; |
1027 | return false; | 1049 | return false; |
1028 | } | 1050 | } |
@@ -1038,8 +1060,17 @@ set_param_selection_noise(ChannelNoiseParams *params, InputHandler return_handle | |||
1038 | switch (param_selection_loc) { | 1060 | switch (param_selection_loc) { |
1039 | case 0: { params->bit_mode = CLAMP(params->bit_mode + inc, 0, 1); } break; | 1061 | case 0: { params->bit_mode = CLAMP(params->bit_mode + inc, 0, 1); } break; |
1040 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; | 1062 | case 1: { params->env_volume = CLAMP(params->env_volume + inc, 0, 15); } break; |
1041 | case 2: { params->env_direction ^= 1; } break; | 1063 | case 2: { |
1042 | case 3: { params->env_time = CLAMP(params->env_time + inc, 0, 7); } break; | 1064 | if (params->env_time == 7 && inc > 0) { |
1065 | params->env_time = 0; | ||
1066 | } else if (params->env_time == 0 && inc < 0) { | ||
1067 | params->env_time = 7; | ||
1068 | } else if (params->env_time != 0) { | ||
1069 | params->env_time = CLAMP(params->env_time + inc, 1, 7); | ||
1070 | } | ||
1071 | } break; | ||
1072 | case 3: { params->env_direction ^= 1; } break; | ||
1073 | case 4: { /* TODO: probability */ } break; | ||
1043 | } | 1074 | } |
1044 | redraw_params = true; | 1075 | redraw_params = true; |
1045 | return true; | 1076 | return true; |