Plugin request: export every n bars as a separate mscz file

• Oct 30, 2024 - 13:51

Hello,
I'm interested to know if it's possible to create a plugin that exports every 2, 3, 4 etc bars of a musescore file as a separate mscz file. It would save me a great deal of time to have a plugin like this and I would be willing to pay for the work involved provided I can afford the quote given.

Additional features that would be a bonus but not essential:
- Automatically name each output file '(Title of original file) + (n bar chunk x)' e.g output file that contained the first 3 bars from original score would be called 'Moon River 3 bar chunk 1'
- Retain the bpm indicated at the beginning of the score in all of the output files


Comments

It would be possible in a MS3 plugin, including the additional features that you mention although care would need to be taken with tempo because this can be changed at any point in a score. I don't use MS4 so can't comment.

In reply to by mattwosere1

I'm currently already working on a couple of plugins so don't have any time for another one just yet. Like the main MS program, plugins are typically provided without any charge. It's one of the nice things about the MS community.

Maybe someone else will pick this up before I get round to it. If you have any coding skills I can point you in the right direction.

Score Chunker 1.0

Select:

• Chunk Size
• Excess Size (adds to chunk size if this would complete the score)
• Chunk Suffix (default is M)

I recommend copying your master score to a separate chunking folder for all the chunks - and just in case of any bugs.
Works with multiple staves but haven't tested with parts.
More staves + more measures = slower process because there's more to do but it's pretty quick.

Here's an example output:

ScoreChunker.png

ScoreChunker 1.0.qml

In reply to by yonah_ag

This is amazing, thank you so much! Especially as I was about to report back on the total failures of getting chatgpt to add a step to its code that kept the original tempo.
Seems to all work for me as I've opened up the qml via plugin creator and it gives the window you posted as an image. Just wondering where I should expect to find the output files?

In reply to by mattwosere1

The output files are saved to the same folder as the input score being processed. I have made a separate folder where I copy a score to since I don't want all the chunk files in with my main scores. (This also ensure that the plugin cannot touch your original score in any way, which is always a good initial precaution with plugins!)

I run it from the main plugin menu:

ScoreChunker.png

The plugin could have options to open any/all of the chunks after processing which might be useful to show that processing has finished. It could open the first chunk and then provide a navigation button to the next chunk etc.

You can obviously chunk the same score with different parameters and use a different suffix:

ScoreChunkerA.png

The chunking parameters could be saved to the chunks so that forward/backward navigation would be possible without having to regenerate the chunks every time.

If the tempo changes during the score then these changes will be reflected in the chunks when the chunking parameters co-incide with the tempo changes; otherwise there will need to be some extra tempo changes inserted, even if they are made invisible.

In reply to by mattwosere1

It looks like the ChatGPT approach builds a new score from scratch, which might accound for the loss of tempo setting. My plugin 'tops-and-tails' the score to make each chunk; saves the chunk then undoes the 'top-and-tail' to restore the master score ready for the next chunk. This way everything gets saved with the chunks: header frame, score image, footer frame, stave texts etc.

In reply to by yonah_ag

Thanks for this revision. Here are the steps I've taken to try and resolve the missing files issue:
-moved the qml from downloads to C:\Users\matt0\Documents\MuseScore3\Plugins .
- uninstalled and reinstalled musescore 3 so I now have the version shown in the png.
- created a new test score in that version of ms
- updated window for version 1.1 shows the 'navigate' button however 'chunking...' does finish after pressing 'chunk score'.
-restarted the pc (because that's all I can think of lol)

I've also managed to get python code from chatgpt to change the tempo of each of file that does work this time. The issue was that the bars in the segmented files kept the bar number they had in the original score. So the code was putting in a tempo marking at bar 1 for each file but only the first chunk had a bar 1 so that was the only file it worked for. As a (very messy) work around I asked for code that put the tempo marking for every bar haha!

So I have a very messy substitute for now but if you're happy to keep working on this I would still be very grateful. Thanks again.

Attachment Size
musescore version.PNG 13.12 KB

In reply to by mattwosere1

Your version of MuseScore is way out of date so I'm guessing that its plugin API does not support the code that I'm using. I have no idea how you ended up on such a state-of-the-ark version when the final official incarnation of MS3 was 3.6.2.

However, there in an on-going development of MS3 known as MS3.7 Evolution which is so much better than 3.6.2 and maintained by well known MuseScore guru Jojo Schmitz. I reckon that installing either will solve the issue.

MS3.7 can open MS4 files and has bugfixes and enhancements.
Here is the official wiki for it:
https://github.com/Jojo-Schmitz/MuseScore/wiki/

If you prefer MS3.6.2 then it can be found in the official archive here:
https://ftp.osuosl.org/pub/musescore-nightlies/windows/3x/stable/

In reply to by mattwosere1

I don't think that MS3.7 will make any difference. I only have guitar tab scores so if you can create a short piano score which exhibits the problem and upload the .mscz file to this thread then I can take a look.

I can test it in 3.7 but I suspect my lack of experience with piano scores is most likely the root cause, i.e. bugs in the plugin.

3.6.2 and 3.7 can be installed on the same PC but I think that only 1 of them should be open at any time. I use 3.7 exclusively now and only keep 3.6.2 installed as a backup.

In reply to by mattwosere1

Thanks, I've downloaded that but I did not mean to invite you to share a score which is still under copyright, in this case by EMI Music. You should remove the score from your post in order to avoid the attention of copyright lawyers.

You can upload public domain material and I think that you can upload short excerpts of copyrighted material for discussion. Other than that you need permission from the copyright holder.

In reply to by yonah_ag

Only manually, putting the mscx into a text editor

      <Staff id="2">
        <StaffType group="pitched">
          <name>stdNormal</name>
          </StaffType>
        <hideWhenEmpty>3</hideWhenEmpty>
        </Staff>
 

vs.

      <Staff id="2">
        <StaffType group="pitched">
          <name>stdNormal</name>
          </StaffType>
        <defaultClef>F</defaultClef>
        </Staff>
 

If you delete a clef (either directly or along with the measure), it falls back to the previous clef, for the 1st meausure to its default clef, if there isn't any it falls back to treble clef

In reply to by Jojo-Schmitz

OK, it's the score that really has the bug but it's not apparent to the casual observer. MS cannot be expected to correct this faulty setup and neither can my plugin. (I do have plugins which resort to mscx processing but only when there are deficiencies in the plugin API).

Thanks for taking a look at this so quickly.

In reply to by mattwosere1

Does the plugin need to cope with this or is it something you can easily fix?

I have improved the code and am adding an option to navigate previously chunked scores, (i.e. without the need to re-chunk every time the plugin starts). This would allow manual tidy up of chunks to be retained which may be good for users, e.g. post-chunking layout improvements.

Would it be any use having a stave text on the first note of each score indicating which measures are included in the chunk?

In reply to by yonah_ag

The plugin is excellent and I've already started to use it for my teaching!
I don't know what's going on with the clefs when musicxml files are converted to mscz. The same thing happens with those kind of files when you try to 'save selection' as I mentioned before (or at least that's what I think is going on with the 'somewhere' score). But it's no issue because the python code can work with the musicxmls and the only reason I have so many musicxmls is because I've been slowly transitioning from Sibelius to Musescore.

Stave text with bar range on the first note of each score is not something I had in mind but that's not to say it could be useful to other users.

This outcome is already far better than I was expecting. Thank you so much!

In reply to by mattwosere1

One fix for 2 x treble-clef scores is:
1) Open score in MuseScore
2) Use "I"nstrument to add a piano (treble and bass clefs)
3) Select all the original measures
4) Copy/Paste to the new empty piano measures
5) Use "I"nstument to remove the original staves
Now you have a score with the piano set up correctly.

In reply to by mattwosere1

The theoretical limit appears to be over 4,000,000,000 but after 10,000 things can slow down:
https://stackoverflow.com/questions/5384187/how-many-files-is-most-advi…
It's an old post but Windows 11 is still running NTFS.

If would be easy to mod the plugin so that the suffix was used as a subfoler name rather than a filename suffix. You could then have all your scores together and all the chunks organised into batches below the scores folder, either by number of chunks, or by composer, etc.

In reply to by yonah_ag

I would also add to this that if the trend with Musescore continues, I think they will eventually dethrone Sibelius as the dominant notation software in the music education sector - though there's still a lot of work for them to do - and plugins like this will become useful to more and more people. Interestingly, Piano Marvel already have a feature that puts scores into smaller practice chunks but their software, only being compatible with midi capable pianos, rules them out for a lot of people including myself. Your plugin has the versatility that can go with multiple apps or any new app that might emerge in the not-too-distant future.

In reply to by mattwosere1

Hopefully the plugin API in MuseScore 4 will soon get some much needed attention as it is so far behind that of MS3, which itself has many limitations. Most of my plugins cannot yet be ported to MS4.

There is a major learning curve involved in developing the main MuseScore software, (in C++), so a good plugin api opens up the possibility of adding significant functionality to many more developers with a much less steep learning curve.

In reply to by mattwosere1

@mattwosere1 wrote:

> Piano Marvel already has a feature that puts scores into smaller practice chunks

Is your primary goal to have the option to loop specific sections for practicing along?

If so, I have some preliminary designs regarding that functionality.

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