If you looked at the prior versions (starting Musical Pi – First Look ) you get the idea of a sheet music display program. Well, I went off on a real tangent.
We have a player piano. It seems such a shame to have a smart computer displaying sheet music that does not capitalize on the player system. It does midi, both input from the keys, and output can drive the player. With today’s notational systems (e.g. Sibelius, Musescore, Lillypond, etc.), you can turn out both nice sheet music, PDF’s of it, and also a midi output that is playable. It may lack some of the artistic flare of a good pianist, but what it has is perfect execution and timing, and it is controllable. A student can slow down a complicated passage, and listen to it over and over, to understand the proper timing. Sure, a piano student should know how to count it out, but there’s no substitute for actually hearing it. Slowly.
So I set off to add a midi player to the MusicalPi program. In concept it looks to see if a PDF for a song also has a midi file associated with it, and if so offers to play it for you. Calibre was happy to accept midi files, so this was going to prove easy, right?
I expected to find a large number of midi library implementations, all ready to go, since it is so central to the music industry (which often thrives off of open source). Well, not so much. What I found were lots of midi sequencers and records, i.e. software like MTS (http://www.multitrackstudio.com/) which are complete midi (and audio) editors. Lots and lots of them. There were also a few standalone players (e.g. command line type), which would play a file, but not let you control the playback easily. What I wanted was a simple, controllable player, where I could say “play from measure 52 at half speed”.
The one I found first was a very old product called TSE3 (http://tse3.sourceforge.net/). I spent weeks with it. It was abandonware – no longer maintained by the author, but still out there, still used by some libraries and utilities. It was also fairly well documented and complete, so I decided to try it.
Short version: Big mistake. Besides needing to be patched to even compile (should have been a hint), parts of it just plain did not work, especially the scaling for tempo. Played at full speed, things would go along reasonably well; reduce it to half, and the sequencer would get all hung up. It also would simply not play some songs, period (even its demo player). I kept getting closer and closer, hoping I could patch it, and finally gave up.
Throughout my searching, I kept running across ALSA (http://www.alsa-project.org/main/index.php/Main_Page), which is one of the main music systems on linux. It had a midi sequencer. Could I use it? The problem was it would not read a Midi file by itself. I finally ran across a midi file reader, that would not play (https://github.com/craigsapp/midifile) and decided to take the plunge and do a separate file reader, and player.
The result, after many false starts, works.
You can adjust volume and tempo, and the player system honors it quite nicely.
In pursuing this, I also discovered a nice piece of software called qmidinet (https://qmidinet.sourceforge.io/). This lets you have a midi device on one computer, and access it from another. It means I can do development in a fast hyperv VM while still connected remotely to my piano. Good stuff.
I am now looking into being able to also capture recordings from the piano, so the pianist can record, and loop it back to play and hear what they sound like. Scary, huh?
In the meantime I have done a lot of cleanup, added individualized playlists (including storing them in Calibre and updating from the touchscreen).
All this is committed to github if anyone wants to try it. Shortly I plan to do a cleanup pass and then label it a version 1.0 release. As always comments and input at the github site welcome (https://github.com/Linwood-F/MusicalPi )