I'm not sure if it qualifies as elegant, but obs-websocket can adjust settings of an Audio Monitor filter. I believe the MIDI plugin works via obs-websocket so perhaps it's possible by hooking into a call to set a source filter?
I copy-pasted some parts of code below that I'm using. Although it's for a different use case, perhaps different language, it may give a hint.
JavaScript:
await obs.sendCommand('SetSourceFilterSettings', {'sourceName': this.source.name, 'filterName': this.name, 'filterSettings': key_value_pair});
case 'audio_monitor':
this.settings['volume'] = 100;
this.settings['locked'] = false;
this.settings['linked'] = false;
this.settings['mute'] = 0;
this.settings['delay'] = 0;