//============================================================================= // MuseScore // Linux Music Score Editor // $Id:$ // // Test plugin // // Copyright (C)2008 Werner Schweer and others // // 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") // /*---Configuration --- */ var french = true; var topNote = false; var frTranslation = {}; frTranslation['Ab'] = 'Lab'; frTranslation['A'] = 'La'; frTranslation['A#'] = 'La#'; frTranslation['Bb'] = 'Sib'; frTranslation['B'] = 'Si'; frTranslation['B#'] = 'Si#'; frTranslation['Cb'] = 'Dob'; frTranslation['C'] = 'Do'; frTranslation['C#'] = 'Do#'; frTranslation['Db'] = 'Reb'; frTranslation['D'] = 'Re'; frTranslation['D#'] = 'Re#'; frTranslation['Eb'] = 'Mib'; frTranslation['E'] = 'Mi'; frTranslation['E#'] = 'Mi#'; frTranslation['Fb'] = 'Fab'; frTranslation['F'] = 'Fa'; frTranslation['F#'] = 'Fa#'; frTranslation['Gb'] = 'Solb'; frTranslation['G'] = 'Sol'; frTranslation['G#'] = 'Sol#'; //--------------------------------------------------------- // init // this function will be called on startup of mscore //--------------------------------------------------------- function init() { // print("test script init"); } //------------------------------------------------------------------- // run // this function will be called when activating the // plugin menu entry // // global Variables: // pluginPath - contains the plugin path; file separator is "/" //------------------------------------------------------------------- function run() { var cursor = new Cursor(curScore); for (var staff = 0; staff < curScore.staves; ++staff) { cursor.staff = staff; //for (var v = 0; v < 3; v++) { // Uncomment to make it work for all voices for (var v = 0; v < 1; v++) { cursor.voice = v; cursor.rewind(); // set cursor to first chord/rest while (!cursor.eos()) { if (cursor.isChord()) { var chord = cursor.chord(); if (topNote) { var text = new Text(curScore); /* top notes only*/ if(french) { text.text = frTranslation[chord.topNote().name]; //En français }else{ text.text = chord.topNote().name; // In english } text.yOffset = -5; cursor.putStaffText(text); } else { /* All notes */ var n = chord.notes; for (var i = 0; i < n; i++) { var note = chord.note(i); var text = new Text(curScore); if(french) { text.text = frTranslation[note.name]; //En français }else{ text.text = note.name; // In english } switch(i){ case 0: text.yOffset = -5; break; case 1: text.yOffset = -7; break; case 2: text.yOffset = -9; break; case 3: text.yOffset = -11; break; default: text.yOffset = -5; break; } cursor.putStaffText(text); } } } // isChord cursor.next(); } } } } //--------------------------------------------------------- // menu: defines were the function will be placed // in the MuseScore menu structure //--------------------------------------------------------- var mscorePlugin = { menu: 'Plugins.Enhanced Note Names', init: init, run: run }; mscorePlugin;