chord.noStem

• Sep 9, 2012 - 12:32

I'm currently running MuseScore V. 1.2 Rev: 5470. I'm finding that when I set the .noStem property to true in a plugin MuseScore promptly crashes. As a test I modified createscore.js plugin thats distributed with MuseScore. Specifically, I inserted "chord.noStem = true;" at line 43, and changed line 78 so it has a different menu item. The full version of the plugin I'm working with is below.

Am I doing something wrong, or is this not implemented?

Thank you,
Nick Barnard

//=============================================================================
// MuseScore
// Linux Music Score Editor
// $Id:$
//
// Test plugin
//
// Copyright (C)2008-2010 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");
};

function addNote(cursor, pitch, duration)
{
var chord = new Chord();
chord.tickLen = duration;
chord.noStem = true;
var note = new Note();
note.pitch = pitch;

chord.addNote(note);

cursor.add(chord);
cursor.next();
};

function run()
{
var score = new Score();
score.name = "Test-Score";
score.title = "Test-Score";
score.appendPart("Piano"); // create two staff piano part
score.appendMeasures(5); // append five empty messages
var cursor = new Cursor(score);
cursor.staff = 0;
cursor.voice = 0;
cursor.rewind();

addNote(cursor, 60, 480);
addNote(cursor, 62, 480);
addNote(cursor, 64, 480);
addNote(cursor, 65, 480);
};

//---------------------------------------------------------
// menu: defines were the function will be placed
// in the menu structure
//---------------------------------------------------------

var mscorePlugin = {
menu: 'Plugins.Score Write Test',
init: init,
run: run
};

mscorePlugin;


Comments

You might want to check out the Slash Notatin plugin to see an example of how noStem can be used. I recall it took some trial and error to figure out what order the properties had to be set in order to work, and a comment in the source reflects that.

In reply to by Marc Sabatella

Marc,
Thank you for the referral to the Slash Notation plugin. That provided the guidance for what I needed to do.

For others running across this thread, essentially, you can't use the .noStem property until the chord is on the staff. So rewriting the previous example, it'd look like this:


//=============================================================================
// MuseScore
// Linux Music Score Editor
// $Id:$
//
// Test plugin
//
// Copyright (C)2008-2010 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");
};

function addNote(cursor, pitch, duration) {
var chord = new Chord();
chord.tickLen = duration;
var note = new Note();
note.pitch = pitch;

chord.addNote(note);

cursor.add(chord);

chord = cursor.chord();
chord.noStem = true;

cursor.next();
};

function run() {
var score = new Score();
score.name = "Test-Score";
score.title = "Test-Score";
score.appendPart("Piano"); // create two staff piano part
score.appendMeasures(5); // append five empty messages
var cursor = new Cursor(score);
cursor.staff = 0;
cursor.voice = 0;
cursor.rewind();

addNote(cursor, 60, 480);
addNote(cursor, 62, 480);
addNote(cursor, 64, 480);
addNote(cursor, 65, 480);
};

//---------------------------------------------------------
// menu: defines were the function will be placed
// in the menu structure
//---------------------------------------------------------

var mscorePlugin = {
menu: 'Plugins.Score Write Test',
init: init,
run: run
};

mscorePlugin;

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