melanchall / drywetmidi

.NET library to read, write, process MIDI files and to work with MIDI devices
https://melanchall.github.io/drywetmidi
MIT License
540 stars 75 forks source link

Midi recording without input device? #54

Closed Yorgg closed 4 years ago

Yorgg commented 4 years ago

I would like to send midi events to the midi Recording without using the InputDevice.

Perhaps If we change OnEventReceived to be public then other objects could subscribe to it?
Something like this:

customEventGenerator.ProcessMidiEvent += recording.OnEventReceived

And the InputDevice could be optional in the Recording class?

https://github.com/melanchall/drywetmidi/blob/ce71820e4679bf605b2f726aed4068347e36caa4/DryWetMidi/Devices/Recording/Recording.cs

melanchall commented 4 years ago

Hi,

I think it will be better to introduce interface like IInputDevice that will be implemented by standard InputDevice and that you can implement by yourself. IInputDevice will contain event EventReceived. And Recording will work with that interface rather than with InputDevice.

In my opinion it's more flexible way. Please tell me if it sounds good.

Yorgg commented 4 years ago

Agreed. That sounds good.

melanchall commented 4 years ago

I've added IInputDevice interface:

public interface IInputDevice
{
    event EventHandler<MidiEventReceivedEventArgs> EventReceived;

    bool IsListeningForEvents { get; }

    void StartEventsListening();

    void StopEventsListening();
}