Examples of Music21 web programming?

72 views
Skip to first unread message

Daniel McGillicuddy

unread,
Jan 12, 2023, 1:06:22 PM1/12/23
to music21
Hello All,

I am interested in using Music21 to make a webapp, but not sure exactly how it all ties together, and was wondering if anyone has done something like this before?

I would like to:
1) Let a user select an XML file
2) Process that file using various Music21 functions I have written, perhaps even letting the user select which ones to process the file with.
3) Return an XML file to the user with the result of the processing.

It can all be via XML and does not have to present any rendered notation to the user, it is really about the processing.

Not sure how to go about this...Django? Flask? What elements need to be included in order to execute Music21 remotely and return the XML results.

Thanks for any advice or examples!
Daniel

David De Sa

unread,
Jan 12, 2023, 6:49:12 PM1/12/23
to music21
I think my use case might be informative for you as to what can be done:

https://colab.research.google.com/drive/1JZIfOKR-A_mcXLnaw_KfumrgjOGMTYv3
1st link is to a google colab space: free hosting from google where anyone can run your code.
2nd link is to a little youtube video explaining how to use the interface.

Basically, the gradio python package is a fantastic tool for building interfaces. I would recommend using HuggingFaceSpaces to host your Gradio interface on a continuous basis (zero friction to user experience, just dragging and dropping files). I used Google Colab to host it only because getting the audio playback and notation visualization to work required some back-end configuration changes executed through code that I just couldn't figure out how to do in HFS.

Anyway I hope the code can be informative.

Muse Score

unread,
Jan 13, 2023, 4:49:49 AM1/13/23
to music...@googlegroups.com
Hello Daniel,

I have done something similar: http://musescore1983.pythonanywhere.com/ It is a web-form to upload midi or musicxml and download musicxml after some processing.
With this app I have done for example this piece: https://www.youtube.com/watch?v=WjOcuflV6uM But don't expect it to work on random midi or musicxml.

The processing is as you described it: Flask-App running on pythonanywhere which I can recommend for starting projects.

Maybe if there is interest, I can share the python code, as I am not maintaining the site any more actively.

Kind regards


--
--
To Post: email music...@googlegroups.com
To Unsubscribe: email music21list...@googlegroups.com
Archives, Options, etc: http://groups.google.com/group/music21list

---
You received this message because you are subscribed to the Google Groups "music21" group.
To unsubscribe from this group and stop receiving emails from it, send an email to music21list...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/music21list/888d48ba-b040-4c86-8e33-faebd61eefaan%40googlegroups.com.

Daniel McGillicuddy

unread,
Jan 13, 2023, 12:59:17 PM1/13/23
to music21
I would be very interested in seeing the Flask container, that is the part I have never done before, I have several relatively complicated Music21 scripts but have never put them together as an app or to be executed via the web before. I am especially interested in how you did that, if there was any Musescore integration and the .zipping you did for the results. Looks great, lots of functionality I am trying to understand how to implement myself. Thanks for the example!

Daniel

Muse Score

unread,
Jan 14, 2023, 2:50:33 AM1/14/23
to music...@googlegroups.com
Hi Daniel,

Please find attached the source code https://github.com/githubuser1983/music21_example_webapp for the webapp linked above. It would be nice, if you like to, that you share also your work openly, but this is not a must, only if you like to! :-)
The source code was mainly written for myself, and it was not intended for another developer to look at it, but here you go, I hope it helps.

mahatGma

unread,
Feb 5, 2023, 12:23:51 PM2/5/23
to music21
Hi there, 

I have used music21 for this project:

Although before deployment. I scanned all chorales from Bach corpus, marked fermata points, identified chord type and encode progressions between fermata points into a text file with various details. To encode MusicXML files I've used scamp library and to correct accidental issues mscore commands. 

Reply all
Reply to author
Forward
0 new messages