Batch Transpose: Get proper access to the Musescore object model when opening file with plugin

• Oct 31, 2022 - 09:43

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?


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 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 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 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 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 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...

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 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 ...

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