From 971922272e9d9c276444da52dfb45dfdea6a37ab Mon Sep 17 00:00:00 2001 From: Simon G Date: Mon, 26 Apr 2021 13:18:46 +0200 Subject: [PATCH] - initialize fader for newly found process --- Lib.Audio/Channel.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib.Audio/Channel.cs b/Lib.Audio/Channel.cs index b6651c0..8f12fe1 100644 --- a/Lib.Audio/Channel.cs +++ b/Lib.Audio/Channel.cs @@ -72,7 +72,7 @@ namespace Lib.Audio ToggleSelectButtonLed(); if (Controllable.IsValid) - InitializeFader(controllable); + InitializeFader(); } private void UnMapControllable() @@ -124,12 +124,12 @@ namespace Lib.Audio _acknowledgeMessage = null; } - private void InitializeFader(IControllable controllable) + private void InitializeFader() { - if (Fader == null) + if (Fader == null || Controllable == null) return; - float volume = controllable.GetVolume(); + float volume = Controllable.GetVolume(); Fader.RelativePosition = volume; _midiCommunication.Send(new PitchWheelChangeMessage(0, _channelNumber, Fader.Position)); @@ -161,6 +161,8 @@ namespace Lib.Audio return; Controllable = _controllableCollector.GetControllableForExecutable(Controllable.ExecutablePath); + if (Controllable != null) + InitializeFader(); } private void OnProcessManagerProcessExited(object? sender, IObservedProcess process)