MIDItoOBS
MIDItoOBS copied to clipboard
Toggle button not working
I was trying to set up a toggle button as such. the button lights up when pressed once. then turns down when pressed again. thus trying to set up toggle mute. but, it so happens i need to press the button twice for the toggle to happen.
i think the problem is, said button outputs value 127 when pressed first. then value 0 when pressed again. where in the miditoobs, the toggle is expecting 127 each time the button is pressed.
i tried editing config manually but i dont see a field for the value. as in when value 127 mute: true. then create another listener for that midi key with value 0 mute: false.
am i doing something wrong?
Currently that is intended behaviour. But i want to change that in the future. It's the same base problem as this one: https://github.com/lebaston100/MIDItoOBS/issues/24
If you want to use the toggle function in the meantime you have to program your controller to send a value of 127 every time the button is pressed.
hmm, could also listen to both note_on and note_off for the channel, and ignore the value. give it a boolean of toggled in the config file to switch between the current method and the toggle method. Warmest Regards,
Christopher P. Yarger
Phone: 802-505-7574 Skype: cpyarger
/************************************ Based upon email reliability concerns, please send an acknowledgment in response to this note.
On Sat, May 9, 2020 at 2:40 AM lebaston100 [email protected] wrote:
Currently that is intended behaviour. But i want to change that in the future. It's the same base problem as this one: #24 https://github.com/lebaston100/MIDItoOBS/issues/24
If you want to use the toggle function in the meantime you have to program your controller to send a value of 127 every time the button is pressed.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lebaston100/MIDItoOBS/issues/26#issuecomment-626116333, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANSE6SFSIJJU5A7QDCQXKLRQT3F7ANCNFSM4M4OVELQ .
I changed
def handle_midi_input(self, message, deviceID, deviceName):
self.log.debug("Received %s %s %s %s %s", str(message), "from device", deviceID, "/", deviceName)
if message.type == "note_on":
return self.handle_midi_button(deviceID, message.channel, message.type, message.note)
to
def handle_midi_input(self, message, deviceID, deviceName):
self.log.debug("Received %s %s %s %s %s", str(message), "from device", deviceID, "/", deviceName)
if message.type == "note_on" or message.type == "note_off":
return self.handle_midi_button(deviceID, message.channel, message.type, message.note)
and then manually added a "note_off" entry in the config file to get this behavior.
That seemed to be the only change needed in main.py. I may look at setup.py next to make button-mapping easier...
Implementation is the easy part here, the thing i'm worried about is UX. Because for the controllers that use "note_on" and "note_off" you get a "double" even which could confuse users.
Well, that's what's working for me, and at least there's enough information here for others who need that functionality to implement it, and get running.
Might need to add a question like the "is this a fader or a button" for buttons that asks whether it's a momentary or toggle button, and if toggle, what to set the on and off to separately. Or ignore the off.
Two very similar edits got setup.py working with mapping note_off.
yea, the information is now here if someone needs it. I'll think about how to aproach that because it's the same for the value in control_change messages.
You might also consider having the config prompt ask someone to press and release a button. Then, have them do it again. That will either give you four events (If I'm understanding this issue correctly) 1) on 127 2) off 127 3) on 0 4) off 0, or it will give you potentially enough data from which to autodetect what kind of button/toggle something is.
That's a little more "automagical" of a solution; your choice of course on whether you want to be intuitive and sensing, or explicit, in your UX.
I changed
def handle_midi_input(self, message, deviceID, deviceName): self.log.debug("Received %s %s %s %s %s", str(message), "from device", deviceID, "/", deviceName) if message.type == "note_on": return self.handle_midi_button(deviceID, message.channel, message.type, message.note)
to
def handle_midi_input(self, message, deviceID, deviceName): self.log.debug("Received %s %s %s %s %s", str(message), "from device", deviceID, "/", deviceName) if message.type == "note_on" or message.type == "note_off": return self.handle_midi_button(deviceID, message.channel, message.type, message.note)
and then manually added a "note_off" entry in the config file to get this behavior.
That seemed to be the only change needed in main.py. I may look at setup.py next to make button-mapping easier...
I made the change you suggested but i couldn't figure about where to add the "note_off" in the config file.
"5": { "msg_type": "control_change", "msgNoC": 112, "input_type": "button", "action": "{\"request-type\": \"ToggleMute\", \"message-id\" : \"1\", \"source\": \"elgato\"}", "deviceID": 1, "bidirectional": false }
this is the code that was added for the toggleMute button i chose. but i don't see a "note_on" so it is not obvious for me how to duplicate the entry with a note off
Your controller seems to send control_change messages, not note_on or note_off. If you use the most recent setup.py from github there will also be a value named msgVoV that is the midi control change value. You would have to add a check to the main.py to check for that value, that's something i will do in the future. Or you can try to reprogramm your controller to send note_on and note_off, these would go into the "msg_type" field.
updated my setup.py with the one on github. {also, my coding skill is very basic but thought i would try to help 👯 }
i see now that my controller sends control_change and i can't change that in my controller. with that said i headed to main.py to try and figure where to start:
I figured that since handle_midi_input receives message.type: "control_change" the handle_midi_fader function is handling my input. I was thinking that by allowing the function to add "or value == 0" in the if statement, it will also fire the toggle but it didn't do the trick.
if input_type == "button": if (value == 127 or value == 0) and not self.send_action(result): continue
since my toggle sends either 0 or 127 i thought the problem is that nothing fires when it sends 0 but i guess i didnt understand that correctly :D
I will wait for that feature to be added since it seems I can't figure how to implement it myself :)
Try something in that direction instead. I've not tested in but in theory it should check if the msgVoV matches the current input value so it doesn't trigger the same action twice.
if input_type == "button": if value == result["msgVoV"] and not self.send_action(result): continue
worked.
changed to what lebaston100 suggested and set the button a setMute. then headed into the config file du[licated the entry and changed to mute on 127 and unmute on 0.