Project Overview
The goal was to create a MIDI controller with capacitive touch keys capable of sending expressive MIDI messages over USB. The device would interface seamlessly with digital audio workstations (DAWs) like Ableton Live and support advanced MIDI features such as MPE.
Hardware Design
The hardware centered around the STM32G474E-EVAL board, chosen for its support for capacitive sensing and USB device functionality. The capacitive keys were designed and implemented using the STM32’s built-in Touch Sensing Controller (TSC). Key layout, PCB design, and signal integrity were carefully considered to ensure reliable touch detection.
Capacitive Touch Implementation
Using STM32CubeMX and the HAL libraries, capacitive keys were configured and tested. The touch system used threshold-based detection and signal filtering to accurately respond to finger input. Testing showed reliable single-touch performance, with plans to expand for polyphonic detection in future iterations.
USB HID and MIDI Class Development
A major technical challenge was implementing USB functionality. Initially, I explored building a USB Audio class, but due to its complexity and lack of need for audio streaming, I transitioned to using the USB HID class—commonly used for devices like keyboards and mice—as a framework for MIDI communication.
USB Mouse and Keyboard Emulation
Mouse HID Implementation: Configured via STM32CubeMX, the board was set to emulate a mouse using a 4-byte report descriptor.
Keyboard HID Implementation: Extended the report descriptor to 8 bytes and reconfigured the HID class to emulate a keyboard.
Despite correct compilation and deployment, both implementations encountered the same USB recognition error on the host computer.
Debugging USB Connectivity
Extensive debugging was performed:
Verified USB descriptors and endpoint settings.
Re-examined PID/VID and interface protocols.
Tested on multiple computers and USB cables.
Checked for hardware faults.
The issue likely stemmed from low-level USB stack initialization or descriptor misconfiguration. Unfortunately, due to the lack of a USB protocol analyzer (typically costing £200–£1500), deeper debugging was limited.
Planned MIDI Driver Implementation
Although a fully functional MIDI driver wasn't completed, a clear plan was outlined:
Adapt an Open-Source USB MIDI HID Library for STM32F1 to STM32G4.
Modify Descriptors and Endpoints to match USB MIDI 2.0 specifications.
Integrate MIDI Polyphonic Expression (MPE) for advanced per-note articulation.
Test and Debug using MIDI monitoring tools and software DAWs.
Integration with Ableton Live
Final project goals included scripting Ableton Live integration using Python:
MIDI Remote Scripts would map controller inputs to Ableton functions.
Custom scripts would allow control over tracks, clips, playback, and effects.
Bi-directional communication would enable feedback (e.g., LED updates) from Ableton to the controller.
Extensive documentation and packaging were planned for future usability.
Conclusion and Future Work
Though the USB driver remained unresolved, the project provided deep insight into USB protocols, embedded systems, and MIDI device design. With more time and access to better debugging tools, especially a USB protocol analyzer, completing the MIDI class driver remains a realistic next step.
Future goals include:
Completing USB MIDI + MPE support.
Expanding touch sensing for multi-touch.
Finalizing Ableton integration for live use.
Potential redesign using a platform like Teensy for faster prototyping and library support.
UPDATE - After more debugging, I got to realise that is some hardware issue with the development I used for the project. The orignal approach, the usb-c and the code were not an issue
Read the attached document for more in-dept information and an appendix section for the verilog code.