mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-29 20:34:51 +00:00
feat: add output audio controller
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash_Essentials_DM.Chassis
|
||||
{
|
||||
public class HdPsXxxAnalogAuxMixerController : IKeyed, IBasicVolumeWithFeedback
|
||||
public class HdPsXxxAnalogAuxMixerController : IKeyed,
|
||||
IHasVolumeControlWithFeedback, IHasMuteControlWithFeedback // || IBasicVolumeWithFeedback
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
|
||||
public HdPsXxxAnalogAuxMixer Mixer { get; set; }
|
||||
public HdPsXxxAnalogAuxMixer Mixer { get; private set; }
|
||||
|
||||
public HdPsXxxAnalogAuxMixerController(string parent, uint mixer, HdPsXxx chassis)
|
||||
{
|
||||
@@ -17,10 +19,17 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
|
||||
Mixer = chassis.AnalogAuxiliaryMixer[mixer];
|
||||
|
||||
Mixer.AuxMixerPropertyChange += OnAuxMixerPropertyChange;
|
||||
|
||||
VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc);
|
||||
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
||||
}
|
||||
|
||||
private void OnAuxMixerPropertyChange(object sender, GenericEventArgs args)
|
||||
{
|
||||
Debug.Console(2, this, "AuxMixerPropertyChange: {0} > Index-{1}, EventId-{2}", sender.ToString(), args.Index, args.EventId);
|
||||
}
|
||||
|
||||
#region Volume
|
||||
|
||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||
|
||||
@@ -83,10 +83,15 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
OutputNames = props.Outputs;
|
||||
SetupOutputs(OutputNames);
|
||||
|
||||
foreach (var mixer in _chassis.AnalogAuxiliaryMixer)
|
||||
foreach (var item in _chassis.HdmiDmLiteOutputs)
|
||||
{
|
||||
var mixerDevice = new HdPsXxxAnalogAuxMixerController(Key, mixer.MixerNumber, _chassis);
|
||||
DeviceManager.AddDevice(mixerDevice);
|
||||
var audioDevice = new HdPsXxxOutputAudioController(Key, item.Number, _chassis);
|
||||
DeviceManager.AddDevice(audioDevice);
|
||||
}
|
||||
foreach (var item in _chassis.AnalogAuxiliaryMixer)
|
||||
{
|
||||
var audioDevice = new HdPsXxxAnalogAuxMixerController(Key, item.MixerNumber, _chassis);
|
||||
DeviceManager.AddDevice(audioDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +185,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
var output = item;
|
||||
var index = item.Number;
|
||||
var name = string.IsNullOrEmpty(OutputNames[index])
|
||||
? string.Format("Output {0}", index)
|
||||
? string.Format("Port {0}", index)
|
||||
: OutputNames[index];
|
||||
|
||||
output.Name.StringValue = name;
|
||||
@@ -191,7 +196,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
FeedbackMatchObject = output,
|
||||
Port = output.HdmiOutput.HdmiOutputPort
|
||||
};
|
||||
Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, name);
|
||||
Debug.Console(1, this, "Adding Port port: {0} - {1}", hdmiPort.Key, name);
|
||||
OutputPorts.Add(hdmiPort);
|
||||
|
||||
var dmLiteKey = string.Format("dmLiteOut{0}", index);
|
||||
@@ -200,7 +205,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
FeedbackMatchObject = output,
|
||||
Port = output.DmLiteOutput.DmLiteOutputPort
|
||||
};
|
||||
Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, name);
|
||||
Debug.Console(1, this, "Adding Port port: {0} - {1}", dmLitePort.Key, name);
|
||||
OutputPorts.Add(dmLitePort);
|
||||
|
||||
OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture),
|
||||
@@ -237,7 +242,7 @@ Selector: {4}
|
||||
|
||||
foreach (var port in OutputPorts)
|
||||
{
|
||||
Debug.Console(0, this, @"Output Port Key: {0}
|
||||
Debug.Console(0, this, @"Port Port Key: {0}
|
||||
Port: {1}
|
||||
Type: {2}
|
||||
ConnectionType: {3}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash_Essentials_DM.Chassis
|
||||
{
|
||||
public class HdPsXxxOutputAudioController : IKeyed,
|
||||
IHasVolumeControlWithFeedback, IHasMuteControlWithFeedback // || IBasicVolumeWithFeedback
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
|
||||
public HdPsXxxOutputPort Port { get; private set; }
|
||||
|
||||
public HdPsXxxOutputAudioController(string parent, uint output, HdPsXxx chassis)
|
||||
{
|
||||
Key = string.Format("{0}-audioOut{1}", parent, output);
|
||||
|
||||
Port = chassis.HdmiDmLiteOutputs[output].OutputPort;
|
||||
|
||||
VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc);
|
||||
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
||||
}
|
||||
|
||||
#region Volume
|
||||
|
||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||
|
||||
protected Func<int> VolumeFeedbackFunc
|
||||
{
|
||||
get { return () => Port.AudioOutput.VolumeFeedback.UShortValue; }
|
||||
}
|
||||
|
||||
public void SetVolume(ushort level)
|
||||
{
|
||||
Port.AudioOutput.Volume.UShortValue = level;
|
||||
}
|
||||
|
||||
public void VolumeUp(bool pressRelease)
|
||||
{
|
||||
if (pressRelease)
|
||||
{
|
||||
var remainingRatio = (65535 - Port.AudioOutput.Volume.UShortValue)/65535;
|
||||
Port.AudioOutput.Volume.CreateRamp(65535, 400);
|
||||
}
|
||||
else
|
||||
{
|
||||
Port.AudioOutput.Volume.StopRamp();
|
||||
}
|
||||
}
|
||||
|
||||
public void VolumeDown(bool pressRelease)
|
||||
{
|
||||
if (pressRelease)
|
||||
{
|
||||
var remainingRatio = Port.AudioOutput.Volume.UShortValue/65535;
|
||||
Port.AudioOutput.Volume.CreateRamp(0, (uint)(400 * remainingRatio));
|
||||
}
|
||||
else
|
||||
{
|
||||
Port.AudioOutput.Volume.StopRamp();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Mute
|
||||
|
||||
private bool _isMuted;
|
||||
|
||||
public BoolFeedback MuteFeedback { get; private set; }
|
||||
|
||||
protected Func<bool> MuteFeedbackFunc
|
||||
{
|
||||
get { return () => _isMuted = Port.MuteOnFeedback.BoolValue; }
|
||||
}
|
||||
|
||||
public void MuteOn()
|
||||
{
|
||||
Port.MuteOn();
|
||||
}
|
||||
|
||||
public void MuteOff()
|
||||
{
|
||||
Port.MuteOff();
|
||||
}
|
||||
|
||||
public void MuteToggle()
|
||||
{
|
||||
if (_isMuted)
|
||||
MuteOff();
|
||||
else
|
||||
MuteOn();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,7 @@
|
||||
<Compile Include="Chassis\HdMdNxM4kEController.cs" />
|
||||
<Compile Include="Chassis\HdPsXxxAnalogAuxMixerController.cs" />
|
||||
<Compile Include="Chassis\HdPsXxxController.cs" />
|
||||
<Compile Include="Chassis\HdPsXxxOutputAudioController.cs" />
|
||||
<Compile Include="Config\HdPsXxxPropertiesConfig.cs" />
|
||||
<Compile Include="Config\InputPropertiesConfig.cs" />
|
||||
<Compile Include="Endpoints\EndpointInterfaces.cs" />
|
||||
|
||||
Reference in New Issue
Block a user