//============================================================================= // MuseScore // Linux Music Score Editor // $Id:$ // // Color notehead plugin version 1.1 // Noteheads are colored according to pitch, according to the BoomWhackers convention. // Each pitch has a different color. C and C# have a different color. C# and Db have the same color. // User can change to color by modifying the colors array. First element is C, second C# etc... // // // 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") // // Amended by skinnyjim June 2014 to colour notes to Tobin Music Scheme instead of Boomwhacker colours // var colors = [ /*C*/ new QColor(238,238,0), /*G*/ new QColor(255,0,0), /*D*/ new QColor(155,48,255), /*A*/ new QColor(30,144,255), /*E*/ new QColor(238,154,0), /*B*/ new QColor(0,255,0), /*F*/ new QColor(139,69,19), new QColor(238,238,0), new QColor(255,0,0), new QColor(155,48,255), new QColor(30,144,255), new QColor(238,154,0), new QColor(0,255,0), new QColor(139,69,19), new QColor(238,238,0), new QColor(255,0,0), new QColor(155,48,255), new QColor(30,144,255), new QColor(238,154,0), new QColor(0,255,0), new QColor(139,69,19), new QColor(238,238,0), new QColor(255,0,0), new QColor(155,48,255), new QColor(30,144,255), new QColor(238,154,0), new QColor(0,255,0), new QColor(139,69,19), ]; // Standardcolor is black var COLOR_BLACK = new QColor(0,0,0); var NON_COLORED = COLOR_BLACK; //--------------------------------------------------------- // 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); // Do for all Staves/Tracks ... for (var staff = 0; staff < curScore.staves; staff++) { cursor.staff = staff; // Do for all 4 voices ... for (var voice = 0; voice <= 3; voice++) { cursor.voice = voice; //Do for all chords (/notes) ... cursor.rewind(); // set cursor to first chord/rest while (!cursor.eos()) { if (cursor.isChord()) { var chord = cursor.chord(); //Do for all notes ... for (var i = 0; i < chord.notes; i++) { var note = chord.note(i) note.color = getColor( note.color, note.tpc ); } } // get next chord (/notes) cursor.next(); } } } } ////////////////////////////////////////////// /// getColor - returns color according to pitch // function getColor( note_color, note_pitch ) { if ( isColoredNote(note_color) ) { return( COLOR_BLACK ) ; } else { var colorIndex = note_pitch % 35; return( colors[ colorIndex ] ); } } //////////////////////////////////////////////////////////////////// /// isColoredNote - returns true if first passed note is not 'black' // var pIsColoredNote = undefined; function isColoredNote(note_color) { // only test the first note and cache the result // to apply the result to all following requests if (typeof pIsColoredNote === 'undefined') { pIsColoredNote = (NON_COLORED != note_color); } return( pIsColoredNote ); } //--------------------------------------------------------- // menu: defines were the function will be placed // in the MuseScore menu structure //--------------------------------------------------------- var mscorePlugin = { menu: 'Plugins.Candidas Colours', init: init, run: run }; mscorePlugin;