generating mscx file

• Dec 19, 2019 - 15:08

Dear all,

For some projects I'm doing algorithmic composition and I need to generate scores.
In previous projects I've worked it out by generating MIDI files and importing them into Musescore. But now I have a more complex outcome, and in my tests the imported files are missing some very basic info in the resulting score (e.g. correct time placement). I guess this is intrinsically related to the way MIDI encodes time.
So, before switching to lilypond, I was trying to understand if I can generate mscx file.
Is there a specification anywhere? I can't find it.
Has anyone tried to generated mscx files from code?
Thanks
-a-


Comments

You could use the Batch Convert plugin, or the -j files.json commandline option any a suitable json file
Ot the -o mscxfile.mscx midifile.mid commandline option

In reply to by Andrea Valle

I looked for a format spec for ms3 mscx files a while back but couldn't find one. However, you can reverse engineer them by using a score of increasing complexity and inspecting the results. Depending on how complex your needs are this may be a viable solution for programmed composition.

Without knowing more about your project, it's difficult for me to imagine why you wouldn't use the standardized MusicXML format. It's well-documented, supported by MuseScore and most other notation programs, can be directly exported by music21 and probably other programming toolkits for music, and it doesn't tend to change radically.

In reply to by [DELETED] 1831606

I'm wondering whether the direct mscx approach would yield cleaner imported results. For example, when I import a MusicXML TAB from GP6 it ends up in MS3 with the word TAB at the start of every bar, which I then have to select and delete.

Why do programs such as MuseScore, Guitar Pro etc. use their own formats rather than use MusicXML as a native format?

In reply to by yonah_ag

Programs such as MuseScore use their own formats because they can do many more things than music XML can express, and do not want to be limited its definition. And they want to be able to grow and add new capabilities, which would be ruled out by that constraint. I assure you there is nothing in the definition of musicxml that puts the word "TAB" where you saw it. See https://www.musicxml.com/ for the definition of the standard.

In reply to by Jojo-Schmitz

(To yonah and OP) Nothing of the sort proposed should require familiarity with, let alone modification of, the code or internal logic of MS. The discussion is about a transaction in the coinage of music, not a change to the way MuseScore operates.

In reply to by [DELETED] 1831606

I will write a standalone program but I just wondered if MS provided any hooks for including external user code. Calibre, a well known eBook manager/converter written in Python, provides many opportunities for user plugin code without having to mod the main program. So if MS had been similar then I could've called my external code automatically on opening a MusicXML file.

In reply to by yonah_ag

Being "familiar with javascript" is not enough. You have to learn the QML interface language, which is expressed in Javascript, and the Musescore plugin API, which is expressed in that. It's nontrivial. What you propose really doesn't make architectural sense. You can write a plugin which runs after the XML has been opened, and simply deletes any staff text element whose content is "TAB". But, as I said, you still have to learn all those levels. It is much easier to read the XML with a language of your choice, delete elements you don't like and write it back. Involving MuseScore seems wrong.

In reply to by yonah_ag

And as I said, using music21 will simplify this immensely - it already knows MusicXML and can build you a complete representation of your score in nicely organized musically aware data structures in like two lines of code. trying to write almighty. To todo the same would be hundreds if not thousands of lines of code, not to mention the work learning the format, designing your own data structures, etc.

In reply to by Marc Sabatella

That's overbroad. It would be as trivial, if not more, to read the MusicXML with any general xml-reading tool (e.g, elementTree), find all the whatevers son of whatevers whose whatever is whatever with exactly one CSS-directed call, and remove them from their parents in two more lines (without learning music21's representation formalism).

In reply to by [DELETED] 1831606

If it's literally only doing one operation fiddling with all elements of a given type, OK, sure. But the original thread here is about algorithmic composition. And it's not all clear what the perceived problem with GP's output really is and whether fixing it would really be as simple as that. So music21 is still going to be a huge benefit in the general case, even if there is the occasional task for which a "sed" script is sufficient.

In reply to by [DELETED] 1831606

I'll probably have a play with music xml from Python and VB. How can I tell if the artifacts produced by using MusicXML between GP and MS are caused by GP or MS. I don't mean to hijack this thread but I am very interested in import/export with MS as the MS Android App is dreadful with TAB and I want a viable alternative.

Your example score certainly looks clean enough.

Hola Andrea,
Did you solve your problem? I do not know if we have the same idea. I would like to generate a mscx outside musescore. For instance from Python, R, Mathematica or other similar computation environment. Environments where I can develop programs for automatic composition. Do we have the same situation? Did you solve your doubts? Thanks for your time. Eduardo Uresti

In reply to by eduardo.uresti

You can certainly generate MSCX files programmatically, at least for MS3.6.2 since the format is now fixed. I use Excel with VBA to inspect and modify MSCX scores as an alternative to plugins, which can be useful when an element is not available via the plugin API.

MS4 should be possible too but I'm not familiar with the format.

Do you still have an unanswered question? Please log in first to post your question.