mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 04:04:58 +00:00
fix: update hd-ps audio controllers to resolve control issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
@@ -20,36 +20,72 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
Mixer = chassis.AnalogAuxiliaryMixer[mixer];
|
Mixer = chassis.AnalogAuxiliaryMixer[mixer];
|
||||||
|
|
||||||
Mixer.AuxMixerPropertyChange += OnAuxMixerPropertyChange;
|
Mixer.AuxMixerPropertyChange += OnAuxMixerPropertyChange;
|
||||||
|
Mixer.AuxiliaryMuteControl.MuteAndVolumeControlPropertyChange += OnMuteAndVolumeControlPropertyChange;
|
||||||
|
|
||||||
VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc);
|
VolumeLevelFeedback = new IntFeedback(() => VolumeLevel);
|
||||||
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
MuteFeedback = new BoolFeedback(() => IsMuted);
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAuxMixerPropertyChange(object sender, GenericEventArgs args)
|
VolumeLevel = Mixer.VolumeFeedback.ShortValue;
|
||||||
{
|
IsMuted = Mixer.AuxiliaryMuteControl.MuteOnFeedback.BoolValue;
|
||||||
Debug.Console(2, this, "AuxMixerPropertyChange: {0} > Index-{1}, EventId-{2}", sender.ToString(), args.Index, args.EventId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Volume
|
#region Volume
|
||||||
|
|
||||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
private void OnAuxMixerPropertyChange(object sender, GenericEventArgs args)
|
||||||
|
|
||||||
protected Func<int> VolumeFeedbackFunc
|
|
||||||
{
|
{
|
||||||
get { return () => Mixer.VolumeFeedback.UShortValue; }
|
Debug.Console(2, this, "AuxMixerPropertyChange: {0} > Index-{1}, EventId-{2}", sender.GetType().ToString(), args.Index, args.EventId);
|
||||||
|
|
||||||
|
switch (args.EventId)
|
||||||
|
{
|
||||||
|
case (3):
|
||||||
|
{
|
||||||
|
VolumeLevel = Mixer.VolumeFeedback.ShortValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const ushort CrestronLevelMin = 0;
|
||||||
|
private const ushort CrestronLevelMax = 65535;
|
||||||
|
|
||||||
|
private const int DeviceLevelMin = -800;
|
||||||
|
private const int DeviceLevelMax = 200;
|
||||||
|
|
||||||
|
private const int RampTime = 5000;
|
||||||
|
|
||||||
|
private int _volumeLevel;
|
||||||
|
|
||||||
|
public int VolumeLevel
|
||||||
|
{
|
||||||
|
get { return _volumeLevel; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var level = value;
|
||||||
|
_volumeLevel = CrestronEnvironment.ScaleWithLimits(level, DeviceLevelMax, DeviceLevelMin, CrestronLevelMax, CrestronLevelMin);
|
||||||
|
|
||||||
|
Debug.Console(1, this, "VolumeFeedback: level-'{0}', scaled-'{1}'", level, _volumeLevel);
|
||||||
|
|
||||||
|
VolumeLevelFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||||
|
|
||||||
public void SetVolume(ushort level)
|
public void SetVolume(ushort level)
|
||||||
{
|
{
|
||||||
Mixer.Volume.UShortValue = level;
|
var scaled = CrestronEnvironment.ScaleWithLimits(level, CrestronLevelMax, CrestronLevelMin, DeviceLevelMax,
|
||||||
|
DeviceLevelMin);
|
||||||
|
|
||||||
|
Debug.Console(1, this, "SetVolume: level-'{0}', scaled-'{1}'", level, scaled);
|
||||||
|
|
||||||
|
Mixer.Volume.ShortValue = (short)scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VolumeUp(bool pressRelease)
|
public void VolumeUp(bool pressRelease)
|
||||||
{
|
{
|
||||||
if (pressRelease)
|
if (pressRelease)
|
||||||
{
|
{
|
||||||
var remainingRatio = (65535 - Mixer.Volume.UShortValue)/65535;
|
Mixer.Volume.CreateSignedRamp(DeviceLevelMax, RampTime);
|
||||||
Mixer.Volume.CreateRamp(65535, 400);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -61,8 +97,10 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
{
|
{
|
||||||
if (pressRelease)
|
if (pressRelease)
|
||||||
{
|
{
|
||||||
var remainingRatio = Mixer.Volume.UShortValue/65535;
|
//var remainingRatio = Mixer.Volume.UShortValue/CrestronLevelMax;
|
||||||
Mixer.Volume.CreateRamp(0, (uint)(400 * remainingRatio));
|
//Mixer.Volume.CreateRamp(CrestronLevelMin, (uint)(RampTime * remainingRatio));
|
||||||
|
|
||||||
|
Mixer.Volume.CreateSignedRamp(DeviceLevelMin, RampTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -73,17 +111,42 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Mute
|
#region Mute
|
||||||
|
|
||||||
|
private void OnMuteAndVolumeControlPropertyChange(MuteControl device, GenericEventArgs args)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "OnMuteAndVolumeControlPropertyChange: {0} > Index-{1}, EventId-{2}", device.ToString(), args.Index, args.EventId);
|
||||||
|
|
||||||
|
switch (args.EventId)
|
||||||
|
{
|
||||||
|
case (1):
|
||||||
|
case (2):
|
||||||
|
{
|
||||||
|
IsMuted = Mixer.AuxiliaryMuteControl.MuteOnFeedback.BoolValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool _isMuted;
|
private bool _isMuted;
|
||||||
|
|
||||||
public BoolFeedback MuteFeedback { get; private set; }
|
public bool IsMuted
|
||||||
|
|
||||||
protected Func<bool> MuteFeedbackFunc
|
|
||||||
{
|
{
|
||||||
get { return () => _isMuted = Mixer.AuxiliaryMuteControl.MuteOnFeedback.BoolValue; }
|
get { return _isMuted; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isMuted = value;
|
||||||
|
|
||||||
|
Debug.Console(1, this, "IsMuted: _isMuted-'{0}'", _isMuted);
|
||||||
|
|
||||||
|
MuteFeedback.FireUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BoolFeedback MuteFeedback { get; private set; }
|
||||||
|
|
||||||
public void MuteOn()
|
public void MuteOn()
|
||||||
{
|
{
|
||||||
Mixer.AuxiliaryMuteControl.MuteOn();
|
Mixer.AuxiliaryMuteControl.MuteOn();
|
||||||
@@ -96,7 +159,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
|
|
||||||
public void MuteToggle()
|
public void MuteToggle()
|
||||||
{
|
{
|
||||||
if (_isMuted)
|
if (IsMuted)
|
||||||
MuteOff();
|
MuteOff();
|
||||||
else
|
else
|
||||||
MuteOn();
|
MuteOn();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
@@ -18,30 +18,59 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
|
|
||||||
Port = chassis.HdmiDmLiteOutputs[output].OutputPort;
|
Port = chassis.HdmiDmLiteOutputs[output].OutputPort;
|
||||||
|
|
||||||
VolumeLevelFeedback = new IntFeedback(VolumeFeedbackFunc);
|
VolumeLevelFeedback = new IntFeedback(() => VolumeLevel);
|
||||||
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
MuteFeedback = new BoolFeedback(() => IsMuted);
|
||||||
|
|
||||||
|
//if(Port.AudioOutput.Volume != null)
|
||||||
|
// VolumeLevel = Port.AudioOutput.VolumeFeedback.UShortValue;
|
||||||
|
|
||||||
|
IsMuted = Port.MuteOnFeedback.BoolValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Volume
|
#region Volume
|
||||||
|
|
||||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
private const ushort CrestronLevelMin = 0;
|
||||||
|
private const ushort CrestronLevelMax = 65535;
|
||||||
|
|
||||||
protected Func<int> VolumeFeedbackFunc
|
private const int DeviceLevelMin = -800;
|
||||||
|
private const int DeviceLevelMax = 200;
|
||||||
|
|
||||||
|
private const int RampTime = 5000;
|
||||||
|
|
||||||
|
private int _volumeLevel;
|
||||||
|
|
||||||
|
public int VolumeLevel
|
||||||
{
|
{
|
||||||
get { return () => Port.AudioOutput.VolumeFeedback.UShortValue; }
|
get { return _volumeLevel; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var level = value;
|
||||||
|
//_volumeLevel = CrestronEnvironment.ScaleWithLimits(level, DeviceLevelMax, DeviceLevelMin, CrestronLevelMax, CrestronLevelMin);
|
||||||
|
_volumeLevel = CrestronEnvironment.ScaleWithLimits(level, CrestronLevelMax, CrestronLevelMin, DeviceLevelMax, DeviceLevelMin);
|
||||||
|
|
||||||
|
Debug.Console(2, this, "VolumeFeedback: level-'{0}', scaled-'{1}'", level, _volumeLevel);
|
||||||
|
|
||||||
|
VolumeLevelFeedback.FireUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||||
|
|
||||||
public void SetVolume(ushort level)
|
public void SetVolume(ushort level)
|
||||||
{
|
{
|
||||||
Port.AudioOutput.Volume.UShortValue = level;
|
var scaled = CrestronEnvironment.ScaleWithLimits(level, CrestronLevelMax, CrestronLevelMin, DeviceLevelMax,
|
||||||
|
DeviceLevelMin);
|
||||||
|
|
||||||
|
Debug.Console(1, this, "SetVolume: level-'{0}', scaled-'{1}'", level, scaled);
|
||||||
|
|
||||||
|
Port.AudioOutput.Volume.ShortValue = (short)scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VolumeUp(bool pressRelease)
|
public void VolumeUp(bool pressRelease)
|
||||||
{
|
{
|
||||||
if (pressRelease)
|
if (pressRelease)
|
||||||
{
|
{
|
||||||
var remainingRatio = (65535 - Port.AudioOutput.Volume.UShortValue)/65535;
|
Port.AudioOutput.Volume.CreateSignedRamp(DeviceLevelMax, RampTime);
|
||||||
Port.AudioOutput.Volume.CreateRamp(65535, 400);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -53,8 +82,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
{
|
{
|
||||||
if (pressRelease)
|
if (pressRelease)
|
||||||
{
|
{
|
||||||
var remainingRatio = Port.AudioOutput.Volume.UShortValue/65535;
|
Port.AudioOutput.Volume.CreateSignedRamp(DeviceLevelMin, RampTime);
|
||||||
Port.AudioOutput.Volume.CreateRamp(0, (uint)(400 * remainingRatio));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -65,17 +93,27 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Mute
|
#region Mute
|
||||||
|
|
||||||
private bool _isMuted;
|
private bool _isMuted;
|
||||||
|
|
||||||
public BoolFeedback MuteFeedback { get; private set; }
|
public bool IsMuted
|
||||||
|
|
||||||
protected Func<bool> MuteFeedbackFunc
|
|
||||||
{
|
{
|
||||||
get { return () => _isMuted = Port.MuteOnFeedback.BoolValue; }
|
get { return _isMuted; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isMuted = value;
|
||||||
|
|
||||||
|
Debug.Console(1, this, "IsMuted: _isMuted-'{0}'", _isMuted);
|
||||||
|
|
||||||
|
MuteFeedback.FireUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BoolFeedback MuteFeedback { get; private set; }
|
||||||
|
|
||||||
public void MuteOn()
|
public void MuteOn()
|
||||||
{
|
{
|
||||||
Port.MuteOn();
|
Port.MuteOn();
|
||||||
@@ -88,7 +126,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
|
|
||||||
public void MuteToggle()
|
public void MuteToggle()
|
||||||
{
|
{
|
||||||
if (_isMuted)
|
if (IsMuted)
|
||||||
MuteOff();
|
MuteOff();
|
||||||
else
|
else
|
||||||
MuteOn();
|
MuteOn();
|
||||||
|
|||||||
Reference in New Issue
Block a user