//============================================================================= // Viool plugin / adjusted by Serge tkint for violin // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //============================================================================= var fingerings = [ "0", "1", "1", "2", "2", "3", "3", "0", "1", "1", "2", "2", "3", "3", "0", "1", "1", "2", "2", "3", "3", "0", "1", "1", "2", "2", "3", "3", "4", "0", "1", "2", "2", "3", "3", ]; var colors = [ new QColor(255,255,0), new QColor(255,255,0), new QColor(255,255,0), new QColor(255,255,0), new QColor(255,255,0), new QColor(255,255,0), new QColor(255,255,0), new QColor(0,255,0) , new QColor(0,255,0) , new QColor(0,255,0) , new QColor(0,255,0) , new QColor(0,255,0) , new QColor(0,255,0) , new QColor(0,255,0), new QColor(0,0,255) , new QColor(0,0,255) , new QColor(0,0,255) , new QColor(0,0,255) , new QColor(0,0,255) , new QColor(0,0,255) , new QColor(0,0,255), new QColor(255,0,0) , new QColor(255,0,0) , new QColor(255,0,0) , new QColor(255,0,0) , new QColor(255,0,0) , new QColor(255,0,0) , new QColor(255,0,0), new QColor(0,0,0) , new QColor(0,0,0) , new QColor(0,0,0) , new QColor(0,0,0) , new QColor(0,0,0) , new QColor(0,0,0) , new QColor(0,0,0), ]; //--------------------------------------------------------- // init //--------------------------------------------------------- function init() { } //------------------------------------------------------------------- // run //------------------------------------------------------------------- function run() { if (typeof curScore === 'undefined') return; var cursor = new Cursor(curScore); cursor.goToSelectionStart(); var startStaff = cursor.staff; cursor.goToSelectionEnd(); var endStaff = cursor.staff; if (cursor.eos()) { // if no selection startStaff = 0; // start with 1st staff endStaff = curScore.staves; // and end with last } var font = new QFont("Times", 16); for (var staff = startStaff; staff < endStaff; ++staff) { cursor.goToSelectionStart(); cursor.staff = staff; cursor.voice = 0; cursor.rewind(); // set cursor to first chord/rest while (!cursor.eos()) { if (cursor.isChord()) { var pitch = cursor.chord().topNote().pitch; var index = pitch - 55; if(index >= 0 && index < fingerings.length){ var text = new Text(curScore); text.text = fingerings[index]; text.defaultFont = font; text.yOffset = -5; text.color = new QColor(colors[index]); cursor.putStaffText(text); } } cursor.next(); } } } var mscorePlugin = { menu: 'Plugins.viool', init: init, run: run }; mscorePlugin;