What's wrong with my advanced color script?
I'm working on a script that is an advaced version of the colornotes included with MuseScore. One where through a UI one chooses to have the notes colored or blackened.
The UI part seems to be working ok.. but none of the notes are getting colored.
The UI code (bbscolornotes.ui):
Dialog
0
0
363
300
Barbershop Color Notes
Qt::Vertical
20
20
10
Choose colorizing method
Qt::LogText
true
Qt::Vertical
20
20
color note head
true
black note head
Qt::Vertical
20
20
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
buttonBox
accepted()
Dialog
accept()
248
254
157
274
buttonBox
rejected()
Dialog
reject()
316
260
286
274
and the regular script (bbscolornotes.js)
//=============================================================================
// MuseScore
// Linux Music Score Editor
// $Id:$
//
// Test plugin
//
// Copyright (C)2009 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.
//=============================================================================
var colors = [new QColor(0,0,0),new QColor(255,0,0),new QColor(0,255,0),
new QColor(0,0,255),new QColor(128,0,0),new QColor(255,0,128),
new QColor(0,128,0),new QColor(0,0,160),new QColor(0,113,187),
new QColor(94,80,161),new QColor(141,91,166),new QColor(207,62,150)];
//
// error handling is mostly omitted!
//
//---------------------------------------------------------
// init
//---------------------------------------------------------
function init()
{
};
var form;
//---------------------------------------------------------
// run
// create gui from qt designer generated file test4.ui
//---------------------------------------------------------
function run()
{
var loader = new QUiLoader(null);
var file = new QFile(pluginPath + "/bbscolornotes.ui");
file.open(QIODevice.OpenMode(QIODevice.ReadOnly, QIODevice.Text));
form = loader.load(file, null);
form.buttonBox.accepted.connect(accept);
form.show();
};
//---------------------------------------------------------
// removeNote
// from all chords with three notes remove note with
// index "idx"
//---------------------------------------------------------
function colorNote(idx)
{
var cursor = new Cursor(curScore);
for (var staff = 0; staff < curScore.staves; ++staff)
{
cursor.staff = staff;
for (var v = 0; v < 4; v++)
{
cursor.voice = v;
cursor.rewind(); // set cursor to first chord/rest
var chosenColor = 0;
if(idx < 1)
{
chosenColor = ((4 *staff) + v) % 12;
}
while (!cursor.eos())
{
if (cursor.isChord())
{
for (var i = 0; i < cursor.chord().notes(); i++)
{
var note = cursor.chord().note(i);
note.color = new QColor(colors[chosenColor]);
}
}
cursor.next();
}
}
}
};
//---------------------------------------------------------
// accept
// called when user presses "Accept" button
//---------------------------------------------------------
function accept()
{
var idx = -1;
if (form.colorHead.checked)
idx = 0;
else if (form.allBlack.checked)
idx = 1;
if (idx != -1)
colorNote(idx);
}
var mscorePlugin = {
menu: 'Plugins.BBS Color Notes',
init: init,
run: run
};
mscorePlugin;
The only thing I haven't checked is running dos2unix on the files before using in musescore.
When I use the debugger in musescore - it crashes when trying to access information to confirm the color value is applied,
I have individual versions that work fine to color and to black, but being identical scripts it would be nice to make them one.
Any help is appreciated.
Comments
My advanced colornotes is not working and here is the files. What am I missing that is wrong?
In reply to That is hard to read.. by ethyr2000
Here is a working version. At least with MuseScore last trunk.
I added undo and change the QColor constructor call.
Out of curiosity, could you explain what the plugin is for?
In reply to Fixed version by [DELETED] 5
I'm part of a barbershop chorus. The society we have been a part of has promoted finale for years and it is wonderful to see musescore coming into development as a competitor in cost and capability. I have several other ideas for plugins for this community.
The purpose of this plugin is to make vocal parts more readable while not cluttering the paper with more staves than necessary. It has been common practice to use layers in finale to separate and colorize the separte parts (tenor, lead, bari, bass). With the current standing of musescore (without layers), I'm distinguishing between staves and voices to colorize and de-colorize the score with this script. I figure most can use the template I've started (see attachment). In the tenor staff use voice 1 for tenor and voice 2 for lead. This leaves the option of on the bass clef using voice 1 or voice 3 for bari and voice 2 or 4 for bass.
Some other plugins I'm planning on developing is:
1) a plugin to exchange 2 parts(by staff and voice) for a selected range of measures
2) a plugin to adjust the cents of each note in to chord to "proper" barbershop NATURAL tuning instead of tempered.
I understand the change in the color constructor.. but why is the Undo needed?
In reply to What does the Undo do? by ethyr2000
I don't know. I guess a redraw/relayout is done on the endUndo call.
I guess it enables the undo of the whole plugin action as well.
hi,
I am curious to what this plugin can do (and how do I install plugins in Musescore?)
I want to use a colour coded system for teaching music, and ideally would just colour the note heads. Anyway, it would be great if there was a way to make C always the same colour regardless of octave etc
But I suspect that this plugin will at least allow me to do that manually which is a great start, and I'd be very surprised all though super pleased if it could do what I need it to...
perhpas you could let me know...
many thanks for contributing to this great project !
In reply to colouring note heads by justcosmic1
If you want to color noteheads regarding to pitches regardless of the octave, you can try the plugin already packaged in MuseScore.
Create a score, add your notes and go to Plugins -> Color notes.
The notes will be colored. The color convention is the boomwhackers one.
@ethyr2000 Regarding the barbershop plugin, it could make his way to http://musescore.org/plugins no? Are you still using it ?
In reply to If you want to color by [DELETED] 5
Thanks Lasonic for the reply...I didn't even know that was there....do you know if I can edit that plugin to my own custom colour scheme (well actually the Tobin music scheme is what I was going to use) ?
Many thanks for the help again...
In reply to if you want colour by justcosmic1
You can edit the file
C:\Program Files\MuseScore\plugins\colorNotes.js
.The colors array contains the color for C C# D etc...
The three numbers are "Red Green Blue" (RGB) and should be between 0 and 255
Any reference to Tobin scheme?
In reply to You can edit the file by [DELETED] 5
Yes here's their website...the system as you will see has been in use for a number of years...and looks like a great over all system for teaching music literacy from an early age
http://www.tobinmusic.co.uk/content/index.htm
Thanks again for that tip on editing the plugin...I will give it a try...maybe I can coppy it and rename it b4 I edit so as to have 2 colour schemes available ?
In reply to Tobin music scheme by justcosmic1
I can't find the colors on the website. But you'll find out I guess :) I'm a little worried about 7 colors for 7 pitches statement, because the color plugin assume 12 pitches not 7.
You can of course make a copy. CHange the line
menu: 'Plugins.Color Notes',
tomenu: 'Plugins.Color Notes Tobin',
to differentiate them in the menu. Feel free to post your plugin as a new one at http://musescore.org/plugins.In reply to I can't find the colors on by [DELETED] 5
Yes I think accidentals don't change the colour...so I guess those I would just duplicate the colour for.
I'll give it a try and let you know how I get on.
Will be away from my computer for a couple of hours now, but I'll post back later.