mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 21:24:54 +00:00
Fixes issue where if DMPS audio min and max levels were set to the same value, a divide by zero exception would occur. Adds try-catch to output card constructor so single output card failing won't break all routing.
This commit is contained in:
@@ -411,19 +411,28 @@ namespace PepperDash.Essentials.DM
|
||||
public void SetVolumeScaled(ushort level)
|
||||
{
|
||||
Debug.Console(2, Debug.ErrorLogLevel.None, "Scaling DMPS volume:{0} level:{1} min:{2} max:{3}", Output.Name, level.ToString(), MinLevel.ToString(), MaxLevel.ToString());
|
||||
if (ushort.MaxValue + MinLevel != 0)
|
||||
{
|
||||
VolumeLevelInput = (ushort)(level * (MaxLevel - MinLevel) / ushort.MaxValue + MinLevel);
|
||||
if (EnableVolumeSend == true)
|
||||
{
|
||||
Level.UShortValue = VolumeLevelInput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ushort ScaleVolumeFeedback(ushort level)
|
||||
{
|
||||
short signedLevel = (short)level;
|
||||
Debug.Console(2, Debug.ErrorLogLevel.None, "Scaling DMPS volume:{0} feedback:{1} min:{2} max:{3}", Output.Name, signedLevel.ToString(), MinLevel.ToString(), MaxLevel.ToString());
|
||||
|
||||
if (MaxLevel - MinLevel != 0)
|
||||
{
|
||||
return (ushort)((signedLevel - MinLevel) * ushort.MaxValue / (MaxLevel - MinLevel));
|
||||
}
|
||||
else
|
||||
return (ushort)MinLevel;
|
||||
}
|
||||
|
||||
public void SendScaledVolume(bool pressRelease)
|
||||
{
|
||||
|
||||
@@ -480,6 +480,8 @@ namespace PepperDash.Essentials.DM
|
||||
void SetupOutputCards()
|
||||
{
|
||||
foreach (var card in Dmps.SwitcherOutputs)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType);
|
||||
|
||||
@@ -545,6 +547,11 @@ namespace PepperDash.Essentials.DM
|
||||
|
||||
AddOutputCard(outputCard.Number, outputCard);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(Debug.ErrorLogLevel.Error, string.Format("DMPS Controller exception creating output card: {0}", ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user