|
|
|
|
@ -8,44 +8,45 @@ using Lib.Audio.Controls.Buttons.Interfaces; |
|
|
|
|
using Lib.Audio.Controls.Factories; |
|
|
|
|
using Lib.Audio.Controls.Interfaces; |
|
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
|
using Lib.Driver.Xml; |
|
|
|
|
|
|
|
|
|
namespace Lib.Audio |
|
|
|
|
{ |
|
|
|
|
public class Channel : IChannel |
|
|
|
|
{ |
|
|
|
|
private readonly uint _channelNumber; |
|
|
|
|
private readonly int _channelNumber; |
|
|
|
|
|
|
|
|
|
public Channel(uint channelNumber, |
|
|
|
|
IDeviceButtonConfiguration buttonConfiguration, |
|
|
|
|
public Channel(int channelNumber, |
|
|
|
|
XmlChannel xmlChannel, |
|
|
|
|
IFaderFactory faderFactory, |
|
|
|
|
IKnobFactory knobFactory, |
|
|
|
|
IButtonFactory buttonFactory) |
|
|
|
|
{ |
|
|
|
|
_channelNumber = channelNumber; |
|
|
|
|
Fader = faderFactory.Create(); |
|
|
|
|
Knob = knobFactory.Create(); |
|
|
|
|
Buttons = InitializeButtons(buttonConfiguration, buttonFactory); |
|
|
|
|
|
|
|
|
|
Fader.PositionChanged += OnFaderPositionChanged; |
|
|
|
|
if (xmlChannel.Fader != null) |
|
|
|
|
{ |
|
|
|
|
Fader = faderFactory.Create(); |
|
|
|
|
Fader.PositionChanged += OnFaderPositionChanged; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (xmlChannel.Knob != null) |
|
|
|
|
Knob = knobFactory.Create(); |
|
|
|
|
|
|
|
|
|
if (xmlChannel.Buttons != null) |
|
|
|
|
{ |
|
|
|
|
Buttons = new List<IButton>(); |
|
|
|
|
foreach (var button in xmlChannel.Buttons) |
|
|
|
|
Buttons.Add(buttonFactory.Create(button)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IFader Fader { get; } |
|
|
|
|
public IKnob Knob { get; } |
|
|
|
|
public List<IButton> Buttons { get; } |
|
|
|
|
public IFader? Fader { get; } |
|
|
|
|
public IKnob? Knob { get; } |
|
|
|
|
public List<IButton>? Buttons { get; } |
|
|
|
|
public IControllable? Controllable { get; private set; } |
|
|
|
|
|
|
|
|
|
public void AllocateControllable(IControllable controllable) => Controllable = controllable; |
|
|
|
|
|
|
|
|
|
//TODO: fix button handling |
|
|
|
|
private List<IButton> InitializeButtons(IDeviceButtonConfiguration buttonConfiguration, IButtonFactory buttonFactory) |
|
|
|
|
{ |
|
|
|
|
List<IButton> buttons = new(); |
|
|
|
|
for (int i = 0; i < buttonConfiguration.NumberOfButtons; i++) |
|
|
|
|
buttons.Add(buttonFactory.Create()); |
|
|
|
|
|
|
|
|
|
return buttons; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnFaderPositionChanged(object? sender, float position) => Controllable?.SetVolume(position); |
|
|
|
|
|
|
|
|
|
public override string ToString() => $"Channel {_channelNumber}"; |
|
|
|
|
|