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:
// some snippets of javascript to give an idea
// actual command via obs-websocket-js
await obs.sendCommand('SetSourceFilterSettings', {'sourceName': this.source.name, 'filterName': this.name, 'filterSettings': key_value_pair});
// these are the settings that come back from a GetSourceFilterSettings request.
// note that settings that have not been adjusted from their defaults are not returned
// so best practice is to create your data with default values, and then overwrite them with whatever gets returned
case 'audio_monitor':
this.settings['volume'] = 100; // [0-100] %
this.settings['locked'] = false; // [true|false] Volume locked
this.settings['linked'] = false; // [true|false] Volume linked to source volume
this.settings['mute'] = 0; // [0-2] index: Not linked|Linked to deactivated from main view|Linked to source muting
this.settings['delay'] = 0; // [0-] ms (in 100ms steps)
// device 'default' [string]
// deviceName 'Built-In Output' [string]