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.

30 lines
946 B

// Author: Gockner, Simon
// Created: 2021-04-07
// Copyright(c) 2021 SimonG. All Rights Reserved.
using Lib.Audio.Controls.Buttons.Interfaces;
using Lib.Audio.Interfaces;
using Lib.Midi.Messages;
using Lib.Midi.Messages.Interfaces;
namespace Lib.Audio.Controls.Buttons
{
public class Button : IButton //TODO: Make abstract?
{
private readonly int _channelNumber;
public Button(int noteNumber, int channelNumber)
{
NoteNumber = noteNumber;
_channelNumber = channelNumber;
}
public int NoteNumber { get; }
public virtual IMidiMessage HandleOn(IControllable? controllable, int velocity) =>
new NoteOnMessage(0, _channelNumber, NoteNumber, velocity, 0);
public virtual IMidiMessage HandleOff(IControllable? controllable, int velocity) =>
new NoteMessage(0, _channelNumber, NoteNumber, velocity);
}
}