Skip to content

Commit

Permalink
Merge pull request #39 from MatKlucznyk/add-matrix-mixer-in/out-gain/…
Browse files Browse the repository at this point in the history
…mute-control

Add matrix mixer in/out gain/mute control
  • Loading branch information
MatKlucznyk authored Feb 7, 2024
2 parents 4bbe624 + 96ac55a commit 2ebf258
Show file tree
Hide file tree
Showing 27 changed files with 1,576 additions and 249 deletions.
150 changes: 150 additions & 0 deletions QscQsys/QscQsys/NamedComponents/QsysMatrixMixerInputFader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using Crestron.SimplSharp;
using QscQsys.Intermediaries;
using QscQsys.Utils;

namespace QscQsys.NamedComponents
{
public sealed class QsysMatrixMixerInputFader : AbstractQsysComponent
{
public delegate void MuteChange(SimplSharpString cName, ushort value);
public delegate void VolumeChange(SimplSharpString cName, ushort value);
public MuteChange newMuteChange { get; set; }
public VolumeChange newVolumeChange { get; set; }

private ushort _input;
private bool _initialized;

private NamedComponentControl _muteControl;
private NamedComponentControl _gainControl;

private string MuteControlName
{
get { return ControlNameUtils.GetMatrixInputMuteName(_input); }
}

private string GainControlName
{
get { return ControlNameUtils.GetMatrixInputGainName(_input); }
}

public NamedComponentControl MuteControl
{
get { return _muteControl; }
private set
{
if (_muteControl == value)
return;

UnsubscribeMuteControl(_muteControl);
_muteControl = value;
SubscribeMuteControl(_muteControl);
}
}

public NamedComponentControl GainControl
{
get { return _gainControl; }
private set
{
if (_gainControl == value)
return;

UnsubscribeGainControl(_gainControl);
_gainControl = value;
SubscribeGainControl(_gainControl);
}
}

public void Initialize(string coreId, string componentName, ushort input)
{
if (_initialized)
return;

_initialized = true;

_input = input;
InternalInitialize(coreId, componentName);
}

protected override void HandleComponentUpdated(NamedComponent component)
{
base.HandleComponentUpdated(component);

if (component == null)
{
MuteControl = null;
GainControl = null;
return;
}

MuteControl = component.LazyLoadComponentControl(MuteControlName);
GainControl = component.LazyLoadComponentControl(GainControlName);
}

public void SetMute(ushort value)
{
if (MuteControl != null)
MuteControl.SendChangeBoolValue(value.BoolFromSplus());
}

public void SetGain(ushort value)
{
if (GainControl != null)
GainControl.SendChangePosition(SimplUtils.ScaleToDouble(value));
}

#region Mute Control Callbacks

private void SubscribeMuteControl(NamedComponentControl muteControl)
{
if (muteControl == null)
return;

muteControl.OnStateChanged += MuteControlOnStateChanged;
}

private void UnsubscribeMuteControl(NamedComponentControl muteControl)
{
if (muteControl == null)
return;

muteControl.OnStateChanged -= MuteControlOnStateChanged;
}

private void MuteControlOnStateChanged(object sender, QsysInternalEventsArgs args)
{
var callback = newMuteChange;
if (callback != null)
callback(MuteControlName, args.BoolValue.BoolToSplus());
}

#endregion

#region Gain Control Callbacks

private void SubscribeGainControl(NamedComponentControl gainControl)
{
if (gainControl == null)
return;

gainControl.OnStateChanged += GainControlOnStateChanged;
}

private void UnsubscribeGainControl(NamedComponentControl gainControl)
{
if (gainControl == null)
return;

gainControl.OnStateChanged -= GainControlOnStateChanged;
}

private void GainControlOnStateChanged(object sender, QsysInternalEventsArgs args)
{
var callback = newVolumeChange;
if (callback != null)
callback(GainControlName, SimplUtils.ScaleToUshort(args.Position));
}

#endregion
}
}
150 changes: 150 additions & 0 deletions QscQsys/QscQsys/NamedComponents/QsysMatrixMixerOutputFader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using Crestron.SimplSharp;
using QscQsys.Intermediaries;
using QscQsys.Utils;

namespace QscQsys.NamedComponents
{
public sealed class QsysMatrixMixerOutputFader : AbstractQsysComponent
{
public delegate void MuteChange(SimplSharpString cName, ushort value);
public delegate void VolumeChange(SimplSharpString cName, ushort value);
public MuteChange newMuteChange { get; set; }
public VolumeChange newVolumeChange { get; set; }

private ushort _output;
private bool _initialized;

private NamedComponentControl _muteControl;
private NamedComponentControl _gainControl;

private string MuteControlName
{
get { return ControlNameUtils.GetMatrixOutputMuteName(_output); }
}

private string GainControlName
{
get { return ControlNameUtils.GetMatrixOutputGainName(_output); }
}

public NamedComponentControl MuteControl
{
get { return _muteControl; }
private set
{
if (_muteControl == value)
return;

UnsubscribeMuteControl(_muteControl);
_muteControl = value;
SubscribeMuteControl(_muteControl);
}
}

public NamedComponentControl GainControl
{
get { return _gainControl; }
private set
{
if (_gainControl == value)
return;

UnsubscribeGainControl(_gainControl);
_gainControl = value;
SubscribeGainControl(_gainControl);
}
}

public void Initialize(string coreId, string componentName, ushort output)
{
if (_initialized)
return;

_initialized = true;

_output = output;
InternalInitialize(coreId, componentName);
}

protected override void HandleComponentUpdated(NamedComponent component)
{
base.HandleComponentUpdated(component);

if (component == null)
{
MuteControl = null;
GainControl = null;
return;
}

MuteControl = component.LazyLoadComponentControl(MuteControlName);
GainControl = component.LazyLoadComponentControl(GainControlName);
}

public void SetMute(ushort value)
{
if (MuteControl != null)
MuteControl.SendChangeBoolValue(value.BoolFromSplus());
}

public void SetGain(ushort value)
{
if (GainControl != null)
GainControl.SendChangePosition(SimplUtils.ScaleToDouble(value));
}

#region Mute Control Callbacks

private void SubscribeMuteControl(NamedComponentControl muteControl)
{
if (muteControl == null)
return;

muteControl.OnStateChanged += MuteControlOnStateChanged;
}

private void UnsubscribeMuteControl(NamedComponentControl muteControl)
{
if (muteControl == null)
return;

muteControl.OnStateChanged -= MuteControlOnStateChanged;
}

private void MuteControlOnStateChanged(object sender, QsysInternalEventsArgs args)
{
var callback = newMuteChange;
if (callback != null)
callback(MuteControlName, args.BoolValue.BoolToSplus());
}

#endregion

#region Gain Control Callbacks

private void SubscribeGainControl(NamedComponentControl gainControl)
{
if (gainControl == null)
return;

gainControl.OnStateChanged += GainControlOnStateChanged;
}

private void UnsubscribeGainControl(NamedComponentControl gainControl)
{
if (gainControl == null)
return;

gainControl.OnStateChanged -= GainControlOnStateChanged;
}

private void GainControlOnStateChanged(object sender, QsysInternalEventsArgs args)
{
var callback = newVolumeChange;
if (callback != null)
callback(GainControlName, SimplUtils.ScaleToUshort(args.Position));
}

#endregion
}
}
2 changes: 2 additions & 0 deletions QscQsys/QscQsys/QscQsys.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
<Compile Include="Intermediaries\NamedComponentControl.cs" />
<Compile Include="Intermediaries\NamedControl.cs" />
<Compile Include="Json.cs" />
<Compile Include="NamedComponents\QsysMatrixMixerOutputFader.cs" />
<Compile Include="NamedComponents\QsysMatrixMixerInputFader.cs" />
<Compile Include="QsysBackupCore.cs" />
<Compile Include="NamedComponents\QsysCamera.cs" />
<Compile Include="NamedComponents\AbstractQsysComponent.cs" />
Expand Down
22 changes: 22 additions & 0 deletions QscQsys/QscQsys/Utils/ControlNameUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static class ControlNameUtils
private const string SIGNAL_PRESENCE = "signal_presence";

private const string MATRIX_MIXER_CONTROL_NAME_FORMAT = "input_{0}_output_{1}_{2}";
private const string MATRIX_MIXER_INPUT_NAME_FORMAT = "input_{0}_{1}";
private const string MATRIX_MIXER_OUTPUT_NAME_FORMAT = "output_{0}_{1}";
private const string METER_NAME_FORMAT = "meter_{0}";
private const string ROUTER_SELECT_NAME_FORMAT = "select_{0}";
private const string ROUTER_MUTE_NAME_FORMAT = "mute_{0}";
Expand All @@ -34,6 +36,26 @@ public static string GetMatrixCrosspointGainName(int input, int output)
return string.Format(MATRIX_MIXER_CONTROL_NAME_FORMAT, input, output, GAIN);
}

public static string GetMatrixInputMuteName(int input)
{
return string.Format(MATRIX_MIXER_INPUT_NAME_FORMAT, input, MUTE);
}

public static string GetMatrixInputGainName(int input)
{
return string.Format(MATRIX_MIXER_INPUT_NAME_FORMAT, input, GAIN);
}

public static string GetMatrixOutputMuteName(int output)
{
return string.Format(MATRIX_MIXER_OUTPUT_NAME_FORMAT, output, MUTE);
}

public static string GetMatrixOutputGainName(int output)
{
return string.Format(MATRIX_MIXER_OUTPUT_NAME_FORMAT, output, GAIN);
}

public static string GetMeterName(int index)
{
return string.Format(METER_NAME_FORMAT, index);
Expand Down
Binary file modified QscQsys/QscQsys/bin/Debug/QscQsys.clz
Binary file not shown.
6 changes: 3 additions & 3 deletions QscQsys/QscQsys/bin/Debug/QscQsys.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<ArchiveName />
</RequiredInfo>
<OptionalInfo>
<CompiledOn>2023-10-11 8:57:09 AM</CompiledOn>
<CompilerRev>1.0.0.14314</CompilerRev>
<CompiledOn>2024-02-07 1:35:31 PM</CompiledOn>
<CompilerRev>1.0.0.24464</CompilerRev>
</OptionalInfo>
<Plugin>
<Version>Crestron.SIMPLSharp, Version=2.0.58.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version>
<Include4.dat>2.19.076</Include4.dat>
<Include4.dat>2.20.042</Include4.dat>
</Plugin>
</ProgramInfo>
Binary file modified QscQsys/QscQsys/bin/Debug/QscQsys.dll
Binary file not shown.
Binary file modified QscQsys/QscQsys/bin/Debug/QscQsys.pdb
Binary file not shown.
Binary file not shown.
Binary file modified QscQsys/QscQsys/bin/Debug/SimplSharpHelperInterface.dll
Binary file not shown.
Binary file modified QscQsys/QscQsys/bin/Debug/SimplSharpNewtonsoft.dll
Binary file not shown.
Binary file modified QscQsys/QscQsys/bin/Debug/SimplSharpReflectionInterface.dll
Binary file not shown.
Binary file modified QscQsys/QscQsys/bin/Debug/SimplSharpSQLHelperInterface.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion QscQsys/QscQsys/bin/Debug/manifest.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MainAssembly=QscQsys.dll:2b76c049b4c5a20baff034a6681dbc5e
MainAssembly=QscQsys.dll:ff95c494a89d43dc13c7132badcf651d
MainAssemblyMinFirmwareVersion=1.007.0017
MainAssemblyResource=QscQsys.xml:59588033c4d98eef04c508e59e1e843d
MainAssemblyResource=SimplSharpData.dat:820b61c48c8a2cace82957eed4cc377c
Expand Down
Binary file modified QscQsys/QscQsys/bin/Debug/manifest.ser
Binary file not shown.
Binary file modified QscQsys/QscQsys/obj/Debug/QscQsys.dll
Binary file not shown.
Binary file modified QscQsys/QscQsys/obj/Debug/QscQsys.pdb
Binary file not shown.
Loading

0 comments on commit 2ebf258

Please sign in to comment.