Issue with Recording Object Not Capturing MIDI Events in DryWetMidi #287
-
Hi there. I’ve been using the Melanchall.DryWetMidi library successfully for about a month, specifically utilizing its recording capabilities to capture MIDI events. Initially, everything worked as expected, and I was able to save MIDI recordings without any issues. However, recently I've encountered a problem where the library's event capture mechanism seems to have stopped working. Despite no memory of significant changes on my end, the Recording object no longer captures events from their associated InputDevice, resulting in empty recordings. Here’s a snippet of how I’m setting up the recording objects:
To diagnose the issue, I've confirmed that MIDI events are indeed being received by verifying through debug logs in the EventReceived event handler. However, these events do not appear to be captured by the Recording object, as indicated by the recording being empty upon saving.
Any suggestions on further troubleshooting steps or fixes would be greatly appreciated. I’m stumped! Here are two MIDI test files I recorded with it. One when it was working and the other being empty: Here’s the entire MIDI recording class:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, Thanks for the info. Your code is pretty strange... Let's look at the var inputDevice = _inputDevices.Last();
recording = new Recording(tempoMap, inputDevice); and nothing will change. And I suppose it's where your bug is placed. To check my assumption please change void Start()
{
tempoMap = TempoMap.Default;
_inputDevices = InputDevice.GetAll().ToArray();
foreach (var inputDevice in _inputDevices)
{
inputDevice.EventReceived += OnEventReceived;
inputDevice.StartEventsListening();
recording = new Recording(tempoMap, inputDevice);
}
}
private void OnEventReceived(object sender, MidiEventReceivedEventArgs e)
{
Debug.Log($"'{e.Event}' received from '{((MidiDevice)sender).Name}'");
} Also change public void StartRecording()
{
recording.Start();
Debug.Log($"Recording started on '{((InputDevice)recording.InputDevice).Name}'");
IsRecording = true;
} and public void StopRecording()
{
recording.Stop();
Debug.Log($"Recording stopped on '{((InputDevice)recording.InputDevice).Name}'");
NameDisplay nameDisplay = FindObjectOfType<NameDisplay>();
string name = nameDisplay?.GetCurrentName();
if (name != null)
{
SaveRecording(name);
}
else
{
Debug.LogError("NameDisplay is null or no current name available");
}
IsRecording = false;
} Now
And then send me the log from Unity. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Indeed you are correct and I see the issue now. By chance this code actually recorded the proper device at one time but I see that was extremely unlikely. ::picard_facepalm_here:: The intention was to listen to all devices but I need to manage separate Recording instances for each device. I think the way forward is to detect all the MIDI devices and list them in a dropdown for selection. Oops report>>> With your debug, when I had just an iConnectivity mio2 connected:
When I had both an iConnectivity mio2 and a Focusrite 18i20 connected and the events coming into the mio2:
After simply hard coding it to one of my MIDI interfaces the recordings saved properly. Thank you again for solving an issue for me. I can’t thank you enough for your library and personal time helping me get DryWetMIDI projects working. |
Beta Was this translation helpful? Give feedback.
Hi,
Thanks for the info. Your code is pretty strange...
Let's look at the
Start
method. Do you see that yourrecording
will always target last device of_inputDevices
? The wholeforeach
loop can be replaced withand nothing will change.
And I suppose it's where your bug is placed. To check my assumption please change
Start
method to this: