MIDI SysEx Implementation
Initializing the APC40mk1 into the correct Ableton Live mode.
The first task is sending the correct MIDI SysEx initialization. The APC40 has a peculiar startup sequence: if it is turned on without Ableton Live running, it defaults to a standalone mode that forces MIDI feedback whenever buttons are pressed. That behavior is useful for quick mappings, but it seriously limits our control. Initializing the APC40 with the correct SysEx message lets it start in Ableton Live mode. This avoids forced MIDI feedback and gives us full responsibility for the implementation—which is exactly what we need.
The current definition is located in Editor > Gui > Interaction > MIDI > CompatibleDevices > Apc40Mk2.cs.
Let’s review what we have in `Apc40Mk2.cs`:
The invocation above does not seem to have an effect, so the whole file is duplicated and renamed `APC40mk1.cs` for editing. The product identifier changes from `APC40 mkII` to `Akai APC40`, and the class and constructor names change from `Apc40Mk2` to `Apc40Mk1`.
Proper APC40mk1 initialization
Setting the application/configuration byte to either `41` or `42` boots the APC40 into the mode needed for mapping.
The APC40mk1 colors are limited to off, green, blinking green, orange, blinking orange, red, and blinking red.
All tests are passing. A pull request was opened to include this in the TiXL project: github.com/tixl3d/tixl/pull/868.
Note: To ensure backward compatibility with anyone using Generic `0x40` mode, the configuration is set to that value by default. To use Ableton mode correctly, edit `Apc40Mk1.cs` and change the byte flag to `0x41` or `0x42`.
Future ideas
While implementing proper SysEx, I found myself wanting to send this byte buffer during runtime instead of only when initializing the MIDI device. This will need a byte operator type to avoid converting every byte from hex into decimal individually. The SysEx initialization could clear all controls back to off/0 and could also support MIDI program or bank changes in the future.
