feat: Inline MIDI processing with expression and tuning CCs#111
Merged
Conversation
Replace deferred batch MIDI task with inline event processing in audio_handler. MIDI events are now handled on every audio DMA completion (every 256 samples), eliminating scheduling overhead and ensuring reliable delivery. Add support for: - CC7 (main volume, 0-127 → 0-10 range) - CC11 (expression, multiplies with volume) - Program Change (waveform selection) - CCs 36-43 (tuning parameters: bit rate, sample rate, formant, autotune, magnitude) Add waveform compensation (1.4× sine, 1.2× triangle, 1.0× square/saw) so waveform choice doesn't affect perceived volume. Applied pre-limiter to prevent DAC clipping.
enoragon
reviewed
Jul 8, 2026
| /// Sets expression from an incoming MIDI CC11 value (0-127). Multiplies with | ||
| /// `volume` for final output gain — see `handler::audio_handler`. | ||
| pub fn set_expression_from_midi(&mut self, value: u8) { | ||
| self.expression = value as i8; |
Collaborator
There was a problem hiding this comment.
what does the expression do? if it is just volume lets skip
| /// waveform. | ||
| pub fn set_waveform_from_midi(&mut self, channel: u8, program: u8) { | ||
| if channel == 9 || program > 2 { | ||
| return; |
Collaborator
There was a problem hiding this comment.
ignoring is fine for the channel but I think we should be mod wrapping for the programs over 2
| } | ||
| 36..=43 => { | ||
| shared.app_state_machine.lock(|msm| { | ||
| msm.set_tuning_from_cc(controller, value); |
Collaborator
There was a problem hiding this comment.
What is this, and why is it multiple? Let's just ignore the ccs we do not have. We should have one to cycle the musical key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace deferred batch MIDI task with inline event processing in audio_handler. MIDI events are now handled on every audio DMA completion (every 256 samples), eliminating scheduling overhead and ensuring reliable delivery.
Add support for:
Add waveform compensation (1.4× sine, 1.2× triangle, 1.0× square/saw) so waveform choice doesn't affect perceived volume. Applied pre-limiter to prevent DAC clipping.