What's wrong with my advanced color script?

• Nov 3, 2009 - 13:48

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

In reply to 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.

Attachment Size
MS BBS template.zip 1.2 KB

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 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', to menu: '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.

Do you still have an unanswered question? Please log in first to post your question.