//============================================================================= // // German Fingerling plugin // http://musescore.org/en/project/naffingering // // Copyright (C) 2014 Jeffrey Edwards // based on 6-hole Native American Flute fingering plugin by lasconic // // 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. //============================================================================= // // This is ECMAScript code (ECMA-262 aka "Java Script") // const fontColorBlack = new QColor("black"); const fontColorRed = new QColor("red") const fontSize = 10; const fontName = "Arial Unicode MS"; const xOffset = 0; const yOffset = 5; const menuItem = "German Fingerling" //------------------------------------------------------------------- // init //------------------------------------------------------------------- function init() { } //------------------------------------------------------------------- // run //------------------------------------------------------------------- function run() { var cursor = new Cursor(curScore); cursor.staff = 0; cursor.voice = 0; cursor.rewind(); // set cursor to first chord/rest var font = new QFont(fontName, fontSize); while (!cursor.eos()) { if (cursor.isChord()) { var topNote = cursor.chord().topNote(); if (topNote.tied <= 1 ) { var FingerText = new Text(curScore); FingerText.defaultFont = font; FingerText.xOffset = xOffset; FingerText.yOffset = yOffset; var pitch = topNote.pitch; if (pitch < 60) { (FingerText.text = CreateFingerString(6,6,6,6,6,6,6,6)); (FingerText.color=fontColorRed); } if (pitch == 60) { (FingerText.text =CreateFingerString(1,1,1,1,1,1,1,1)); (FingerText.color=fontColorBlack); } if (pitch == 61) { (FingerText.text =CreateFingerString(1,1,1,1,1,1,1,3)); (FingerText.color=fontColorBlack); } if (pitch == 62) { (FingerText.text =CreateFingerString(1,1,1,1,1,1,1,6)); (FingerText.color=fontColorBlack); } if (pitch == 63) { (FingerText.text =CreateFingerString(1,1,1,1,1,1,3,6)); (FingerText.color=fontColorBlack); } if (pitch == 64) { (FingerText.text =CreateFingerString(1,1,1,1,1,1,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 65) { (FingerText.text =CreateFingerString(1,1,1,1,1,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 66) { (FingerText.text =CreateFingerString(1,1,1,1,6,1,1,1)); (FingerText.color=fontColorBlack); } if (pitch == 67) { (FingerText.text =CreateFingerString(1,1,1,1,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 68) { (FingerText.text =CreateFingerString(1,1,1,6,1,1,1,6)); (FingerText.color=fontColorBlack); } if (pitch == 69) { (FingerText.text =CreateFingerString(1,1,1,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 70) { (FingerText.text =CreateFingerString(1,1,6,1,1,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 71) { (FingerText.text =CreateFingerString(1,1,6,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 72) { (FingerText.text =CreateFingerString(1,6,1,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 73) { (FingerText.text =CreateFingerString(1,6,6,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 74) { (FingerText.text =CreateFingerString(6,6,1,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 75) { (FingerText.text =CreateFingerString(6,6,1,1,1,1,1,6)); (FingerText.color=fontColorBlack); } if (pitch == 76) { (FingerText.text =CreateFingerString(2,1,1,1,1,1,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 77) { (FingerText.text =CreateFingerString(2,1,1,1,1,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 78) { (FingerText.text =CreateFingerString(2,1,1,1,6,1,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 79) { (FingerText.text =CreateFingerString(2,1,1,1,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 80) { (FingerText.text =CreateFingerString(2,1,1,6,1,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 81) { (FingerText.text =CreateFingerString(2,1,1,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 82) { (FingerText.text =CreateFingerString(2,1,1,6,6,1,1,6)); (FingerText.color=fontColorBlack); } if (pitch == 83) { (FingerText.text =CreateFingerString(2,1,6,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch == 84) { (FingerText.text =CreateFingerString(2,6,6,6,6,6,6,6)); (FingerText.color=fontColorBlack); } if (pitch > 84) { (FingerText.text =CreateFingerString(6,6,6,6,6,6,6,6)); (FingerText.color=fontColorRed); } cursor.putStaffText(FingerText); }//end of if (topNote.tied <= 1 ) }//end of if (cursor.isChord()) cursor.next(); }//end of while (!cursor.eos()) }//end of function run() //------------------------------------------------------------------- // GetFingerUnicode - returns a string of the fingering // using font Arial Unicode MS // where: 1 = \u25cf = black circle // 2 = \u25d0 = circle with left side shaded // 3 = \u25d1 = circle with right side shaded // 4 = \u25d2 = circle with bottom side shaded // 5 = \u25d3 = circle with top side shaded // 6 = \u25cb = white circle // 7 = \u2212 = horizontal line function GetFingerUnicode(A) { if(A == 1) var HoleString = '\u25cf'; if(A == 2) var HoleString = '\u25d0'; if(A == 3) var HoleString = '\u25d1'; if(A == 4) var HoleString = '\u25d2'; if(A == 5) var HoleString = '\u25d3'; if(A == 6) var HoleString = '\u25cb'; return HoleString; }//end of function GetFingerUnicode() //------------------------------------------------------------------- // CreateFingerString - creates and returns a string of the fingering function CreateFingerString(h1,h2,h3,h4,h5,h6,h7,h8) { var FingerString = GetFingerUnicode(h8); //get hole 8 FingerString = FingerString + '\n' + GetFingerUnicode(h7); //add hole 7 FingerString = FingerString + '\n' + GetFingerUnicode(h6); //add hole 6 FingerString = FingerString + '\n' + GetFingerUnicode(h5); //add hole 5 FingerString = FingerString + '\n' + '\u2212'; //add line FingerString = FingerString + '\n' + GetFingerUnicode(h4); //add hole 4 FingerString = FingerString + '\n' + GetFingerUnicode(h3); //add hole 3 FingerString = FingerString + '\n' + GetFingerUnicode(h2); //add hole 2 FingerString = FingerString + '\n' + '\u2212'; //add line FingerString = FingerString + '\n' + GetFingerUnicode(h1); //add hole 1 return FingerString; }//end of function CreateFingerString() //------------------------------------------------------------------- var mscorePlugin = { menu: 'Plugins.' + menuItem, init: init, run: run }; mscorePlugin;