Updating plugin scripts
This commit is contained in:
parent
5fbce98161
commit
4c9162443c
3 changed files with 30 additions and 42 deletions
|
@ -2,13 +2,15 @@ import QtQuick 2.0
|
|||
import MuseScore 1.0
|
||||
|
||||
MuseScore {
|
||||
version: "1.0"
|
||||
version: "2.0"
|
||||
description: "This demo plugin creates a new score."
|
||||
menuPath: "Plugins.createscore"
|
||||
|
||||
onRun: {
|
||||
console.log("hello createscore");
|
||||
var score = newScore("Test-Score", "Piano", 5);
|
||||
var score = newScore("Test-Score", "piano", 5);
|
||||
var numerator = 3;
|
||||
var denominator = 4;
|
||||
|
||||
score.addText("title", "==Test-Score==");
|
||||
score.addText("subtitle", "subtitle");
|
||||
|
@ -16,10 +18,14 @@ MuseScore {
|
|||
var cursor = score.newCursor();
|
||||
cursor.track = 0;
|
||||
|
||||
cursor.rewind(0);
|
||||
var ts = newElement(Element.TIMESIG);
|
||||
ts.setSig(numerator, denominator);
|
||||
cursor.add(ts);
|
||||
|
||||
cursor.rewind(0);
|
||||
cursor.setDuration(1, 4);
|
||||
var note = cursor.addNote(60);
|
||||
note.color = "#5040a1";
|
||||
cursor.addNote(60);
|
||||
|
||||
cursor.next();
|
||||
cursor.setDuration(3, 8);
|
||||
|
@ -28,10 +34,10 @@ MuseScore {
|
|||
cursor.next();
|
||||
cursor.setDuration(1, 4);
|
||||
cursor.addNote(68);
|
||||
|
||||
cursor.next();
|
||||
cursor.addNote(72);
|
||||
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick 2.1
|
||||
import MuseScore 1.0
|
||||
|
||||
MuseScore {
|
||||
version: "1.0"
|
||||
version: "2.0"
|
||||
description: "Create random score."
|
||||
menuPath: "Plugins.random"
|
||||
|
||||
|
@ -25,7 +25,7 @@ MuseScore {
|
|||
var octaves = 2;
|
||||
var key = 3;
|
||||
|
||||
var score = newScore("Random.mscz", "Piano", measures);
|
||||
var score = newScore("Random.mscz", "piano", measures);
|
||||
|
||||
score.addText("title", "==Random==");
|
||||
score.addText("subtitle", "subtitle");
|
||||
|
@ -39,16 +39,10 @@ MuseScore {
|
|||
ts.setSig(numerator, denominator);
|
||||
cursor.add(ts);
|
||||
|
||||
if (key != 0) {
|
||||
var sig = newElement(Element.KEYSIG);
|
||||
sig.setSig(0, key);
|
||||
cursor.add(sig);
|
||||
}
|
||||
|
||||
cursor.rewind(0);
|
||||
cursor.setDuration(1, denominator);
|
||||
|
||||
var realMeasures = Math.floor((measures * 4 + numerator - 1) / numerator);
|
||||
var realMeasures = Math.floor((measures + numerator - 1) / numerator);
|
||||
console.log(realMeasures);
|
||||
var notes = realMeasures * numerator;
|
||||
|
||||
|
@ -64,14 +58,9 @@ MuseScore {
|
|||
cursor.setDuration(1, 4);
|
||||
addNote(key, cursor);
|
||||
}
|
||||
if (i % 12 == 11) {
|
||||
var lb = newElement(Element.LAYOUT_BREAK);
|
||||
lb.layoutBreakType = LayoutBreak.LINE;
|
||||
cursor.add(lb);
|
||||
}
|
||||
|
||||
cursor.next();
|
||||
}
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,13 +4,13 @@ import QtQuick.Controls 1.0
|
|||
import QtQuick.Layouts 1.0
|
||||
|
||||
MuseScore {
|
||||
version: "1.0"
|
||||
version: "2.0"
|
||||
description: "Create random score."
|
||||
menuPath: "Plugins.random2"
|
||||
pluginType: "dock"
|
||||
dockArea: "left"
|
||||
width: 150
|
||||
// height: 75
|
||||
height: 75
|
||||
|
||||
property variant octaves : 2;
|
||||
|
||||
|
@ -25,6 +25,7 @@ MuseScore {
|
|||
var octave = Math.floor(Math.random() * 2);
|
||||
var pitch = cdur[Math.floor(idx)] + octave * 12 + 60;
|
||||
var pitch = pitch + keyo[key];
|
||||
console.log("Add note pitch "+pitch);
|
||||
cursor.addNote(pitch);
|
||||
}
|
||||
|
||||
|
@ -34,11 +35,11 @@ MuseScore {
|
|||
var denominator = 4;
|
||||
var key = 3;
|
||||
|
||||
var score = newScore("Random.mscz", "Piano", measures);
|
||||
var score = newScore("Random2.mscz", "piano", measures);
|
||||
|
||||
score.startCmd()
|
||||
score.addText("title", "==Random==");
|
||||
score.addText("subtitle", "subtitle");
|
||||
score.addText("title", "==Random2==");
|
||||
score.addText("subtitle", "Another subtitle");
|
||||
|
||||
var cursor = score.newCursor();
|
||||
cursor.track = 0;
|
||||
|
@ -49,38 +50,31 @@ MuseScore {
|
|||
ts.setSig(numerator, denominator);
|
||||
cursor.add(ts);
|
||||
|
||||
if (key != 0) {
|
||||
var sig = newElement(Element.KEYSIG);
|
||||
sig.setSig(0, key);
|
||||
cursor.add(sig);
|
||||
}
|
||||
|
||||
cursor.rewind(0);
|
||||
cursor.setDuration(1, denominator);
|
||||
|
||||
var realMeasures = Math.floor((measures * 4 + numerator - 1) / numerator);
|
||||
var realMeasures = Math.floor((measures * 2 + numerator - 1) / numerator);
|
||||
console.log(realMeasures);
|
||||
var notes = realMeasures * numerator;
|
||||
|
||||
for (var i = 0; i < notes; ++i) {
|
||||
if (Math.random() < 0.5) {
|
||||
console.log("Adding two notes at ", i);
|
||||
cursor.setDuration(1, 8);
|
||||
addNote(key, cursor);
|
||||
cursor.next();
|
||||
addNote(key, cursor);
|
||||
}
|
||||
else {
|
||||
console.log("Adding note at ", i);
|
||||
cursor.setDuration(1, 4);
|
||||
addNote(key, cursor);
|
||||
}
|
||||
if (i % 12 == 11) {
|
||||
var lb = newElement(Element.LAYOUT_BREAK);
|
||||
lb.layoutBreakType = LayoutBreak.LINE;
|
||||
cursor.add(lb);
|
||||
}
|
||||
|
||||
cursor.next();
|
||||
}
|
||||
score.endCmd()
|
||||
Qt.quit();
|
||||
}
|
||||
GridLayout {
|
||||
anchors.fill: parent
|
||||
|
@ -111,5 +105,4 @@ MuseScore {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue