musescore简谱标注插件
标注效果
适用版本
3.6.2,其他版本可能出现排版错误
插件 SimpleStaff.qml
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Note Names Plugin
//
// Copyright (C) 2012 Werner Schweer
// Copyright (C) 2013, 2014 Joachim Schmitz
// Copyright (C) 2014 Jörn Eichler
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
import QtQuick 2.0
import MuseScore 3.0
MuseScore {
version: "2.0"
description: qsTr("This plugin names SimpleStaff")
menuPath: "Plugins." + qsTr("SimpleStaff") // this does not work, why?
function nameChord(notes, text, cursor) {
var textDotC0 = newElement(Element.STAFF_TEXT);
var textDotC1 = newElement(Element.STAFF_TEXT);
var textDotC2 = newElement(Element.STAFF_TEXT);
var textDotC3 = newElement(Element.STAFF_TEXT);
var textDotC5 = newElement(Element.STAFF_TEXT);
var textDotC6 = newElement(Element.STAFF_TEXT);
var textDotC7 = newElement(Element.STAFF_TEXT);
var textDotC8 = newElement(Element.STAFF_TEXT);
textDotC0.fontSize = 8;
textDotC1.fontSize = 8;
textDotC2.fontSize = 8;
textDotC3.fontSize = 8;
textDotC5.fontSize = 8;
textDotC6.fontSize = 8;
textDotC7.fontSize = 8;
textDotC8.fontSize = 8;
for (var i = 0; i < notes.length; i++) {
var sep = " "; // change to "\n" if you want them vertically
if (i > 0)
text.text = sep + text.text;
if (typeof notes[i].tpc === "undefined") // just in case
return
if (notes[i].pitch < 24) {
textDotC0.text = qsTr(". ") + textDotC0.text
}
if (notes[i].pitch < 24 + 12) {
textDotC1.text = qsTr(". ") + textDotC1.text
}
if (notes[i].pitch < 24 + 12 * 2) {
textDotC2.text = qsTr(". ") + textDotC2.text
}
if (notes[i].pitch < 24 + 12 * 3) {
textDotC3.text = qsTr(". ") + textDotC3.text
}
if (notes[i].pitch >= 24 + 12 * 4) {
textDotC5.text = qsTr(". ") + textDotC5.text
}
if (notes[i].pitch >= 24 + 12 * 5) {
textDotC6.text = qsTr(". ") + textDotC6.text
}
if (notes[i].pitch >= 24 + 12 * 6) {
textDotC7.text = qsTr(". ") + textDotC7.text
}
if (notes[i].pitch >= 24 + 12 * 7) {
textDotC8.text = qsTr(". ") + textDotC8.text
}
switch (notes[i].tpc) {
case -1: text.text = qsTr("4") + text.text; break;
case 0: text.text = qsTr("1") + text.text; break;
case 1: text.text = qsTr("5") + text.text; break;
case 2: text.text = qsTr("2") + text.text; break;
case 3: text.text = qsTr("6") + text.text; break;
case 4: text.text = qsTr("3") + text.text; break;
case 5: text.text = qsTr("7") + text.text; break;
case 6: text.text = qsTr("4") + text.text; break;
case 7: text.text = qsTr("1") + text.text; break;
case 8: text.text = qsTr("5") + text.text; break;
case 9: text.text = qsTr("2") + text.text; break;
case 10: text.text = qsTr("6") + text.text; break;
case 11: text.text = qsTr("3") + text.text; break;
case 12: text.text = qsTr("7") + text.text; break;
case 13: text.text = qsTr("4") + text.text; break;
case 14: text.text = qsTr("1") + text.text; break;
case 15: text.text = qsTr("5") + text.text; break;
case 16: text.text = qsTr("2") + text.text; break;
case 17: text.text = qsTr("6") + text.text; break;
case 18: text.text = qsTr("3") + text.text; break;
case 19: text.text = qsTr("7") + text.text; break;
case 20: text.text = qsTr("4") + text.text; break;
case 21: text.text = qsTr("1") + text.text; break;
case 22: text.text = qsTr("5") + text.text; break;
case 23: text.text = qsTr("2") + text.text; break;
case 24: text.text = qsTr("6") + text.text; break;
case 25: text.text = qsTr("3") + text.text; break;
case 26: text.text = qsTr("7") + text.text; break;
case 27: text.text = qsTr("4") + text.text; break;
case 28: text.text = qsTr("1") + text.text; break;
case 29: text.text = qsTr("5") + text.text; break;
case 30: text.text = qsTr("2") + text.text; break;
case 31: text.text = qsTr("6") + text.text; break;
case 32: text.text = qsTr("3") + text.text; break;
case 33: text.text = qsTr("7") + text.text; break;
default: text.text = qsTr("?") + text.text; break;
} // end switch tpc
//console.log(notes[i].pitch)
//console.log(notes[i].accidentalType)
//for(var ss in notes[i]){
// console.log(ss + " : " + eval("notes[i]." + ss))
//}
switch (String(notes[i].accidentalType)) {
case "NONE":
text.offsetX = 0.65;
text.offsetY = 3;
break;
case "SHARP":
text.text = qsTr("♯") + text.text;
break;
case "FLAT":
text.text = qsTr("♭") + text.text;
break;
case "SHARP2":
text.text = qsTr("♯♯") + text.text;
break;
case "FLAT2":
text.text = qsTr("♭♭") + text.text;
break;
case "NATURAL":
text.text = qsTr("♮") + text.text;
break;
default:
text.text = qsTr("?") + text.text;
break;
} // end switch userAccidental
} // end for note
text.offsetX = text.offsetX - (notes.length - 1) * 0.5;
textDotC0.offsetX = textDotC0.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC1.offsetX = textDotC1.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC2.offsetX = textDotC2.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC3.offsetX = textDotC3.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC5.offsetX = textDotC5.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC6.offsetX = textDotC6.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC7.offsetX = textDotC7.offsetX + 0.95 - (notes.length - 1) * 0.5;
textDotC8.offsetX = textDotC8.offsetX + 0.95 - (notes.length - 1) * 0.5;
cursor.add(textDotC0);
cursor.add(textDotC1);
cursor.add(textDotC2);
cursor.add(textDotC3);
cursor.add(text);
cursor.add(textDotC5);
cursor.add(textDotC6);
cursor.add(textDotC7);
cursor.add(textDotC8);
}
onRun: {
if (typeof curScore === 'undefined')
Qt.quit();
var cursor = curScore.newCursor();
var style = curScore.style;
//console.log(style.value("minVerticalDistance") + "ss")
style.setValue("staffTextMinDistance", 0.2);
//console.log(style.value("minVerticalDistance") + "ss")
var startStaff;
var endStaff;
var endTick;
var fullScore = false;
cursor.rewind(1);
if (!cursor.segment) { // no selection
fullScore = true;
startStaff = 0; // start with 1st staff
endStaff = curScore.nstaves - 1; // and end with last
} else {
startStaff = cursor.staffIdx;
cursor.rewind(2);
if (cursor.tick == 0) {
// this happens when the selection includes
// the last measure of the score.
// rewind(2) goes behind the last segment (where
// there's none) and sets tick=0
endTick = curScore.lastSegment.tick + 1;
} else {
endTick = cursor.tick;
}
endStaff = cursor.staffIdx;
}
console.log(startStaff + " - " + endStaff + " - " + endTick)
for (var staff = startStaff; staff <= endStaff; staff++) {
for (var voice = 0; voice < 4; voice++) {
cursor.rewind(1); // beginning of selection
cursor.voice = voice;
cursor.staffIdx = staff;
if (fullScore) // no selection
cursor.rewind(0); // beginning of score
while (cursor.segment && (fullScore || cursor.tick < endTick)) {
if (cursor.element && cursor.element.type == Element.CHORD) {
var text = newElement(Element.STAFF_TEXT);
var notes = cursor.element.notes;
text.fontSize = 8
switch (voice) {
case 0: text.offsetY = 1; break;
case 1: text.offsetY = 10; break;
case 2: text.offsetY = -1; break;
case 3: text.offsetY = 12; break;
}
nameChord(notes, text, cursor);
} // end if CHORD
cursor.next();
} // end while segment
} // end for voice
} // end for staff
Qt.quit();
} // end onRun
}
适用方法
将上述代码保存成文件SimpleStaff.qml,或者加入qq群聊:954463049,群文件免费获取,还有很多免费乐谱
将文件放入文件夹中
有些版本不在这个路径,没关系,通过插件管理器,查看路径在哪,放到该路径中即可
放入之后重启MuseScore再左侧点击对钩,即可使用
不足与改进
- 多个音同时标注,点的位置可能移动
- 不支持移调,如果要标注,需要先转化为C大调,标注完之后再转换回来
- 如果豆芽太过密集,位置可能会向上移动,需要手动调整
- 只能进行标注,不能绘制完整简谱,尝试使用占位框,但是官方文档写的稀碎,经过一番努力,没有成功