Batch Transpose: Get proper access to the Musescore object model when opening file with plugin
We have made 1000nds of note using Muse score. We would like to auto transpose them to other keys such as Bb for clarinets and trumpets or Eb for alto saxophones.
The easy way to do it would be using a muse score plugin.
such as cmd("select-all"); and cmd("transpose-up"), but these commends does not work when the document is opened with the plugin. It is not possible to select and manipulate the note system when a mscz file is opened via macro.
Is there any method I should use that I don't know about? Or is it just impossible what I want to achieve?
Enclosed script opens a file, tries to get access to manipulate the note structure and export the note as SVG (or Png), but it does not work.
Is there another way?
Attachment | Size |
---|---|
auto_open_file_and_transpose_and_export.qml | 4.86 KB |
Comments
With cmd("next-score") sandwiched between startCmd & endCmd you can make the plugin process multiple files, but beware: next-score cycles back to the first score
To stop it have e.g. an empty score (1 measure) leftmost and run while (mcount != 1)
I managed to open and process 35 lead sheets at a time without problems…
In reply to With cmd("next-score")… by elsewhere
Thank you for input elsewhere . But it does not solve my issue.
I have hundreds of documents, and want to open them dynamically one by one
Do somthing (in this case transpose and export an Svg-file)
Then close the document and go to the next.
The problem is that the "cmd" does not work on a document opened by a plugin
In reply to Thank you for input. But it… by oleviolin_
Maybe I'm missing something, but I don't see the endCmd() in your plugin.
In reply to Thank you for input. But it… by oleviolin_
For what it is worth...
With:
thisScore = readScore(fileName,false) // instead of true
thisScore.endCmd(); after cmd("select-all");
e.notes[0].pitch=e.notes[0].pitch;
e.notes[0].tpc=e.notes[0].tpc;
(Also put your own params in fileName & targetFile)
the score becomes visible and is transposed, but:
the intput score is also changed, and you are asked if you want to save it.
tpcs are not correct
modified_auto_open_file_and_transpose_and_export.qml
In reply to For what it is worth... With… by elsewhere
Thanks elsewhere. I think I got the concept now. (And it is working!! which is great!!)
No problem pressing the Don't save button 670 times. Since it is do-once job for our team to add Bb notation.
When I finished the project, I would like to start updating the plugin manual, making it easier for newbee's like myself to get started making these kind of plugins.
In reply to Thanks elsewhere. I think I… by oleviolin_
You could attempt to cmd("undo") to make the original score "clean" again and perhaps not have the Save question popup.