Cross Platform Application to allow control with a MIDI controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

// Author: Gockner, Simon
// Created: 2021-04-07
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System.Collections.Generic;
using Lib.Audio.Factories;
using Lib.Audio.Interfaces;
using Lib.Midi.Factories;
using Lib.Midi.Interfaces;
namespace Lib.Audio
{
public class Device : IDevice
{
private readonly IMidiCommunication _midiCommunication;
private readonly IDeviceButtonConfiguration _buttonConfiguration;
public Device(IMidiCommunicationFactory midiCommunicationFactory, IChannelFactory channelFactory)
{
_midiCommunication = midiCommunicationFactory.Create();
_buttonConfiguration = new DeviceButtonConfiguration {HasMuteButton = true, NumberOfButtons = 4}; //FixMe: remove hard coded config
Channels = new List<IChannel>();
for (uint i = 0; i < 8; i++) //FixMe: remove hard coded config
Channels.Add(channelFactory.Create(i, _buttonConfiguration));
_midiCommunication.MessageReceived += OnMidiCommunicationMessageReceived;
_midiCommunication.ErrorReceived += OnMidiCommunicationErrorReceived;
}
public List<IChannel> Channels { get; }
public void StartCommunication() => _midiCommunication.Open();
private void OnMidiCommunicationMessageReceived(object? sender, IMidiMessage message)
{
int i = 0;
}
private void OnMidiCommunicationErrorReceived(object? sender, IMidiMessage message)
{
int i = 0;
}
}
}