Skip to content

Conversation

@lucastephann
Copy link
Contributor

@lucastephann lucastephann commented Sep 5, 2025

Summary

Adds dedicated MIDI CC commands for loading presets to specific A/B slots without switching, enabling advanced workflows while preserving existing functionality.

Changes

  • CC 120: Load Preset to Slot A (values 0-19) without switching to it
  • CC 121: Load Preset to Slot B (values 0-19) without switching to it
  • Both commands bypass CONFIG_ITEM_SAVE_PRESET_TO_SLOT global configuration
  • Maintains full backward compatibility with existing CC 127 behavior
  • Added proper input validation and error logging
  • Updated MidiCommands.md documentation

Use Case

This feature enables the controller to receive MIDI:

  1. Message CC 120 to load a preset into Slot A (preset stays loaded but inactive)
  2. Message CC 121 to load a preset into Slot B (preset stays loaded but inactive)
  3. Use TONEX ONE footswitch to toggle between the loaded A/B presets
  4. Maintain independent control over slot content and slot selection

Technical Implementation

  • source/main/usb_comms.h: Added USB_COMMAND_LOAD_PRESET_TO_SLOT_A/B commands and function declarations
  • source/main/usb_comms.c: Implemented thread-safe queue functions usb_load_preset_to_slot_a/b()
  • source/main/usb_tonex_one.c: Added command handlers in usb_tonex_one_handle() switch statement
  • source/main/midi_helper.c: Updated MIDI CC 120/121 handlers to use thread-safe queue functions
  • MidiCommands.md: Updated documentation with new commands

Addresses PR feedback by using message queue pattern instead of direct USB function calls for thread safety.

MIDI Command Reference

CC Command Values Behavior
120 Load Preset to Slot A 0-19 Loads preset 1-20 to Slot A, no switching
121 Load Preset to Slot B 0-19 Loads preset 1-20 to Slot B, no switching
127 Select Preset 0-19 Existing behavior (load + switch to configured slot)

…t A/B slot targeting

- Add CC 120: Load Preset to Slot A (values 0-19)
- Add CC 121: Load Preset to Slot B (values 0-19)
- Both commands bypass global slot configuration
- Both commands load without switching active slot (selectSlot=0)
- Maintain full backward compatibility with CC 127
- Add proper validation and error logging
- Update MIDI commands documentation

Resolves independent A/B preset loading for HX Stomp workflows
# Conflicts:
#	source/main/midi_helper.c
lucastephann and others added 2 commits September 8, 2025 10:35
…t targeting

- Add CC 120 (Load Preset to Slot A) and CC 121 (Load Preset to Slot B)
- Implement thread-safe architecture using message queues instead of direct USB calls
- Add USB_COMMAND_LOAD_PRESET_TO_SLOT_A/B commands to enum
- Add usb_load_preset_to_slot_a/b() queue functions in usb_comms.c
- Add command handlers in usb_tonex_one_handle() switch statement
- Update MIDI handlers to use new thread-safe functions
- Allows HX Stomp to independently load presets into both slots without forcing mode changes
- Preserves TONEX ONE's native A/B toggle functionality and tuner access

Addresses PR feedback regarding thread safety - replaced direct USB function calls
from MIDI thread with proper message queue pattern as suggested by reviewer.
@Builty Builty merged commit fe08081 into Builty:main Sep 9, 2025
@lucastephann lucastephann deleted the midi-cc-ab-preset-selection branch September 9, 2025 17:46
@luizhenriquemm
Copy link

luizhenriquemm commented Sep 30, 2025

@lucastephann Brother, I love you. You can't imagine how much I wanted this feature... Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants