Plugin request: export every n bars as a separate mscz file
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 It would be possible in a… by yonah_ag
Great! yes a MS3 plugin would also be fine.
In reply to Great! yes a MS3 plugin… 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.
In reply to I'm currently already… by yonah_ag
Yes it is a nice community, I've only just entered the musescoreverse but wish I'd joined sooner. I don't have any coding skills unfortunately.
In reply to Great! yes a MS3 plugin… by mattwosere1
Incidentally, why do you split up scores in this way?
In reply to Incidentally, why do you… by yonah_ag
I'll DM you
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 1.0.qml
In reply to Score Chunker 1.0 Select •… 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 This is amazing, thank you… 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:
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:
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 The output files are in the… by yonah_ag
I'm not seeing the output files after running it from the main plugin menu at the moment. Will try some more troubleshooting and get back to you.
In reply to I'm not seeing the output… by mattwosere1
How odd. Do you get them when running from the plugin creator?
In reply to I'm not seeing the output… by mattwosere1
What OS are you on, and which version of MuseScore?
In reply to I'm not seeing the output… by mattwosere1
You could upload a score and I'll test it, (non-copyrighted or only an excerpt.)
In reply to This is amazing, thank you… 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 This is amazing, thank you… by mattwosere1
There is definitely room for improvement.
• Manual stave/page breaks are retained which can give odd layouts.
• Bar numbers start from 1 in each chunk.
Maybe you will find other suggestions for improvement.
It's usually quite easy to add options to plugins.
Score Chunker 1.1 adds Chunk Navigation
ScoreChunker 1.1.qml
In reply to Score Chunker 1.1 add Chunk… 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.
In reply to Thanks for this revision… 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 You version of MuseScore is… by yonah_ag
Yes brilliant it works with MS3.6.2! The only issue is there are two treble clefs in the segmented piano scores that were written originally with treble and bass clef. I'll install MS3.7 as that might have the debugs which resolves it.
In reply to Yes brilliant it works with… 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 I don't think that MS3.7… by yonah_ag
Edit: here's a one that I've been testing with.
In reply to Sure, here's the one I… 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 Thanks, I've downloaded that… by yonah_ag
I've just tested the chunker on the (copyright free) 2 5 1 exercise and it kept the original clefs this time! No idea why but it's very good!
In reply to I've just tested the chunker… by mattwosere1
I'll test that too. I can reproduce the issue with "Somewhere..." and it appears that the problem occurs on every chunk apart form the first. This is a useful clue.
In reply to I'll test that too. I can… by yonah_ag
Just tested Harmonic 251 and with interesting results: it works perfectly for every chunk. The plot thickens.
In reply to Yes brilliant it works with… by mattwosere1
When the bass clef gets changed to treble clef, are the notes still actually correct?
In reply to When the bass clef gets… by yonah_ag
Yes indeed
In reply to Yes brilliant it works with… by mattwosere1
It looks a bug in MS3.
Here's a sequence which I tried manually, (i.e. no plugin involvement) :
Initial score
Select first measure
Press Control-Delete
Oops!
In reply to It looks a bug in MS3. Here… by yonah_ag
Issue raised on GitHub:
https://github.com/Jojo-Schmitz/MuseScore/issues/686
In reply to Issue raised on GitHub:… by yonah_ag
Not a bug, that score's 2nd staff has a treble clef that got changed to a bass clef.
Removing that, alone or along with the 1st measure, resurfaces the treble clef
In reply to Not a bug, that score's 2nd… by Jojo-Schmitz
Is there any way to fix such a staff?
In reply to Is there any way to fix such… by yonah_ag
Only manually, putting the mscx into a text editor
vs.
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 Only manually, putting the… 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 OK, it's the score that… by yonah_ag
'Somewhere' was written in sibelius, exported as a music xml, opened with ms4 and saved with either ms3 or 4 (I cannot remember.
251 harmonic minor was written with ms3 or 4.
In reply to 'Somewhere' was written in… 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 Does the plugin need to cope… 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 The plugin is excellent and… 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 One fix for 2 x treble-clef… by yonah_ag
Or
1) Open score in MuseScore
2) Use "I"nstrument to add a staff to the 1st staff (not the 2nd). Verify that is lists as having a bass clef
3) Select the original measures in bottom
4) Copy/Paste to the new staff above
5) Use "I"nstument to remove the bottom staff
In reply to Or 1) Open score in… by Jojo-Schmitz
Thank you and thanks for MS3.7!
In reply to One fix for 2 x treble-clef… by yonah_ag
Brilliant! Thanks for this.
In reply to Brilliant! Thanks for this. by mattwosere1
Released plugin as 1.2 which selects navigation mode automatically when the score is already a chunk.
https://musescore.org/en/project/score-chunker
In reply to Released plugin as 1.2 which… by yonah_ag
Fantastic! I now have hundreds (soon to be thousands) of chunks!
In reply to Fantastic! I now have… by mattwosere1
Wow! That's a lot. Are you giving each score its own folder? (Just wondering whether there is any OS limit on the number of files per folder).
In reply to Wow! That's a lot. Are you… by yonah_ag
No, but that's a good idea at this point!
In reply to No, but that's a good idea… 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 The theoretical limit… by yonah_ag
Thanks. I'm just able to handle all of the chunks right now. There is a small issue with the lack of options to organise them once they're uploaded to the platform. But that is beyond my control.
In reply to Thanks. I'm just able to… by mattwosere1
At least they are named so that they sort in playing order.
@yonah thanks for your work that you share with the community, it's really great 👍
In reply to @yonah thanks for your work… by frfancha
+1
In reply to @yonah thanks for your work… by frfancha
You're welcome!
In reply to You're welcome! 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 I would also add to this… 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 I would also add to this… 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.
In reply to > Piano Marvel already has a… by scorster
Nah it's not that, thanks. I've got what I need thanks to Yonah!