2023-06-23 17:44:51 +01:00
|
|
|
import time
|
|
|
|
from logging import config
|
|
|
|
|
|
|
|
import obsws_python as obsws
|
2022-09-29 10:01:18 +01:00
|
|
|
|
2022-07-02 02:23:22 +01:00
|
|
|
import voicemeeterlib
|
|
|
|
|
2023-06-23 17:44:51 +01:00
|
|
|
config.dictConfig(
|
|
|
|
{
|
|
|
|
"version": 1,
|
|
|
|
"formatters": {
|
|
|
|
"standard": {
|
|
|
|
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"handlers": {
|
|
|
|
"stream": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"formatter": "standard",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"voicemeeterlib.iremote": {"handlers": ["stream"], "level": "DEBUG"}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
2022-10-28 02:14:08 +01:00
|
|
|
|
|
|
|
|
2023-06-23 17:44:51 +01:00
|
|
|
class MyClient:
|
2022-10-28 02:14:08 +01:00
|
|
|
def __init__(self, vm):
|
|
|
|
self.vm = vm
|
2023-06-23 17:44:51 +01:00
|
|
|
self.client = obsws.EventClient()
|
|
|
|
self.client.callback.register(
|
|
|
|
(
|
|
|
|
self.on_current_program_scene_changed,
|
|
|
|
self.on_exit_started,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.is_running = True
|
2022-10-28 02:14:08 +01:00
|
|
|
|
|
|
|
def on_start(self):
|
|
|
|
self.vm.strip[0].mute = True
|
|
|
|
self.vm.strip[1].B1 = True
|
|
|
|
self.vm.strip[2].B2 = True
|
|
|
|
|
|
|
|
def on_brb(self):
|
|
|
|
self.vm.strip[7].fadeto(0, 500)
|
|
|
|
self.vm.bus[0].mute = True
|
|
|
|
|
|
|
|
def on_end(self):
|
|
|
|
self.vm.apply(
|
|
|
|
{
|
|
|
|
"strip-0": {"mute": True},
|
|
|
|
"strip-1": {"mute": True, "B1": False},
|
|
|
|
"strip-2": {"mute": True, "B1": False},
|
|
|
|
"vban-in-0": {"on": False},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
def on_live(self):
|
|
|
|
self.vm.strip[0].mute = False
|
|
|
|
self.vm.strip[7].fadeto(-6, 500)
|
|
|
|
self.vm.strip[7].A3 = True
|
|
|
|
self.vm.vban.instream[0].on = True
|
|
|
|
|
|
|
|
def on_current_program_scene_changed(self, data):
|
|
|
|
def fget(scene):
|
|
|
|
run = {
|
|
|
|
"START": self.on_start,
|
|
|
|
"BRB": self.on_brb,
|
|
|
|
"END": self.on_end,
|
|
|
|
"LIVE": self.on_live,
|
|
|
|
}
|
|
|
|
return run.get(scene)
|
|
|
|
|
|
|
|
scene = data.scene_name
|
|
|
|
print(f"Switched to scene {scene}")
|
|
|
|
if fn := fget(scene):
|
|
|
|
fn()
|
|
|
|
|
2023-06-23 17:44:51 +01:00
|
|
|
def on_exit_started(self, _):
|
|
|
|
self.client.unsubscribe()
|
|
|
|
self.is_running = False
|
|
|
|
|
2022-10-28 02:14:08 +01:00
|
|
|
|
|
|
|
def main():
|
2023-06-23 17:44:51 +01:00
|
|
|
KIND_ID = "potato"
|
|
|
|
|
|
|
|
with voicemeeterlib.api(KIND_ID) as vm:
|
|
|
|
client = MyClient(vm)
|
|
|
|
while client.is_running:
|
|
|
|
time.sleep(0.1)
|
2022-10-28 02:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|