/* MuseScore Plugin: Score Chunker
*
* Copyright © 2024 yonah_ag
*
* This program is free software; you can redistribute it or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation and appearing in the accompanying LICENSE file.
*
* Description
* -----------
* Split a score into batches of measures
*
* 04 Nov 2024 | 1.0 | Initial Release
*/
import QtQuick 2.2
import QtQuick.Controls 1.5
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import FileIO 3.0
import MuseScore 3.0
MuseScore
{
version: "1.0"
description: "Score Chunker"
menuPath: "Plugins.Score Chunker"
requiresScore: true
pluginType: "dialog"
// Global variables
property var zLog : true // view process log only
property var tlog : "" // text output log line
property var nofS : 0 // no. of staves
property var nofM : 0 // no. of measures
property var nofX : 0 // no. of map entries
property var nofC : 0 // no. of chunks
property var tickEnd : 0 // end of score tick
property var msPath : ""
property var msFile : ""
property var tout : "" // text output file
// Score Map
property var mIX : [] // Map index
property var mMez : [] // Measure
property var mTick : [] // Segment ticj
// Chunk Map
property var cIX : []
property var cMez : []
property var cTick : []
property var cMoz : []
property var cTock : []
FileIO { id: fid; source: msPath }
// onRun: {}
//=================================================================================================================================
function chunkScore()
{
var ii =0;
var nun = 0; // no. of undos required
var nix = 0; // maximum index
var nox = 0; // padding formatter
var tMez = "";
var tMoz = "";
var chuf = txtChunk.text;
var msChuf = "" // Path to .mscz chunk
mapScore();
mapChunks();
msPath = curScore.path.substring(0, curScore.path.lastIndexOf("/")+1) + curScore.scoreName;
var cursor = curScore.newCursor()
var selMez;
var tockEnd = tickEnd+1; // select beyond start of last tick to select all!!
nix = nofC - 1;
if (nofM<10)
nox=-1;
else if (nofM<100)
nox=-2
else if (nofM<1000)
nox=-3
else
nox=-4
for (ii=0; ii0) {
curScore.startCmd();
selMez = curScore.selection.selectRange(0,cTock[ii-1],0,nofS);
curScore.endCmd();
cmd('time-delete');
nun++;
}
tMez = "000"+cMez[ii].toString();
tMoz = "000"+cMoz[ii].toString();
tMez = tMez.substr(nox);
tMoz = tMoz.substr(nox);
msChuf = msPath + "_" + chuf + tMez + "_" + tMoz + ".mscz";
writeScore(curScore, msChuf, "mscz");
if (nun>0) {
cmd("undo");
if (nun>1)
cmd("undo")
}
}
curScore.selection.clear();
mIX.length = 0;
mMez.length = 0;
mTick.length = 0;
cIX.length = 0;
cMez.length = 0;
cTick.length = 0;
cMoz.length = 0;
cTock.length = 0;
}
//=================================================================================================================================
function viewMaps()
{
var ii = 0;
mapScore();
tout = "Score Chunker " + version + "
";
tout += "Score Map
";
tout += "";
tout += "IX | Staff | Mez | Tick |
";
for (ii=0; ii < nofX; ++ii) {
tout += " " + mIX[ii] + " | " + mMez[ii];
tout += " | " + mTick[ii] + " |
";
}
tout += "
";
mapChunks();
tout += "Chunk Map
";
tout += "";
tout += "IX | Mez | Moz | Tick | Tock |
";
for (ii=0; ii < nofC; ++ii) {
tout += " " + cIX[ii];
tout += " | " + cMez[ii]+ " | " + cMoz[ii];
tout += " | " + cTick[ii]+ " | " + cTock[ii];
}
tout += " |
";
tout += "