diff --git a/duckypad_twitch/audio.py b/duckypad_twitch/audio.py index 99257b0..7e7fb72 100644 --- a/duckypad_twitch/audio.py +++ b/duckypad_twitch/audio.py @@ -4,7 +4,7 @@ import time import vban_cmd from . import configuration -from .enums import Buttons, Strips +from .enums import Buttons, VBANChannels, VMBuses, VMStrips, XAirBuses, XAirStrips from .layer import ILayer from .states import AudioState from .util import ensure_mixer_fadeout @@ -42,44 +42,42 @@ class Audio(ILayer): def mute_mics(self): self.state.mute_mics = not self.state.mute_mics if self.state.mute_mics: - self.vm.strip[0].mute = True - self.vm.strip[1].mute = True - self.vm.strip[4].mute = True + self.vm.strip[VMStrips.onyx_mic].mute = True + self.vm.strip[VMStrips.iris_mic].mute = True self.logger.info('Mics Muted') else: - self.vm.strip[0].mute = False - self.vm.strip[1].mute = False - self.vm.strip[4].mute = False + self.vm.strip[VMStrips.onyx_mic].mute = False + self.vm.strip[VMStrips.iris_mic].mute = False self.logger.info('Mics Unmuted') self.vm.button[Buttons.mute_mics].stateonly = self.state.mute_mics def only_discord(self): self.state.only_discord = not self.state.only_discord if self.state.only_discord: - self.mixer.dca[0].on = False - self.vm.strip[4].mute = True + self.vm.bus[VMBuses.both_mics].mute = True + self.mixer.strip[XAirStrips.comms].send[XAirBuses.stream_mix].level = -90 self.logger.info('Only Discord Enabled') else: - self.vm.strip[4].mute = False - self.mixer.dca[0].on = True + self.mixer.strip[XAirStrips.comms].send[XAirBuses.stream_mix].level = -24 + self.vm.bus[VMBuses.both_mics].mute = False self.logger.info('Only Discord Disabled') self.vm.button[Buttons.only_discord].stateonly = self.state.only_discord def only_stream(self): self.state.only_stream = not self.state.only_stream if self.state.only_stream: - self.vm.bus[5].mute = True - self.vm.bus[6].mute = True - self.vm.strip[2].gain = -3 - self.vm.strip[3].gain = -3 - self.vm.strip[6].gain = -3 + self.vm.bus[VMBuses.onyx_mic].mute = True + self.vm.bus[VMBuses.iris_mic].mute = True + self.vm.strip[VMStrips.onyx_pc].gain = -3 + self.vm.strip[VMStrips.iris_pc].gain = -3 + self.vm.strip[VMStrips.pretzel].gain = -3 self.logger.info('Only Stream Enabled') else: - self.vm.strip[2].gain = 0 - self.vm.strip[3].gain = 0 - self.vm.strip[6].gain = 0 - self.vm.bus[5].mute = False - self.vm.bus[6].mute = False + self.vm.strip[VMStrips.onyx_pc].gain = 0 + self.vm.strip[VMStrips.iris_pc].gain = 0 + self.vm.strip[VMStrips.pretzel].gain = 0 + self.vm.bus[VMBuses.onyx_mic].mute = False + self.vm.bus[VMBuses.iris_mic].mute = False self.logger.info('Only Stream Disabled') self.vm.button[Buttons.only_stream].stateonly = self.state.only_stream @@ -113,54 +111,54 @@ class Audio(ILayer): self.state.sound_test = not self.state.sound_test if self.state.sound_test: - self.vm.strip[Strips.onyx_mic].apply({'A1': True, 'B1': False, 'B3': False, 'mute': False}) - self.vm.strip[Strips.iris_mic].apply({'A1': True, 'B2': False, 'B3': False, 'mute': False}) - self.vm.vban.outstream[0].on = True - self.vm.vban.outstream[1].on = True - self.vm.vban.outstream[0].route = 0 - self.vm.vban.outstream[1].route = 0 + self.vm.strip[VMStrips.onyx_mic].apply({'A1': True, 'B1': False, 'B3': False, 'mute': False}) + self.vm.strip[VMStrips.iris_mic].apply({'A1': True, 'B2': False, 'B3': False, 'mute': False}) + self.vm.vban.outstream[VBANChannels.onyx_mic].on = True + self.vm.vban.outstream[VBANChannels.iris_mic].on = True + self.vm.vban.outstream[VBANChannels.onyx_mic].route = 0 + self.vm.vban.outstream[VBANChannels.iris_mic].route = 0 toggle_soundtest(ENABLE_SOUNDTEST) self.logger.info('Sound Test Enabled') else: toggle_soundtest(DISABLE_SOUNDTEST) - self.vm.vban.outstream[0].route = 5 - self.vm.vban.outstream[1].route = 6 - self.vm.strip[Strips.onyx_mic].apply({'A1': False, 'B1': True, 'B3': True, 'mute': True}) - self.vm.strip[Strips.iris_mic].apply({'A1': False, 'B2': True, 'B3': True, 'mute': True}) + self.vm.vban.outstream[VBANChannels.onyx_mic].route = 5 + self.vm.vban.outstream[VBANChannels.iris_mic].route = 6 + self.vm.strip[VMStrips.onyx_mic].apply({'A1': False, 'B1': True, 'B3': True, 'mute': True}) + self.vm.strip[VMStrips.iris_mic].apply({'A1': False, 'B2': True, 'B3': True, 'mute': True}) self.logger.info('Sound Test Disabled') @ensure_mixer_fadeout def stage_onyx_mic(self): """Gain stage SE Electronics DCM8 with phantom power""" - self.mixer.headamp[10].phantom = True + self.mixer.headamp[XAirStrips.onyx_mic].phantom = True for i in range(21): - self.mixer.headamp[10].gain = i + self.mixer.headamp[XAirStrips.onyx_mic].gain = i time.sleep(0.1) self.logger.info('Onyx Mic Staged with Phantom Power') @ensure_mixer_fadeout def stage_iris_mic(self): """Gain stage TLM102 with phantom power""" - self.mixer.headamp[11].phantom = True + self.mixer.headamp[XAirStrips.iris_mic].phantom = True for i in range(31): - self.mixer.headamp[11].gain = i + self.mixer.headamp[XAirStrips.iris_mic].gain = i time.sleep(0.1) self.logger.info('Iris Mic Staged with Phantom Power') def unstage_onyx_mic(self): """Unstage SE Electronics DCM8 and disable phantom power""" for i in reversed(range(21)): - self.mixer.headamp[10].gain = i + self.mixer.headamp[XAirStrips.onyx_mic].gain = i time.sleep(0.1) - self.mixer.headamp[10].phantom = False + self.mixer.headamp[XAirStrips.onyx_mic].phantom = False self.logger.info('Onyx Mic Unstaged and Phantom Power Disabled') def unstage_iris_mic(self): """Unstage TLM102 and disable phantom power""" for i in reversed(range(31)): - self.mixer.headamp[11].gain = i + self.mixer.headamp[XAirStrips.iris_mic].gain = i time.sleep(0.1) - self.mixer.headamp[11].phantom = False + self.mixer.headamp[XAirStrips.iris_mic].phantom = False self.logger.info('Iris Mic Unstaged and Phantom Power Disabled') def solo_onyx(self): @@ -169,6 +167,8 @@ class Audio(ILayer): def solo_iris(self): """placeholder method""" + ### Workstation and TV Audio Routing via VBAN ### + def _fade_mixer(self, target_fader, fade_in=True): """Fade the mixer's fader to the target level.""" current_fader = self.mixer.lr.mix.fader diff --git a/duckypad_twitch/enums.py b/duckypad_twitch/enums.py index 2ea95f3..d3ab8f5 100644 --- a/duckypad_twitch/enums.py +++ b/duckypad_twitch/enums.py @@ -2,5 +2,25 @@ from enum import IntEnum Buttons = IntEnum('Buttons', 'mute_mics only_discord only_stream', start=0) -Strips = IntEnum('Strips', 'onyx_mic iris_mic onyx_pc iris_pc', start=0) -Buses = IntEnum('Buses', 'MR18 ASIO[1,2] ASIO[3,4] ASIO[5,6] ASIO[7,8] onyx_mic iris_mic both_mics', start=5) +# Voicemeeter Channels +VMStrips = IntEnum('Strips', 'onyx_mic iris_mic onyx_pc iris_pc st_input_5 system comms pretzel', start=0) +VMBuses = IntEnum('Buses', 'onyx_mic iris_mic both_mics', start=5) + +# VBAN Channels +VBANChannels = IntEnum('VBANChannels', 'onyx_mic iris_mic comms workstation', start=0) + + +# XAir Channels +class XAirStrips(IntEnum): + system = 0 + comms = 2 + pretzel = 4 + game_pcs = 6 + onyx_mic = 10 + iris_mic = 12 + + +class XAirBuses(IntEnum): + onyx_mix = 0 + iris_mix = 2 + stream_mix = 4 diff --git a/duckypad_twitch/scene.py b/duckypad_twitch/scene.py index c652a0c..caf44aa 100644 --- a/duckypad_twitch/scene.py +++ b/duckypad_twitch/scene.py @@ -1,6 +1,6 @@ import logging -from .enums import Strips +from .enums import VMStrips from .layer import ILayer from .states import SceneState @@ -33,8 +33,8 @@ class Scene(ILayer): self._state = SceneState() def start(self): - self.vm.strip[Strips.onyx_pc].mute = True - self.vm.strip[Strips.iris_pc].mute = True + self.vm.strip[VMStrips.onyx_pc].mute = True + self.vm.strip[VMStrips.iris_pc].mute = True self.obsws.switch_to_scene('START') def dual_stream(self): @@ -43,26 +43,26 @@ class Scene(ILayer): 'A5': True, 'gain': 0, } - self.vm.strip[Strips.onyx_pc].apply(ENABLE_PC) - self.vm.strip[Strips.iris_pc].apply(ENABLE_PC) + self.vm.strip[VMStrips.onyx_pc].apply(ENABLE_PC) + self.vm.strip[VMStrips.iris_pc].apply(ENABLE_PC) self.obsws.switch_to_scene('DUAL STREAM') def brb(self): - self.vm.strip[Strips.onyx_pc].mute = True - self.vm.strip[Strips.iris_pc].mute = True + self.vm.strip[VMStrips.onyx_pc].mute = True + self.vm.strip[VMStrips.iris_pc].mute = True self.obsws.switch_to_scene('BRB') def end(self): - self.vm.strip[Strips.onyx_pc].mute = True - self.vm.strip[Strips.iris_pc].mute = True + self.vm.strip[VMStrips.onyx_pc].mute = True + self.vm.strip[VMStrips.iris_pc].mute = True self.obsws.switch_to_scene('END') def onyx_solo(self): - self.vm.strip[Strips.onyx_pc].mute = False - self.vm.strip[Strips.iris_pc].mute = True + self.vm.strip[VMStrips.onyx_pc].mute = False + self.vm.strip[VMStrips.iris_pc].mute = True self.obsws.switch_to_scene('ONYX SOLO') def iris_solo(self): - self.vm.strip[Strips.onyx_pc].mute = True - self.vm.strip[Strips.iris_pc].mute = False + self.vm.strip[VMStrips.onyx_pc].mute = True + self.vm.strip[VMStrips.iris_pc].mute = False self.obsws.switch_to_scene('IRIS SOLO')