Mute channel when shift + play pressed (#14)

Fixes https://github.com/awonak/alt-gravity/issues/2

Reviewed-on: https://git.pinkduck.xyz/awonak/libGravity/pulls/14
This commit is contained in:
2025-07-21 00:01:18 +00:00
parent 5729eef037
commit 1bf90e1674
2 changed files with 31 additions and 5 deletions

View File

@ -2,7 +2,7 @@
* @file Gravity.ino * @file Gravity.ino
* @author Adam Wonak (https://github.com/awonak/) * @author Adam Wonak (https://github.com/awonak/)
* @brief Alt firmware version of Gravity by Sitka Instruments. * @brief Alt firmware version of Gravity by Sitka Instruments.
* @version v2.0.1 - June 2025 awonak - Full rewrite * @version v2.0.1 - June 2025 awonak - Full rewrite
* @version v1.0 - August 2023 Oleksiy H - Initial release * @version v1.0 - August 2023 Oleksiy H - Initial release
* @date 2025-07-04 * @date 2025-07-04
* *
@ -25,7 +25,7 @@
* quantization of features like duty cycle (pulse width) or offset. * quantization of features like duty cycle (pulse width) or offset.
* Additionally, this firmware replaces the sequencer with a Euclidean Rhythm * Additionally, this firmware replaces the sequencer with a Euclidean Rhythm
* generator. * generator.
* *
* ENCODER: * ENCODER:
* Press: change between selecting a parameter and editing the parameter. * Press: change between selecting a parameter and editing the parameter.
* Hold & Rotate: change current selected output channel. * Hold & Rotate: change current selected output channel.
@ -33,17 +33,17 @@
* BTN1: * BTN1:
* Play/pause - start or stop the internal clock. * Play/pause - start or stop the internal clock.
* *
* BTN2: * BTN2:
* Shift - hold and rotate encoder to change current selected output channel. * Shift - hold and rotate encoder to change current selected output channel.
* *
* EXT: * EXT:
* External clock input. When Gravity is set to INTERNAL clock mode, this * External clock input. When Gravity is set to INTERNAL clock mode, this
* input is used to reset clocks. * input is used to reset clocks.
* *
* CV1: * CV1:
* CV2: * CV2:
* External analog input used to provide modulation to any channel parameter. * External analog input used to provide modulation to any channel parameter.
* *
*/ */
#include <gravity.h> #include <gravity.h>
@ -168,6 +168,21 @@ void HandleExtClockTick() {
// //
void HandlePlayPressed() { void HandlePlayPressed() {
// Check if SHIFT is pressed to mute all/current channel.
if (gravity.shift_button.On()) {
if (app.selected_channel == 0) {
// Mute all channels
for (int i = 0; i < Gravity::OUTPUT_COUNT; i++) {
app.channel[i].toggleMute();
}
} else {
// Mute selected channel
auto& ch = GetSelectedChannel();
ch.toggleMute();
}
return;
}
gravity.clock.IsPaused() gravity.clock.IsPaused()
? gravity.clock.Start() ? gravity.clock.Start()
: gravity.clock.Stop(); : gravity.clock.Stop();

View File

@ -161,6 +161,8 @@ class Channel {
byte getSteps(bool withCvMod = false) const { return withCvMod ? pattern.GetSteps() : base_euc_steps; } byte getSteps(bool withCvMod = false) const { return withCvMod ? pattern.GetSteps() : base_euc_steps; }
byte getHits(bool withCvMod = false) const { return withCvMod ? pattern.GetHits() : base_euc_hits; } byte getHits(bool withCvMod = false) const { return withCvMod ? pattern.GetHits() : base_euc_hits; }
void toggleMute() { mute = !mute; }
/** /**
* @brief Processes a clock tick and determines if the output should be high or low. * @brief Processes a clock tick and determines if the output should be high or low.
* Note: this method is called from an ISR and must be kept as simple as possible. * Note: this method is called from an ISR and must be kept as simple as possible.
@ -168,6 +170,12 @@ class Channel {
* @param output The output object to be modified. * @param output The output object to be modified.
*/ */
void processClockTick(uint32_t tick, DigitalOutput& output) { void processClockTick(uint32_t tick, DigitalOutput& output) {
// Mute check
if (mute) {
output.Low();
return;
}
const uint16_t mod_pulses = pgm_read_word_near(&CLOCK_MOD_PULSES[cvmod_clock_mod_index]); const uint16_t mod_pulses = pgm_read_word_near(&CLOCK_MOD_PULSES[cvmod_clock_mod_index]);
// Conditionally apply swing on down beats. // Conditionally apply swing on down beats.
@ -298,6 +306,9 @@ class Channel {
// Euclidean pattern // Euclidean pattern
Pattern pattern; Pattern pattern;
// Mute channel flag
bool mute;
// Pre-calculated pulse values for ISR performance // Pre-calculated pulse values for ISR performance
uint16_t _duty_pulses; uint16_t _duty_pulses;
uint16_t _offset_pulses; uint16_t _offset_pulses;