Customizing control surface behaviour

Hi!

I’m working on an application using tracktion_engine and would like to add support for Mackie MCU control surfaces. I know that tracktion_engine has built-in support for these controllers and this works as expected, but I would like to customize this behaviour.

This would include things like assigning different actions to the MCU’s Function keys or making the Master fader control some application-specific parameter rather than the master volume of the Edit.

Subclassing te::ControlSurface and overriding acceptMidiMessage to customize how commands coming from the control surface are handled would probably work.
But the other direction (sending updates based on the edit state to the control surface) seems to be more problematic.
For example te::ExternalControllerManger::EditStateWatcher and te::ExternalController::updateDeviceState will update the master fader of the controller based on the master volume of the edit (which is not the intended behaviour for the use case mentioned above) and I haven’t found a clean way to change this. At least not without extensive modifications to the tracktion_engine codebase, which would make things difficult to maintain in the future.


What would be the best way to go about this?

I would recommend doing a copy / paste on MackieMCU and rework it to do what you want. When MackieMCU::moveMasterLevelFader is called, if there is no requirement you actually move the hardware fader. If you don’t care about master level, feel free to ignore it or map it to something else.

You can see how something similar is done in MackieMCU::moveFader. If the surface is flipped then I actually move a pan pot, otherwise I move a fader. A channel fader can either control a plugin parameter, aux send level, pan or track level. You could implement something similar for the master fader, where it doesn’t different things based on a mode setting.

There is no requirement you even use any of the callbacks, you can override currentEditChanged and then just listen to the edit’s state. Just be aware if you do that, then you’ll be responsible for mapping between track number in the edit and track number on the surface.