From 6dbdd0587d22431cef4992ddea9c76d4a81ae6bf Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Wed, 15 Jun 2022 08:49:52 -0400 Subject: [PATCH] Reworks audio routing on DMPS-4K units. --- .../Chassis/DmpsDigitalOutputController.cs | 171 +++++++++ .../Chassis/DmpsMicrophoneController.cs | 3 + .../Chassis/DmpsRoutingController.cs | 344 ++++++++++++++---- .../PepperDash_Essentials_DM.csproj | 1 + 4 files changed, 447 insertions(+), 72 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs new file mode 100644 index 00000000..49b5c1c5 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsDigitalOutputController.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.DM +{ + /// + /// + /// + public class DmpsDigitalOutputController : Device, IRoutingNumericWithFeedback, IHasFeedback + { + public Card.Dmps3OutputBase OutputCard { get; protected set; } + + public RoutingInputPort None { get; protected set; } + public RoutingInputPort DigitalMix1 { get; protected set; } + public RoutingInputPort DigitalMix2 { get; protected set; } + public RoutingInputPort AudioFollowsVideo { get; protected set; } + + public RoutingOutputPort DigitalAudioOut { get; protected set; } + + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + + /// + /// Returns a list containing the Outputs that we want to expose. + /// + public FeedbackCollection Feedbacks { get; private set; } + + public virtual RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + None, + DigitalMix1, + DigitalMix2, + AudioFollowsVideo + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DigitalAudioOut }; + } + } + + public DmpsDigitalOutputController(string key, string name, Card.Dmps3OutputBase outputCard) + : base(key, name) + { + Feedbacks = new FeedbackCollection(); + OutputCard = outputCard; + + if (outputCard is Card.Dmps3DmOutputBackend) + { + AudioSourceNumericFeedback = new IntFeedback(() => + { + return (int)(outputCard as Card.Dmps3DmOutputBackend).AudioOutSourceDeviceFeedback; + }); + DigitalAudioOut = new RoutingOutputPort(DmPortName.DmOut + OutputCard.Number, eRoutingSignalType.Audio, eRoutingPortConnectionType.DmCat, null, this); + } + + else if (outputCard is Card.Dmps3HdmiOutputBackend) + { + AudioSourceNumericFeedback = new IntFeedback(() => + { + return (int)(outputCard as Card.Dmps3HdmiOutputBackend).AudioOutSourceDeviceFeedback; + }); + DigitalAudioOut = new RoutingOutputPort(DmPortName.HdmiOut + OutputCard.Number, eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null, this); + } + else + { + return; + } + + None = new RoutingInputPort("None", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, + eDmps34KAudioOutSourceDevice.NoRoute, this); + DigitalMix1 = new RoutingInputPort("DigitalMix1", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, + eDmps34KAudioOutSourceDevice.DigitalMixer1, this); + DigitalMix2 = new RoutingInputPort("DigitalMix2", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, + eDmps34KAudioOutSourceDevice.DigitalMixer2, this); + AudioFollowsVideo = new RoutingInputPort("AudioFollowsVideo", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, + eDmps34KAudioOutSourceDevice.AudioFollowsVideo, this); + + AddToFeedbackList(AudioSourceNumericFeedback); + } + + /// + /// Adds feedback(s) to the list + /// + /// + public void AddToFeedbackList(params Feedback[] newFbs) + { + foreach (var f in newFbs) + { + if (f != null) + { + if (!Feedbacks.Contains(f)) + { + Feedbacks.Add(f); + } + } + } + } + + public virtual void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(None.Selector, null, type); + break; + } + case 1: + { + ExecuteSwitch(DigitalMix1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(DigitalMix2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(AudioFollowsVideo.Selector, null, type); + break; + } + } + + } + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + if (OutputCard is Card.Dmps3DmOutputBackend) + { + (OutputCard as Card.Dmps3DmOutputBackend).AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice)inputSelector; + } + else if (OutputCard is Card.Dmps3HdmiOutputBackend) + { + (OutputCard as Card.Dmps3HdmiOutputBackend).AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice)inputSelector; + } + } + } + + #endregion + + #region IRoutingFeedback Members + + public event EventHandler NumericSwitchChange; + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs index 30b2cfab..29dc0693 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsMicrophoneController.cs @@ -38,6 +38,9 @@ namespace PepperDash.Essentials.DM void Dmps_MicrophoneChange(MicrophoneBase mic, GenericEventArgs args) { + if (args.EventId == MicrophoneEventIds.VuFeedBackEventId) + return; + Debug.Console(2, "Dmps Microphone Controller Index: {0} EventId: {1}", mic.ID, args.EventId.ToString()); if(Mics.ContainsKey(mic.ID)) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 38a0aed9..55c49a96 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -59,6 +59,7 @@ namespace PepperDash.Essentials.DM public Dictionary InputNames { get; set; } public Dictionary OutputNames { get; set; } public Dictionary VolumeControls { get; private set; } + public Dictionary DigitalAudioOutputs { get; private set; } public DmpsMicrophoneController Microphones { get; private set; } public const int RouteOffTime = 500; @@ -155,6 +156,7 @@ namespace PepperDash.Essentials.DM InputPorts = new RoutingPortCollection(); OutputPorts = new RoutingPortCollection(); VolumeControls = new Dictionary(); + DigitalAudioOutputs = new Dictionary(); TxDictionary = new Dictionary(); RxDictionary = new Dictionary(); @@ -246,13 +248,15 @@ namespace PepperDash.Essentials.DM { return; } - foreach (var kvp in OutputNames) { var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); - if (output != null && output.Name.Type != eSigType.NA) + if (output != null) { - output.Name.StringValue = kvp.Value; + if (output.Name.Supported && kvp.Value.Length > 0) + { + output.Name.StringValue = kvp.Value; + } } } } @@ -266,9 +270,12 @@ namespace PepperDash.Essentials.DM foreach (var kvp in InputNames) { var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); - if (input != null && input.Name.Type != eSigType.NA) + if (input != null) { - input.Name.StringValue = kvp.Value; + if (input.Name.Supported && kvp.Value.Length > 0) + { + input.Name.StringValue = kvp.Value; + } } } } @@ -376,9 +383,20 @@ namespace PepperDash.Essentials.DM } if (OutputNameFeedbacks[ioSlot] != null) { - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputVideoNames.JoinNumber + ioSlotJoin]); - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputAudioNames.JoinNumber + ioSlotJoin]); + if (Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3DmOutput || + Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3DmOutputBackend || + Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3HdmiOutput || + Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3HdmiOutputBackend) + { + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputVideoNames.JoinNumber + ioSlotJoin]); + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputAudioNames.JoinNumber + ioSlotJoin]); + } + else + { + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputAudioNames.JoinNumber + ioSlotJoin]); + } } if (OutputVideoRouteNameFeedbacks[ioSlot] != null) { @@ -402,11 +420,15 @@ namespace PepperDash.Essentials.DM { if (Global.ControlSystemIsDmps4kType) { - //DMPS-4K audio inputs 1-5 are aux inputs - for (uint i = 1; i <= 5; i++) + //DMPS-4K audio inputs 1-5 are aux inputs, add them after regular dm cards + for (ushort i = 1; i <= 5; i++) { - trilist.StringInput[joinMap.InputAudioNames.JoinNumber + i - 1].StringValue = String.Format("Aux Input {0}", i); + trilist.StringInput[joinMap.InputAudioNames.JoinNumber + i - 1 + (ushort)Dmps.SwitcherInputs.Count].StringValue = String.Format("Aux Input {0}", i); } + + //Add DMPS-4K mixer input names to end of inputs + trilist.StringInput[joinMap.InputAudioNames.JoinNumber + (uint)Dmps.SwitcherInputs.Count + 5].StringValue = "Digital Mixer 1"; + trilist.StringInput[joinMap.InputAudioNames.JoinNumber + (uint)Dmps.SwitcherInputs.Count + 6].StringValue = "Digital Mixer 2"; } for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++) { @@ -425,16 +447,7 @@ namespace PepperDash.Essentials.DM { InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputVideoNames.JoinNumber + ioSlotJoin]); - - if (Global.ControlSystemIsDmps4kType) - { - //DMPS-4K Audio Inputs are offset by 5 - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputAudioNames.JoinNumber + ioSlotJoin + 5]); - } - else - { - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputAudioNames.JoinNumber + ioSlotJoin]); - } + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputAudioNames.JoinNumber + ioSlotJoin]); } trilist.SetStringSigAction(joinMap.InputNames.JoinNumber + ioSlotJoin, s => @@ -496,7 +509,7 @@ namespace PepperDash.Essentials.DM }); AudioOutputFeedbacks[outputCard.Number] = new IntFeedback(() => { - try + if (!Global.ControlSystemIsDmps4kType) { if (outputCard.AudioOutFeedback != null) { @@ -504,15 +517,58 @@ namespace PepperDash.Essentials.DM } return 0; } - catch (NotSupportedException) + else { - return (ushort)outputCard.AudioOutSourceFeedback; + + if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) + { + //Special cases for DMPS-4K digital audio output + if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 0) + return 0; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 1) + return (ushort)Dmps.SwitcherInputs.Count + 6; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 2) + return (ushort)Dmps.SwitcherInputs.Count + 7; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 3) + return (ushort)outputCard.VideoOutFeedback.Number; + else + return 0; + } + else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.NoRoute) + { + //Fixes for weird audio indexing on DMPS3-4K + return 0; + } + else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.AirMedia8) + { + //Fixes for weird audio indexing on DMPS3-4K + return 8; + } + else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.AirMedia9) + { + //Fixes for weird audio indexing on DMPS3-4K + return 9; + } + else if ((ushort)outputCard.AudioOutSourceFeedback <= 5) + { + //Move analog inputs to after regular dm cards + return (ushort)outputCard.AudioOutSourceFeedback + (ushort)Dmps.SwitcherInputs.Count; + } + else + { + //Fixes for weird audio indexing on DMPS3-4K + return (ushort)outputCard.AudioOutSourceFeedback - 5; + } } }); OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.NameFeedback != null && outputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) + if(OutputNames.ContainsKey(outputCard.Number)) + { + return OutputNames[outputCard.Number]; + } + else if (outputCard.NameFeedback != null && outputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) { Debug.Console(2, this, "Output Card {0} Name: {1}", outputCard.Number, outputCard.NameFeedback.StringValue); return outputCard.NameFeedback.StringValue; @@ -530,9 +586,33 @@ namespace PepperDash.Essentials.DM }); OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.AudioOutFeedback != null && outputCard.AudioOutFeedback.NameFeedback != null) + if (!Global.ControlSystemIsDmps4kType) { - return outputCard.AudioOutFeedback.NameFeedback.StringValue; + if (outputCard.AudioOutFeedback != null && outputCard.AudioOutFeedback.NameFeedback != null) + { + return outputCard.AudioOutFeedback.NameFeedback.StringValue; + } + } + else + { + if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) + { + //Special cases for DMPS-4K digital audio output + if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 0) + return NoRouteText; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 1) + return "Digital Mix 1"; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 2) + return "Digital Mix 2"; + else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 3) + return outputCard.VideoOutFeedback.NameFeedback.StringValue; + else + return NoRouteText; + } + else + { + return outputCard.AudioOutSourceFeedback.ToString(); + } } return NoRouteText; }); @@ -570,13 +650,15 @@ namespace PepperDash.Essentials.DM InputNameFeedbacks[inputCard.Number] = new StringFeedback(() => { - if (inputCard.NameFeedback != null && inputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue)) + if (InputNames.ContainsKey(inputCard.Number)) + { + return InputNames[inputCard.Number]; + } + else if (inputCard.NameFeedback != null && inputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue)) { Debug.Console(2, this, "Input Card {0} Name: {1}", inputCard.Number, inputCard.NameFeedback.StringValue); return inputCard.NameFeedback.StringValue; } - - Debug.Console(2, this, "Input Card {0} Name is null", inputCard.Number); return ""; }); @@ -705,10 +787,11 @@ namespace PepperDash.Essentials.DM else if (outputCard is Card.Dmps3HdmiOutputBackend) { var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutputBackend; - var cecPort = hdmiOutputCard.HdmiOutputPort; - AddHdmiOutputPort(number, cecPort); + var audioOutput = new DmpsDigitalOutputController(string.Format("processor-avRouting-HdmiAudioOut{0}", number), string.Format("Hdmi Audio Output {0} Router", number), hdmiOutputCard); + DigitalAudioOutputs.Add(number, audioOutput); + DeviceManager.AddDevice(audioOutput); } else if (outputCard is Card.Dmps3DmOutput) { @@ -720,6 +803,9 @@ namespace PepperDash.Essentials.DM else if (outputCard is Card.Dmps3DmOutputBackend) { AddDmOutputPort(number); + var audioOutput = new DmpsDigitalOutputController(string.Format("processor-avRouting-DmAudioOut{0}", number), string.Format("Dm Audio Output {0} Router", number), outputCard as Card.Dmps3DmOutputBackend); + DigitalAudioOutputs.Add(number, audioOutput); + DeviceManager.AddDevice(audioOutput); } else if (outputCard is Card.Dmps3ProgramOutput) { @@ -737,7 +823,7 @@ namespace PepperDash.Essentials.DM { AddAudioOnlyOutputPort(number, "Aux1"); - var aux1Output = new DmpsAudioOutputController(string.Format("processor-aux1AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3Aux1Output); + var aux1Output = new DmpsAudioOutputController(string.Format("processor-aux1AudioOutput"), "Aux1 Audio Output", outputCard as Card.Dmps3Aux1Output); DeviceManager.AddDevice(aux1Output); } @@ -746,7 +832,7 @@ namespace PepperDash.Essentials.DM { AddAudioOnlyOutputPort(number, "Aux2"); - var aux2Output = new DmpsAudioOutputController(string.Format("processor-aux2AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3Aux2Output); + var aux2Output = new DmpsAudioOutputController(string.Format("processor-aux2AudioOutput"), "Aux2 Audio Output", outputCard as Card.Dmps3Aux2Output); DeviceManager.AddDevice(aux2Output); } @@ -788,7 +874,7 @@ namespace PepperDash.Essentials.DM || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix2) AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString()); - var audioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number % 2 + 1), string.Format("Digital Audio Output {0}", number % 2 + 1), outputCard as Card.Dmps3DigitalMixOutput); + var audioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number % 2 + 1), string.Format("Digital Audio Mix {0}", number % 2 + 1), outputCard as Card.Dmps3DigitalMixOutput); DeviceManager.AddDevice(audioOutput); } else @@ -902,14 +988,13 @@ namespace PepperDash.Essentials.DM } void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) { - Debug.Console(2, this, "DMOutputChange Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); - if (args.EventId == DMOutputEventIds.OutputVuFeedBackEventId) { //Frequently called event that isn't needed return; } + Debug.Console(2, this, "DMOutputChange Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); var output = args.Number; DMOutput outputCard = Dmps.SwitcherOutputs[output] as DMOutput; @@ -942,41 +1027,68 @@ namespace PepperDash.Essentials.DM { OutputVideoRouteNameFeedbacks[output].FireUpdate(); } + if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) + { + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) + { + OutputAudioRouteNameFeedbacks[output].FireUpdate(); + } + } } else if (args.EventId == DMOutputEventIds.AudioOutEventId) { - try + if (!Global.ControlSystemIsDmps4kType) { if (outputCard != null && outputCard.AudioOutFeedback != null) { Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, outputCard.AudioOutFeedback.Number, output); } - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - } } - catch (NotSupportedException) + else { if (outputCard != null) { - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, - outputCard.AudioOutSourceFeedback, output); - } - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); + if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) + { + DigitalAudioOutputs[output].AudioSourceNumericFeedback.FireUpdate(); + } + else + { + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, + outputCard.AudioOutSourceFeedback, output); + } } } + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) + { + OutputAudioRouteNameFeedbacks[output].FireUpdate(); + } } else if (args.EventId == DMOutputEventIds.OutputNameEventId && OutputNameFeedbacks.ContainsKey(output)) { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); OutputNameFeedbacks[output].FireUpdate(); } - + else if (args.EventId == DMOutputEventIds.DigitalMixerAudioSourceFeedBackEventId) + { + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) + { + OutputAudioRouteNameFeedbacks[output].FireUpdate(); + } + } } void Dmps_DMSystemChange(Switch device, DMSystemEventArgs args) @@ -1024,9 +1136,6 @@ namespace PepperDash.Essentials.DM Debug.Console(2, this, "Attempting a DM route from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); - //var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail - //var output = Convert.ToUInt32(outputSelector); - var input = inputSelector as DMInput; var output = outputSelector as DMOutput; @@ -1044,7 +1153,7 @@ namespace PepperDash.Essentials.DM if (input == null || (input.Number <= Dmps.NumberOfSwitcherInputs && output.Number <= Dmps.NumberOfSwitcherOutputs && sigTypeIsUsbOrVideo) || - (input.Number <= Dmps.NumberOfSwitcherInputs + 5 && output.Number <= Dmps.NumberOfSwitcherOutputs && + (input.Number <= (Dmps.NumberOfSwitcherInputs) && output.Number <= Dmps.NumberOfSwitcherOutputs && (sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) { // Check to see if there's an off timer waiting on this and if so, cancel @@ -1063,11 +1172,6 @@ namespace PepperDash.Essentials.DM } } - - //DMOutput dmOutputCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; - - //if (inCard != null) - //{ // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) { @@ -1076,19 +1180,34 @@ namespace PepperDash.Essentials.DM if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) { - try + if(!Global.ControlSystemIsDmps4kType) { output.AudioOut = input; } - catch (NotSupportedException) + else { - Debug.Console(1, this, "Routing input {0} audio to output {1}", - (eDmps34KAudioOutSource) (input == null ? 0 : input.Number), - (CrestronControlSystem.eDmps34K350COutputs) output.Number); - - output.AudioOutSource = input == null - ? eDmps34KAudioOutSource.NoRoute - : (eDmps34KAudioOutSource)input.Number; + if (input == null) + { + output.AudioOutSource = eDmps34KAudioOutSource.NoRoute; + } + else if (input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaInput || input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaNoStreamingInput) + { + //Special case for weird AirMedia indexing + if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl) + output.AudioOutSource = eDmps34KAudioOutSource.AirMedia8; + else if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) + output.AudioOutSource = eDmps34KAudioOutSource.AirMedia9; + } + else if (input.Number <= Dmps.SwitcherInputs.Count) + { + //Shift video inputs by 5 for weird DMPS3-4K indexing + output.AudioOutSource = (eDmps34KAudioOutSource)(input.Number + 5); + } + else + { + //Shift analog inputs back to inputs 1-5 + output.AudioOutSource = (eDmps34KAudioOutSource)(input.Number - Dmps.SwitcherInputs.Count); + } } } @@ -1122,10 +1241,91 @@ namespace PepperDash.Essentials.DM public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) { - var input = inputSelector == 0 ? null : Dmps.SwitcherInputs[inputSelector]; - var output = Dmps.SwitcherOutputs[outputSelector]; + if (EnableRouting == false) + { + return; + } - ExecuteSwitch(input, output, sigType); + Debug.Console(1, this, "Attempting a numeric switch from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); + + if((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) + { + if (inputSelector <= Dmps.SwitcherInputs.Count && outputSelector <= Dmps.SwitcherOutputs.Count) + { + var input = inputSelector == 0 ? null : Dmps.SwitcherInputs[inputSelector]; + var output = Dmps.SwitcherOutputs[outputSelector]; + + ExecuteSwitch(input, output, sigType); + } + } + else if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + //Special case for DMPS-4K digital audio output + if (Global.ControlSystemIsDmps4kType) + { + if (DigitalAudioOutputs.ContainsKey(outputSelector)) + { + if (inputSelector == 0) //Clear action + { + DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(0, 0, eRoutingSignalType.Audio); + } + else if (inputSelector <= Dmps.SwitcherInputs.Count) //DMPS-4K video inputs, set to audio follows video + { + DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(3, 0, eRoutingSignalType.Audio); + //Force video route since it is now set so audio follows video + ExecuteNumericSwitch(inputSelector, outputSelector, eRoutingSignalType.Video); + } + else if (inputSelector == Dmps.SwitcherInputs.Count + 6) + { + //Set to mix 1 + DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(1, 0, eRoutingSignalType.Audio); + } + else if (inputSelector == Dmps.SwitcherInputs.Count + 7) + { + //Set to mix 2 + DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(2, 0, eRoutingSignalType.Audio); + } + } + else if (inputSelector <= (Dmps.SwitcherInputs.Count + 5) && outputSelector <= Dmps.SwitcherOutputs.Count) + { + var output = Dmps.SwitcherOutputs[outputSelector] as DMOutput; + if (inputSelector == 0) + { + output.AudioOutSource = eDmps34KAudioOutSource.NoRoute; + } + else if(inputSelector > Dmps.SwitcherInputs.Count) + { + //Shift analog inputs back to inputs 1-5 + Debug.Console(1, this, "Attempting analog route input {0} to output {1}", inputSelector - Dmps.SwitcherInputs.Count, outputSelector); + output.AudioOutSource = (eDmps34KAudioOutSource)(inputSelector - Dmps.SwitcherInputs.Count); + } + else if (inputSelector <= Dmps.SwitcherInputs.Count) + { + var input = Dmps.SwitcherInputs[inputSelector] as DMInput; + if (input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaInput || input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaNoStreamingInput) + { + //Special case for weird AirMedia indexing + if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl) + output.AudioOutSource = eDmps34KAudioOutSource.AirMedia8; + else if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) + output.AudioOutSource = eDmps34KAudioOutSource.AirMedia9; + } + else + { + //Shift video inputs by 5 for weird DMPS3-4K indexing + output.AudioOutSource = (eDmps34KAudioOutSource)(inputSelector + 5); + } + } + } + } + + else if (inputSelector <= Dmps.SwitcherInputs.Count && outputSelector <= Dmps.SwitcherOutputs.Count) + { + var output = Dmps.SwitcherOutputs[outputSelector] as DMOutput; + var input = Dmps.SwitcherInputs[inputSelector] as DMInput; + output.AudioOut = input; + } + } } #endregion diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index ea3dbd5d..41b07237 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -93,6 +93,7 @@ +