All notes in Note Names
Hello all :)
I needed the Note Names plugin to display all note names (yes, I am too lazy to learn how to read music notation fluently), and could not find any way to do this in the standard plugin, or here on the forum. So I just made a quick customization of the existing plugin. The plugin iterates (should do, at least) through all staffs, and each note in each chord at any given position in that staff.
I am new to both JavaScript and MuseScore, so this is probably not bug-free, and I have not implemented any specific functionality for voices, as I don't know what that is, but this customized version of Note Names could perhaps help other people in my situation, and I have not found bugs in any of the tests I have done. So I'll post the script here for you, to use if you need it :)
Copy/paste into notenames.js to use (perhaps backup old version in case you want to revert)
//=============================================================================
// 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")
//
//---------------------------------------------------------
// 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);
var i = 0;
for (i = curScore.staves; i > 0; i--){
cursor.staff = i-1;
cursor.voice = 0;
cursor.rewind(); // set cursor to first chord/rest
var shiftDown = 0;
while (!cursor.eos()) {
if (cursor.isChord()) {
var text = new Text(curScore);
text.text = cursor.chord().topNote().name;
//-1 for index, -1 for topNote(), ie -2:
var chordlength = cursor.chord().notes-2;
while (chordlength >= 0){
print(chordlength + text.text);
text.text += "-" + cursor.chord().note(chordlength).name;
chordlength = chordlength - 1;
}
if(text.text.length >4 && shiftDown == 1){
text.yOffset = 6;
shiftDown = 0;
}else{
text.yOffset = 5;
shiftDown = 1;
}
cursor.putStaffText(text);
}
cursor.next();
}
}
}
//---------------------------------------------------------
// menu: defines were the function will be placed
// in the MuseScore menu structure
//---------------------------------------------------------
var mscorePlugin = {
menu: 'Plugins.Note Names',
init: init,
run: run
};
mscorePlugin;
Comments
Well, after reading what voices actually represent, I decided that it should probably be included. Revised version of initial code attached here :) Now includes voices!
Note that adding note names for large chords requires lots and lots of space. Since that is not always available, note names might sometimes overlap. I have tried avoiding it, but in some scores,that is not always possible.
In reply to Added voices by moeller_
Thanks for this!
Hello,
I'm an old programmer, but new to music.
My problem is the opposite of yours – I want to convert lead sheets into piano chords. I can't automate everything, because I can't teach the program how to choose the chord patterns.
I couldn't test your code, because I have no music scores with chord notes. Please upload a demo that I can use.
Meanwhile, I made your code more readable. You need a good editor, and Notepad will do.
the view of the note names all runs together if there are several chords in sucession. how do I change the plugin code to display the note names for the chord vertically above the chord?
In reply to how do you stack the notes vertically for the chord? by mrpeeble
Here's how to stack them vertically:
http://musescore.org/en/node/24617