nhielost / obs-midi-mg

Allows MIDI devices to interact with OBS Studio.
GNU General Public License v2.0
149 stars 9 forks source link

MIDI output - when the OBS audio source status change #41

Open LMWCoding opened 1 year ago

LMWCoding commented 1 year ago

Thanks for making changes to the way velocity works in MIDIoutput in the recent release, you are fantastic in developing this plugin and taking in users' feedback, big thank you again. I can see how the modified velocity works, however, for the situation I am looking for, it does not work. So this is more of a detail description of feature request, rather than a bug.

The situation is I am using external MIDI control surface (for example, Korg nanoKONTROL 2) to control MUTE of the audio source in OBS. The control surface have a LED light on the button too. So ideally, what we want is if we press the button, and MUTE the audio source, the button lights up, showing it is MUTE. The LED light on the button actually can be controlled by the MIDI message (for example the MIDI message sent by obs-midi-mg).

As is, I can set the nanoKontrol to send the right MIDI command to obs to control the right OBS audio MUTE Toggle, however, there is no MIDI command sent from OBS to turn on the LED on to indicate the audio is now muted. (yes, we can use multiple action such that when OBS-MIDI-MG receive the MIDI message to MUTE, it can send back a MIDI message to turn on the LED. But it doesn't work because the BUTTON sends 127 when pressed, and will send 0 when released. It means obs-midi-mg will send 127 when pressed and 0 turning off the LED when the button is let go. it is not toggle.). Also, it also doesn't solve the other case, that is if user now UNMUTE the audio source on OBS using the UI, there is no MIDI command to turn off the LED sent to nanoKontrol, hence the LED is still on and the status is now not synchronised. (A similar situation is a user feedback about volume slider, if user uses a midi Controller with motorised slider, then ideally, if user changes the vol on the OBS by the UI, the MIDI command is sent to mini Controller to set the slider to the current vol level.)

So ideally, there should be a way for OBS status change to result in a MIDI message sent. This may mean there needs to use OBS Callback API, so for example, when audio source MUTE status is changed, the mute status is sent via a MIDI message.

nhielost commented 1 year ago

Thanks for the feedback.

This is a massive project that will take a long time to implement, but I have been considering the idea since the very beginning of the development of this plugin. A future release should contain this feature, although it may take a while. Have patience!

mishakim commented 1 year ago

In the same vein, I'd love to have to ability to send a MIDI command when specific scenes are used. Specifically, I have scenes where I want to mute one source and change the gain of another whenever I switch to the scene. Currently, I send a MIDI command to this plugin to change the scene*, and separately send MIDI commands to my DAW to adjust the audio. I'd like to have those MIDI commands sent to my DAW whenever that scene is activated.

*I'm not selecting a specific scene, so I can't use a multi-action to combine the MIDI commands. I'm using a "next scene" script that steps through the scene list in order using a single hotkey, and that's what I use within this plugin to change the scene. I need the MIDI commands for volume adjust to be sent no matter how the scene was activated.

It seems to me like the way to do this would be to have a "source" within the scene that triggers the outbound MIDI commands, but I don't know if that's actually the best way to implement this.

agardnerIT commented 7 months ago

I kind of have this working but to do it properly would require a massive, complex set of bindings to "turn off" the other LEDs. Imagine a row of buttons where only 1 should be highlighted at a time.

I wonder if the plugin could accept a DAG input or perhaps a JSON file which says: If I get an input type A on channel B, note C and velocity D then emit signals for combinations of type AA, channel BB, note CC, velocity DD + type EE, channel FF, note GG and velocity HH

For example:

When: input = velocity: 127 channel 41 then send all of the following outputs at once:

velocity = 127, channel 41 # to override the note off event and thus enable the LED
velocity= 0, channel 42 # disable next button in row
velocity= 0, channel 42 # disable LED for third button in row
velocity= 0, channel 42 # disable LED for fourth button in row

As a directed acyclic graph this would look like:

dag {

# Possible states
"note on, 41, 127"
"note on, 42, 127"
"note on, 43, 127"

"note off, 41, 0"
"note off, 42, 0"
"note off, 43, 0"

# Message flows

# If 41 is turned on
# Send on to 41 (enable LED)
# Send off to 42 and 43
"note on, 41, 127" -> "note on, 41, 127"
"note on, 41, 127" -> "note off, 42, 0"
"note on, 41, 127" -> "note off, 43, 0"

# If 42 is turned on
# Send on to 42 (enable LED)
# Send off to 41 and 43
"note on, 42, 127" -> "note on, 42, 127"
"note on, 42, 127" -> "note off, 41, 0"
"note off, 42, 127" -> "note off, 43, 0"

# If 43 is turned on
# Send on to 43 (enable LED)
# Send off to 41 and 42
"note on, 43, 127" -> "note on, 43, 127"
"note on, 43, 127" -> "note off, 41, 0"
"note off, 43, 127" -> "note off, 42, 0"

}

Think about it, 3.0.0 already provides the ability to emit a MIDI event on an incoming one. Perhaps all that's needed is to add the ability to send multiple such events based on one input?

Mind you "all that's needed" ... that's easy for me to say since I have no idea of the voodoo magic you've built here! :)