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.
In reply to You could attempt to cmd(… by jeetee
Worked ! THANK YOU !!
This sounds very helpful! :)
How does it work? tried to install it via the plugin-Manager but it seems to do nothing.
In reply to This sounds very helpful! :)… by Elquieto
And, does it work for Eb instruments as well?
In reply to And, does it work for Eb… by Elquieto
If you are on MU3.6 run the plugin from the plugin creator window and/or try my Batchtranspose plugins:
https://musescore.org/en/project/batch-transpose
If you are on MU4 let me know. I can try to adapt the plugins but cannot guarantee success...
In reply to If you are on MU3.6 run the… by elsewhere
I'm still at 3.6.
Hm... seems to be a bit tricky, cant get the cript to work properly. I tried to run it from the plugin-Window, but somehow i get a "path Error for a testin.mscz"...I'm afraid I'm doing something wrong from scratch, i have very little experience with PlugInScripts :*( ...
Hm...any recommendations for a batch transpose plug in? I try to do sheets for a private session, and it would be a great TIme saver to have a Transpose Plugin that does an more or less automated Export for Bb and Eb Instruments.
In reply to I'm still at 3.6. Hm… by Elquieto
As I mentioned above:
"Also put your own params in fileName & targetFile", ie you have to open the plugin in a text only editor, find filename & targetfile & put your paths there, scary if you have never done this, but try it. At worst you'll get another errror.
As I wrote above: try the batch transpose plugin (EDIT: I mean the BatchTranspose2.qml plugin). All you have to do is adjust the interval, as explained on the plugin page (read the whole page). If you post a sample score I can try it for you to see if it works...
In reply to As I mentioned above: "Also… by elsewhere
ah, okay. I made it, supposedly... it had to be run in from the PlugIn-Editor (Strg/shift+P), i didnt realize that.
I'm going to check around a little bit and give a feedback. So far only Version 3 seem to Transpose Chords as well?...
Thanks for this code! I was able to adapt it for batch transposing. As you can see, it's very kludgy, every file is invoked explicitly, and I run it 'interactively' in Plugin Creator. But it works in v3.7 on Windows 10. The attached example converts a bunch of Bb scores to concert. I used Excel to concatenate the file listings with the subroutine call. I use C# and the DOM on the MSCX files to re-label, and a CMD file that calls Musescore repeatedly, iterating through the files to export PDF.
So yes, kludge upon kludge
Suggestions welcome ...
In reply to Thanks for this code! I was… by BanjoJake
Thanks, useful stuff. Do you run it from the command line or from the GUI? Were you able to make it work on v4.x? Were you able to automate the generation of file names?
In reply to Thanks, useful stuff. Do you… by opinsky
I usually run it from Plugin Creator which makes it easier to keep an eye on what's going on. 4.x doesn't really support plugins yet, so I didn't even try. The script automatically generates a file name for the transposed MSCX based on the list which I generate from a directory listing. Let me know if additional questions ...
In reply to I usually run it from Plugin… by BanjoJake
CORRECTION: I don't think it works at all from the command-line, that's why I run it from Plugin Creator. See: musescore.org/en/node/350015