Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bi-directional sniffing/snooping on an ALSA MIDI SysEx exchange

Does anyone know of a good way to get a bi-directional dump of MIDI SysEx data on Linux? (between a Yamaha PSR-E413 MIDI keyboard and a copy of the Yamaha MusicSoft Downloader running in Wine)

I'd like to reverse-engineer the protocol used to copy MIDI files to and from my keyboard's internal memory and, to do that, I need to do some recording of valid exchanges between the two.

The utility does work in Wine (with a little nudging) but I don't want to have to rely on a cheap, un-scriptable app in Wine when I could be using a FUSE filesystem.

Here's the current state of things:

  • My keyboard connects to my PC via a built-in USB-MIDI bridge. USB dumpers/snoopers are a possibility, but I'd prefer to avoid them if possible. I don't want to have to decode yet another layer of protocol encoding before I even get started.
  • I run only Linux. However, if there really is no other option than a Windows-based dumper/snooper, I can try getting the USB 1.1 pass-through working on my WinXP VirtualBox VM.
  • I run bare ALSA for my audio system with dmix for waveform audio mixing.
    • If a sound server is necessary, I'm willing to experiment with JACK.
    • No PulseAudio please. It took long enough to excise it from my system.
  • If the process involves ALSA MIDI routing:
    • a virtual pass-through device I can select from inside the Downloader is preferred because it often only appears in an ALSA patch bay GUI like patchage an instant before it starts communicating with the keyboard.
    • Neither KMIDIMon nor GMIDIMonitor support snooping bi-directionally as far as I can tell.
    • virmidi isn't relevant and I haven't managed to get snd-seq-dummy working.
  • I I suppose I could patch ALSA to get dumps if I really must, but it's really an option of last resort.
    • The vast majority of my programming experience is in Python, PHP, Javascript, and shell script.
    • I have almost no experience programming in C.
    • I've never even seen a glimpse of kernel-mode code.
    • I'd prefer to keep my system stable and my uptime high.
like image 476
ssokolow Avatar asked Oct 09 '22 01:10

ssokolow


1 Answers

This question has been unanswered for some time and while I do not have an exact answer to your problem I maybe have something that can push you in the right direction (or maybe others with similar problems).

I had a similar albeit less complex problem when I wanted to sniff the data used to set and read presets on an Akai LPK25 MIDI keyboard. Similar to your setup the software to setup the keyboard can run in Wine but I also had no luck in finding a sniffer setup for Linux.

For the lack of an existing solution I rolled my own using ALSA MIDI routing over virmidi ports. I understand why you see them as useless because without additional software they cannot help at sniffing MIDI traffic.

My solution was programming a MIDI relay/bridge in Java where I read input from a virmidi port, display the data and send it further to the keyboard. The answer from the keyboard (if any) is also read, displayed and finally transmitted back to the virmidi port. The application in Wine can be setup to use the virmidi port for communication and in theory this process is completely transparent (except for potential latency issues). The application is written in a generic way and not hardcoded to my problem.

I was only dealing with SysEx messages of about 20 bytes length so I am not sure how well the software works for sniffing the transfer of large amounts of data. But maybe you can modify it / write your own program following the example.

Sources available here: https://github.com/hiben/MIDISpy

(Java 1.6, ant build file included, source is under BSD license)

like image 131
hiben Avatar answered Oct 12 '22 20:10

hiben