kosua20 / MIDIVisualizer

A small MIDI visualizer tool, using OpenGL
MIT License
1.02k stars 136 forks source link

Inaccurate Render w/ Virtual MIDI Device #139

Open tabcodes opened 1 year ago

tabcodes commented 1 year ago

First of all, this is some truly phenomenal work- I'm blown away by how well it works and how clean the UI and effects are. Tremendous work!

I'm not sure if the problem lies directly with the visualizer, but here's the context: I wanted to use my MIDI keyboard with the visualizer, and with a DAW so I can hear the sound output from the piano as well as seeing it on the visualizer. However, predictably, trying to set MIDI Visualizer to use a device already in use by another program causes it to crash. To get this done, I have my DAW set to take input from the hardware (my keyboard), and output it to a virtual MIDI device I created (using the snd-virmidi module). I then set the device in MIDI Visualizer to the virtual device, and voi-la, it works.... almost!

Describe the issue Once I start playing the keyboard, the notes rendered have some issues. For example, keys and notes are shown to be "active" when in reality I only hit them once, and without further input, they stay that way (see GIF below). Also, occasionally it will render keys/notes that I haven't touched, even when I haven't touched any keys at all. Finally, sometimes seemingly random keys/notes appear on the render when I haven't touched any notes close to them. How fast I play the notes may have some effect, as it happens much more at faster pace or with chords, but while it's an extremely consistent problem, how it presents is not.

The GIF below was taken while I was only playing the lowest-octave C-scale (furthest left on the keyboard). The first two, fairly slow tries, it didn't happen, but the third one (at a slightly faster pace) threw the entire rendering into chaos. As described, notes far off from what I was playing are highlighted and stay that way. Peek 2023-04-30 09-43

Initially, I thought this to be the fault of my DAW (LMMS is what I use), but I also tested it against VMPK and the same issue presents itself. Notably, if I use the actual hardware device direct to the visualizer, the issue does not occur, as seen below- I can testify that in this case, the render was 100% accurate:

vis-good

FWIW- I also tested the same LMMS/Visualizer setup on Windows and it works perfectly. Let me know if there's anything I can do to help sort this out- I absolutely love this thing and can't wait to make more use of it!

Hardware info:

kosua20 commented 1 year ago

Hello! First of all, huge thanks for this extremely detailed report! Based on the problem you are describing, I would suspect an issue with either my code for "live mode" or the backend I'm using to receive MIDI messages from live devices (libremidi, which is itself using ALSA on Linux if I recall correctly). The fact that it's only present on Linux could point towards the backend as the code in MIDIVisualizer is the same for both platforms.

One thing you can try is to enable the debug mode in MIDIVisualizer : after starting the application, press the 'D' key on your computer keyboard, a small menu should pop at the bottom of the settings panel.

Menu screenshot

If you check "Verbose log" before connecting to the device and start playing, it should log in the console all MIDI messages received from the device. That way we can check if MIDIVisualizer received unexpected messages or not.

tabcodes commented 1 year ago

Sorry for the lack of response here- I'll get some debug output posted this weekend. Thanks!