mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +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:
parent
455d85e8f9
commit
0f44700486
2 changed files with 76 additions and 60 deletions
|
|
@ -411,19 +411,28 @@ namespace PepperDash.Essentials.DM
|
||||||
public void SetVolumeScaled(ushort level)
|
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());
|
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);
|
VolumeLevelInput = (ushort)(level * (MaxLevel - MinLevel) / ushort.MaxValue + MinLevel);
|
||||||
if (EnableVolumeSend == true)
|
if (EnableVolumeSend == true)
|
||||||
{
|
{
|
||||||
Level.UShortValue = VolumeLevelInput;
|
Level.UShortValue = VolumeLevelInput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ushort ScaleVolumeFeedback(ushort level)
|
public ushort ScaleVolumeFeedback(ushort level)
|
||||||
{
|
{
|
||||||
short signedLevel = (short)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());
|
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));
|
return (ushort)((signedLevel - MinLevel) * ushort.MaxValue / (MaxLevel - MinLevel));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return (ushort)MinLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public void SendScaledVolume(bool pressRelease)
|
public void SendScaledVolume(bool pressRelease)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,8 @@ namespace PepperDash.Essentials.DM
|
||||||
void SetupOutputCards()
|
void SetupOutputCards()
|
||||||
{
|
{
|
||||||
foreach (var card in Dmps.SwitcherOutputs)
|
foreach (var card in Dmps.SwitcherOutputs)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType);
|
Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType);
|
||||||
|
|
||||||
|
|
@ -545,6 +547,11 @@ namespace PepperDash.Essentials.DM
|
||||||
|
|
||||||
AddOutputCard(outputCard.Number, outputCard);
|
AddOutputCard(outputCard.Number, outputCard);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError(Debug.ErrorLogLevel.Error, string.Format("DMPS Controller exception creating output card: {0}", ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue