|
|
|
@ -3,6 +3,9 @@ |
|
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved. |
|
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved. |
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using Lib.Audio.Controls.Buttons.Factories; |
|
|
|
|
|
|
|
using Lib.Audio.Controls.Buttons.Interfaces; |
|
|
|
|
|
|
|
using Lib.Audio.Controls.Factories; |
|
|
|
using Lib.Audio.Controls.Interfaces; |
|
|
|
using Lib.Audio.Controls.Interfaces; |
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
using Lib.Audio.Interfaces; |
|
|
|
|
|
|
|
|
|
|
|
@ -10,9 +13,35 @@ namespace Lib.Audio |
|
|
|
{ |
|
|
|
{ |
|
|
|
public class Channel : IChannel |
|
|
|
public class Channel : IChannel |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
public Channel(IDeviceButtonConfiguration buttonConfiguration, |
|
|
|
|
|
|
|
IFaderFactory faderFactory, |
|
|
|
|
|
|
|
IKnobFactory knobFactory, |
|
|
|
|
|
|
|
IButtonFactory buttonFactory) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Fader = faderFactory.Create(); |
|
|
|
|
|
|
|
Knob = knobFactory.Create(); |
|
|
|
|
|
|
|
Buttons = InitializeButtons(buttonConfiguration, buttonFactory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fader.PositionChanged += OnFaderPositionChanged; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public IFader Fader { get; } |
|
|
|
public IFader Fader { get; } |
|
|
|
public IKnob Knob { get; } |
|
|
|
public IKnob Knob { get; } |
|
|
|
public List<IButton> Buttons { get; } |
|
|
|
public List<IButton> Buttons { get; } |
|
|
|
public IControllable Controllable { 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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |