blog.humaneguitarist.org

MuSEarch: searching within embedded MuseScore.com scores

[Fri, 26 Dec 2014 20:56:41 +0000]
OK, gonna try and keep this short. I've been obsessing the last few days over the Christmas holiday on this micro-project/demo ... i.e. I been working from morning until midday and taking a shower and brushing my teeth only well, well past the afternoon. Don't judge. I start a new job in January (more later) and, while it will require a good deal of technical know-how, coding won't be part of my job. That's fine, I don't need work to keep me working, so to speak. I thought I'd get back to programming music-related stuff. It's been a while since I checked out MuseScore.com so I did. They now have this nice feature where you can upload a score from MuseScore and then you can read and listen online (with score-following). And you can embed the score into your own pages. Anyway, I wanted to play around with a demo for being able to search the music data and then go to a specific measure - with the measure getting highlighted when selected from the search results. So, here's my demo requirements and what I did for my chosen score, "Lascia ch'io pianga [https://musescore.com/user/202630/scores/191220]" from Handel's Rinaldo. I first heard the piece when I saw Farinelli [http://en.wikipedia.org/wiki/Farinelli_%28film%29] back in the days. Requirements 1. Read the compressed MusicXML version of the score; index the note names (no sharps/flats [DEL: or rests :DEL] , etc.) in each measure into a SQLite database along with the measure number. 2. Read the MuseScore.com "div" element which has the position coordinates for each measure against the score image; index the page and measure numbers. 3. Create an API that takes an ordered series of notes (e.g. "eee") and returns a JSON response with the page and measure numbers as well as all the notes for all measures starting with that series of notes. Example JSON: [{"page":1,"measure":1,"notes":"EEE"},{"page":1,"measure":15,"notes":"EEE"}] 4. Embed the score in an HTML page where one can type in a note or a series or notes, click on a result, and be "taken" to that measure. I did steps 1 and 2 in Python, 3 in PHP, and 4 with jQuery, Knockout, and Bootstrap. I also had to embed the score via PHP-proxy because I found out that JavaScript scrolling in an iframe-embed from another domain doesn't work (right?). I may post the Python code on my blog at a later date, but I really need to eat an early dinner ... so I might as well wait until after that to brush my teeth. Before I link to the demo, let me say that this is just a demo and I'm not looking to do anything to tick off the MuseScore crew. I probably shouldn't be proxying the score embed, but I needed to for the demo. What I'd really like to see is something like this in MuseScore.com itself. [DEL: And maybe even an API for the embedded score, if there's not already one (I didn't see anything about that). :DEL] Update: OK, I'm completely blind. Here's the API docs: http://developers.musescore.com/ [http://developers.musescore.com/]. I'll need to, at some point, work on the backend of this demo so I can automate all processes with the API provided they will grant me an API key. I should also see what's up with Noteflight these days. They used to have an embed API and may still, but it's also been a while since I've looked at what they're up to. Anyway, here's the demo link: http://blog.humaneguitarist.org/uploads/musearch/musearch_example.html [http://blog.humaneguitarist.org/uploads/musearch/musearch_example.html]. Results * It seems to be working OK in my desktop versions of Firefox, Chrome, and Internet Explorer. * I couldn't get smooth-scrolling in the iframe-embed to work on Chrome, so I dropped it. That issue's out-of-scope for this demo. * Only Internet Explorer seems to be embedding the audio player but that, too, is not relevant for this demo. * On my Android, scrolling to the specific measure isn't working, so I need to look into that. But you can resize a desktop browser to the size of a small tablet or so and refresh the page to get an idea of what I want it to look like on mobile. * [DEL: A few times it seems that either something didn't get indexed (the last measure, for example) or the coordinates are off (or my JavaScript isn't parsing them correctly). But it's mostly working, so I don't care. :DEL] Update: OK, so I cared. I think this is fixed and that it was an offset bug in one of my Python scripts.[DEL: :DEL] I'm OK with the demo. I met my main goals. But ultimately, the real issue here is this ... What the hell is a useful search for music notation? I'm not sure learned musicians even need search. Isn't learning a piece and studying the score far more revealing than searching for pitches and potentially durations and intervals, etc.? But tech is tech and research is research, and you know people are going to work on this stuff because it's intriguing at the least.