Compare commits

..

No commits in common. "be71c498065fdc353ed4792be359c7beaf08a6fe" and "4fda9ddb4d38a61f91d4cec7a08de7412ca3f5cc" have entirely different histories.

6 changed files with 19 additions and 43 deletions

View File

@ -15,9 +15,6 @@ logger = logging.getLogger(__name__)
class Audio(ILayer):
"""Audio concrete class"""
DCM8_MAX_GAIN = 20 # SE Electronics DCM8 max gain
TLM102_MAX_GAIN = 30 # Neumann TLM102 max gain
def __init__(self, duckypad, **kwargs):
super().__init__(duckypad)
for attr, val in kwargs.items():
@ -134,7 +131,7 @@ class Audio(ILayer):
def stage_onyx_mic(self):
"""Gain stage SE Electronics DCM8 with phantom power"""
self.mixer.headamp[XAirStrips.onyx_mic].phantom = True
for i in range(Audio.DCM8_MAX_GAIN + 1):
for i in range(21):
self.mixer.headamp[XAirStrips.onyx_mic].gain = i
time.sleep(0.1)
self.logger.info('Onyx Mic Staged with Phantom Power')
@ -143,14 +140,14 @@ class Audio(ILayer):
def stage_iris_mic(self):
"""Gain stage TLM102 with phantom power"""
self.mixer.headamp[XAirStrips.iris_mic].phantom = True
for i in range(Audio.TLM102_MAX_GAIN + 1):
for i in range(31):
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(Audio.DCM8_MAX_GAIN + 1)):
for i in reversed(range(21)):
self.mixer.headamp[XAirStrips.onyx_mic].gain = i
time.sleep(0.1)
self.mixer.headamp[XAirStrips.onyx_mic].phantom = False
@ -158,7 +155,7 @@ class Audio(ILayer):
def unstage_iris_mic(self):
"""Unstage TLM102 and disable phantom power"""
for i in reversed(range(Audio.TLM102_MAX_GAIN + 1)):
for i in reversed(range(31)):
self.mixer.headamp[XAirStrips.iris_mic].gain = i
time.sleep(0.1)
self.mixer.headamp[XAirStrips.iris_mic].phantom = False
@ -182,15 +179,6 @@ class Audio(ILayer):
self.vm.patch.asio[2].set(0)
self.logger.info('Iris mic has been unpatched')
def mute_game_pcs(self):
self.state.mute_game_pcs = not self.state.mute_game_pcs
if self.state.mute_game_pcs:
self.mixer.strip[XAirStrips.game_pcs].send[XAirBuses.stream_mix].level = -90
self.logger.info('Game PCs Muted')
else:
self.mixer.strip[XAirStrips.game_pcs].send[XAirBuses.stream_mix].level = -24
self.logger.info('Game PCs Unmuted')
### Workstation and TV Audio Routing via VBAN ###
def _fade_mixer(self, target_fader, fade_in=True):
@ -249,7 +237,7 @@ class Audio(ILayer):
vban_tv.strip[3].A1 = False
vban_tv.strip[3].gain = -6
vban_tv.vban.outstream[0].on = True
vban_target.vban.instream[3].on = True
vban_target.vban.instream[2].on = True
self.logger.info(f'TV audio routed to {target_name}')
else:
with (
@ -259,7 +247,7 @@ class Audio(ILayer):
vban_tv.strip[3].A1 = True
vban_tv.strip[3].gain = 0
vban_tv.vban.outstream[0].on = False
vban_target.vban.instream[3].on = False
vban_target.vban.instream[2].on = False
self.logger.info(f'TV audio routing to {target_name} disabled')
def toggle_tv_audio_to_onyx(self):

View File

@ -24,11 +24,10 @@ def register_hotkeys(duckypad):
keyboard.add_hotkey('shift+F18', duckypad.audio.unstage_iris_mic)
keyboard.add_hotkey('F19', duckypad.audio.patch_onyx)
keyboard.add_hotkey('F20', duckypad.audio.patch_iris)
keyboard.add_hotkey('F21', duckypad.audio.mute_game_pcs)
keyboard.add_hotkey('alt+F13', duckypad.audio.toggle_workstation_to_onyx)
keyboard.add_hotkey('alt+F14', duckypad.audio.toggle_workstation_to_iris)
keyboard.add_hotkey('alt+F15', duckypad.audio.toggle_tv_audio_to_onyx)
keyboard.add_hotkey('alt+F16', duckypad.audio.toggle_tv_audio_to_iris)
keyboard.add_hotkey('F21', duckypad.audio.toggle_workstation_to_onyx)
keyboard.add_hotkey('F22', duckypad.audio.toggle_workstation_to_iris)
keyboard.add_hotkey('F23', duckypad.audio.toggle_tv_audio_to_onyx)
keyboard.add_hotkey('F24', duckypad.audio.toggle_tv_audio_to_iris)
def scene_hotkeys():
keyboard.add_hotkey('ctrl+F13', duckypad.scene.start)
@ -39,8 +38,8 @@ def register_hotkeys(duckypad):
keyboard.add_hotkey('ctrl+F18', duckypad.scene.iris_solo)
def obsws_hotkeys():
keyboard.add_hotkey('ctrl+F22', duckypad.obsws.start_stream)
keyboard.add_hotkey('ctrl+F23', duckypad.obsws.stop_stream)
keyboard.add_hotkey('ctrl+alt+F13', duckypad.obsws.start_stream)
keyboard.add_hotkey('ctrl+alt+F14', duckypad.obsws.stop_stream)
def duckypad_hotkeys():
keyboard.add_hotkey('ctrl+F24', duckypad.reset)

View File

@ -54,12 +54,12 @@ class OBSWS(ILayer):
for client in (self.request, self.event):
if client:
client.disconnect()
self.request = self.event = None
### Event Handlers ###
def on_stream_state_changed(self, data):
self._duckypad.stream.is_live = data.output_active
self.logger.info(f'stream is {"live" if self._duckypad.stream.is_live else "offline"}')
def on_current_program_scene_changed(self, data):
self._duckypad.stream.current_scene = data.scene_name
@ -77,10 +77,8 @@ class OBSWS(ILayer):
case 'IRIS SOLO':
self.logger.info('Iris Solo Scene enabled, Onyx game pc muted')
def on_exit_started(self, data):
self.logger.info('OBS is exiting, disconnecting...')
self.request.disconnect()
self.request = self.event = None
def on_exit_started(self, _):
self.event.unsubscribe()
### OBSWS Request Wrappers ###
@ -100,7 +98,6 @@ class OBSWS(ILayer):
return
self._call('start_stream')
self.logger.info('stream started')
def stop_stream(self):
resp = self._call('get_stream_status')
@ -109,4 +106,3 @@ class OBSWS(ILayer):
return
self._call('stop_stream')
self.logger.info('stream stopped')

View File

@ -15,7 +15,6 @@ class AudioState:
sound_test: bool = False
patch_onyx: bool = True
patch_iris: bool = True
mute_game_pcs: bool = False
ws_to_onyx: bool = False
ws_to_iris: bool = False

View File

@ -1,7 +1,5 @@
def ensure_obsws(func):
"""ensure an obs websocket connection has been established
Used as a decorator for functions that require an obs websocket connection"""
"""ensure an obs websocket connection has been established"""
def wrapper(self, *args):
if self.request is None:
@ -13,11 +11,8 @@ def ensure_obsws(func):
return wrapper
def ensure_mixer_fadeout(func):
"""ensure mixer is faded out before proceeding (disable monitor speaker)
Used as a decorator for functions that require the mixer to be faded out"""
"""ensure mixer fadeout is stopped before proceeding"""
def wrapper(self, *args):
if self.mixer.lr.mix.fader > -90:
@ -26,7 +21,6 @@ def ensure_mixer_fadeout(func):
return wrapper
def to_snakecase(scene_name: str) -> str:
"""Convert caplitalized words to lowercase snake_case"""
return '_'.join(word.lower() for word in scene_name.split())

View File

@ -23,9 +23,9 @@ classifiers = [
dynamic = ["version"]
dependencies = [
"keyboard",
"obsws-python>=1.8.0",
"obsws-python>=1.7",
"vban-cmd>=2.5.2",
"voicemeeter-api>=2.7.1",
"voicemeeter-api>=2.6.1",
"xair-api>=2.4.1",
]