-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
The callbacks need to be wrapped, otherwise they either don't get called at all or with the wrong arguments
This will add a "bidirectional" option for buttons that change the current or preview scene. When we see an update from OBS that the scene changed we try to inform the MIDI controls that are associated with that scene about it if it's bidirectional. In other words: If your scene changing button has an LED it will turn on/off. I tested this with a KORG nanoKONTROL2 where it works beautifully.
It seems I had forgotten to add most of my changes. :-/
Looks fine to me. |
Thank you. I don't think you can send to an input port, that's why I changed it to an io port. |
Oh right, i apparently missed that while reading though it. |
Hi, Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mido
>>> mido.get_ioport_names()
[]
>>> mido.get_input_names()
['X-TOUCH MINI 0']
>>> mido.get_output_names()
['Microsoft GS Wavetable Synth 0', 'X-TOUCH MINI 1']
>>>
|
Thanks for testing that @me-vlad . |
Full output
|
I had a similar issue with opening an IO port regarding my x touch
compact. even though it should work bi-directionally.
Warmest Regards,
<edit: removed "private information">
…On Fri, Apr 10, 2020 at 11:38 AM Vlad V. Teteria ***@***.***> wrote:
Full output
C:\Users\Vlad\Desktop\MIDItoOBS-bidirectional>python main.py
[2020-04-10 13:20:45,935] (INFO) T8960 : Successfully parsed config file
--- Logging error ---
Traceback (most recent call last):
File "main.py", line 76, in __init__
self._port = mido.open_ioport(name=self._devicename, callback=self.callback, autoreset=True)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\backend.py", line 159, in open_ioport
self.module.Output(output_name, **kwargs))
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\ports.py", line 265, in __init__
BasePort.__init__(self, name, **kwargs)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\ports.py", line 86, in __init__
self._open(**kwargs)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\rtmidi.py", line 190, in _open
virtual=virtual, api=self.api)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\rtmidi.py", line 93, in _open_port
raise IOError('unknown port {!r}'.format(name))
OSError: unknown port 'X-TOUCH MINI 0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 1025, in emit
msg = self.format(record)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 869, in format
return fmt.format(record)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 608, in format
record.message = record.getMessage()
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 369, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "main.py", line 388, in <module>
handler = MidiHandler()
File "main.py", line 139, in __init__
self._portobjects.append((DeviceHandler(device, device.doc_id), device.doc_id))
File "main.py", line 78, in __init__
self.log.critical("\nCould not open", self._devicename)
Message: '\nCould not open'
Arguments: ('X-TOUCH MINI 0',)
--- Logging error ---
Traceback (most recent call last):
File "main.py", line 76, in __init__
self._port = mido.open_ioport(name=self._devicename, callback=self.callback, autoreset=True)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\backend.py", line 159, in open_ioport
self.module.Output(output_name, **kwargs))
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\ports.py", line 265, in __init__
BasePort.__init__(self, name, **kwargs)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\ports.py", line 86, in __init__
self._open(**kwargs)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\rtmidi.py", line 190, in _open
virtual=virtual, api=self.api)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\site-packages\mido\backends\rtmidi.py", line 93, in _open_port
raise IOError('unknown port {!r}'.format(name))
OSError: unknown port 'X-TOUCH MINI 0'
Traceback (most recent call last):
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 1025, in emit
msg = self.format(record)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 869, in format
return fmt.format(record)
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 608, in format
record.message = record.getMessage()
File "C:\Users\Vlad\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 369, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "main.py", line 388, in <module>
handler = MidiHandler()
File "main.py", line 139, in __init__
self._portobjects.append((DeviceHandler(device, device.doc_id), device.doc_id))
File "main.py", line 78, in __init__
self.log.critical("\nCould not open", self._devicename)
Message: '\nCould not open'
Arguments: ('X-TOUCH MINI 0',)
[2020-04-10 13:20:45,976] (CRITICAL) T8960 : The midi device might be used by another application/not plugged in/have a different name.
[2020-04-10 13:20:45,977] (CRITICAL) T8960 : Please close the device in the other application/plug it in/select the rename option in the device management menu and restart this script.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANSE6WGY32WVSAUAQMIFSTRL44P3ANCNFSM4MEZ3X2Q>
.
|
Well, that should now be fixed with ae6de7f |
Thanks for your feedback. I added a check if the device is capable to do IO. Of course, that will still fail if the device lies and isn't actually supporting it. I am not sure if that is the case with the X-Touch Mini. Edit: Actually, I just noticed that there are 2 X-Touch Mini reported, one for input and one for output. I assume that's the same physical device though? |
Yes it is the same device listed in input and output devices but not in ioport list |
This should call self.close() exactly once, no matter if the program was terminated with ctrl-c or because OBS died. I am not 100% sure about this one.
If the same midi device can be used for input and output, or if it's an ioport, then the "bidirectional" key in the config should be enough, if you have a separate device for output, then add it as a 2nd device and add "out_deviceID": <deviceID> to the config. It's not done in setup.py for you.
I tried to fix the case that different logical midi devices are needed for input and output. You have to add the 2nd device in your config, and add a key |
Hi Tobias, thanks for your help. My mido device names
My test config (two buttons for "preview" and two another - for "program") {
"_default": {},
"keys": {
"1": {
"msg_type": "note_on",
"msgNoC": 16,
"input_type": "button",
"action": "{\"request-type\": \"SetPreviewScene\", \"message-id\" : \"1\",\"scene-name\" : \"CAMERA1 - 1\"}",
"deviceID": 1,
"out_deviceID": 2,
"bidirectional": true
},
"2": {
"msg_type": "note_on",
"msgNoC": 17,
"input_type": "button",
"action": "{\"request-type\": \"SetPreviewScene\", \"message-id\" : \"1\",\"scene-name\" : \"CAMERA2 - 2\"}",
"deviceID": 1,
"out_deviceID": 2,
"bidirectional": true
},
"3": {
"msg_type": "note_on",
"msgNoC": 8,
"input_type": "button",
"action": "{\"request-type\": \"SetCurrentScene\", \"message-id\" : \"1\", \"scene-name\" : \"CAMERA1 - 1\"}",
"deviceID": 1,
"out_deviceID": 2,
"bidirectional": true
},
"4": {
"msg_type": "note_on",
"msgNoC": 9,
"input_type": "button",
"action": "{\"request-type\": \"SetCurrentScene\", \"message-id\" : \"1\", \"scene-name\" : \"CAMERA2 - 2\"}",
"deviceID": 1,
"out_deviceID": 2,
"bidirectional": true
}
},
"devices": {
"1": {
"devicename": "X-TOUCH MINI 0"
},
"2": {
"devicename": "X-TOUCH MINI 1"
}
}
} |
Does the following code turn on a light?
Edit: https://stackoverflow.com/questions/39435550/changing-leds-on-x-touch-mini-mackie-control-mc-mode sounds as if it's not as simple with that device |
Xtouch Mini has 2 modes - standart midi (in this mode device works with miditoobs) and mackie control mode (MC). Buttons led in standart mode on my device turns on with
|
... or probably devices that are sending NOTE_ON in general.
Next round of testing. :-) |
Thanks @houz , |
Some MIDI devices like the X-Touch Mini have different notes for sending and receiving. In those cases you can specify the output note with out_msgNoC in your config.json.
Thank you again for your feedback. I added |
@houz, now it works after adding out_msgNoC to buttons config. |
Yes, that is on purpose as it makes the code easier – we have to react to scene change events from OBS anyway. Of course it wouldn't be hard to set it immediately when sending the command to OBS. The subsequent message received would just set it again. |
I would leave it like this by design. What might be confusing at first is actually kind of handy and how i would expect it to work. |
Reacting to |
So for traditional hardware video mixer that can display red and green the concept if simple: if a source is visible it's red. So when there is a transition the green instantly changes to red (so both buttons are red at that moment). And when the transition is done the now-preview scene changes to green. |
I don't really care, making both buttons light up while the transition happens would be easy. Tell me what you prefer as a user experience and I will implement it. I don't think simplicity of code should be the determining factor here. 😃 |
Little side question. Would it make sense to wrap the ports in a multiport.
That way you can get around the separate input and output ports for the
behringer devices?
…On Sun, Apr 12, 2020, 12:40 Tobias Ellinghaus ***@***.***> wrote:
I don't really care, making both buttons light up while the transition
happens would be easy. Tell me what you prefer as a user experience and I
will implement it. I don't think simplicity of code should be the
determining factor here. 😃
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANSE6QT3IF7GBHOQLSCAMLRMHVJTANCNFSM4MEZ3X2Q>
.
|
For now i'm perfectly fine with it. From a UX side i don't really know which is right but i could imagine some confusion with the technical correct version. But on the other hand the entire script is tui-based so what do i know about UX :D |
Good idea, having a description of a concrete device would even allow to write a gui that shows an image of the hardware with overlays in setup. Just thinking out loud here. |
Yea exactly that's what i was thinking too. Having a online docs page for every device with a svg of the device with numbers that links to the right entry in the configuration file. |
IMHO something like "device database" with tipical mapping for different hw models + ability to edit config file manually (for advanced users) - a good solution. |
I don't think those advanced features are in the scope of this PR. So, is there anything else I should do to get this merged? |
No, nothing from your end. I wasn't expecting you to add all that stuff. Now it's my turn. Thanks again. |
Hello,
this PR adds support for reacting to OBS messages and sending MIDI messages. Currently it only reacts to changes of the scene (current and preview), but adding other feedback should be easy.
I also fixed some bugs in the registration of WebSocketApp callbacks.
I tested this with a KORG nanoKONTROL2.
Related to issue #16 .