What has to be changed to make version 2 plugins work in Musescore 3

• Jan 10, 2019 - 19:56

I use a plugin "brass fingerings" (or maybe it's called "trombone slide positions) in Musescore 2. It does not work in Musescore 3. Any clues on, what has to be changed? The plugin can be selected, but it does nothing to the notes - should write the trombone slide positions.

The code:
//=============================================================================
// Brass Fingering Plugin
//
// Copyright (C) 2016 Alexander Schwedler
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================

import QtQuick 2.0
import MuseScore 3.0

MuseScore {
version: "1.1"
description: qsTr("This plugin adds fingering for brass instruments")
menuPath: qsTr("Plugins.Brass Fingering")

property variant seperator: "\n";
property variant offsetFactor: -2.3;

property variant verbose: false;

property variant baseKey: -2;

property variant noteTable: {
    26: {fingering: "123"}, // E
    27: {fingering: "13"}, // F 
    28: {fingering: "23"}, // Gb
    29: {fingering: "12"}, // G
    30: {fingering: "1"}, // Ab
    31: {fingering: "2"}, // A
    32: {fingering: "0"}, // Bb
    33: {fingering: "123"}, // B
    34: {fingering: "13"}, // C
    35: {fingering: "23"}, // Db
    36: {fingering: "12"}, // D
    37: {fingering: "1"}, // Eb
    38: {fingering: "2"}, // E
    39: {fingering: "0"}, // F
    40: {fingering: "23"}, // Gb
    41: {fingering: "12"}, // G
    42: {fingering: "1", slide: "3"}, // Ab
    43: {fingering: "2", slide: "2"}, // A
    44: {fingering: "0", slide: "1"}, // Bb
    45: {fingering: "12", slide: "7\n2"}, // B
    46: {fingering: "1", slide: "6\n1"}, // C
    47: {fingering: "2", slide: "5"}, // Db
    48: {fingering: "0", slide: "4"}, // D
    49: {fingering: "1", slide: "3"}, // Eb
    50: {fingering: "2", slide: "2"}, // E
    51: {fingering: "0", slide: "1"}, // F
    52: {fingering: "23", slide: "5"}, // Gb
    53: {fingering: "12", slide: "4"}, // G
    54: {fingering: "1", slide: "3"}, // Ab
    55: {fingering: "2", slide: "2"}, // A
    56: {fingering: "0", slide: "1"}, // Bb
    57: {fingering: "123", slide: "4"}, // B
    58: {fingering: "13", slide: "3"}, // C <-----
    59: {fingering: "23", slide: "2"}, // Db
    60: {fingering: "12", slide: "1\n4"}, // D
    61: {fingering: "1", slide: "3"}, // Eb
    62: {fingering: "2", slide: "2"}, // E
    63: {fingering: "0", slide: "1"}, // F
    64: {fingering: "23", slide: "3"}, // Gb
    65: {fingering: "12", slide: "2\n4"}, // G
    66: {fingering: "1", slide: "3\n1"}, // Ab
    67: {fingering: "2", slide: "2"}, // A
    68: {fingering: "0", slide: "1"}, // Bb
    69: {fingering: "12"}, // B
    70: {fingering: "1"}, // C
    71: {fingering: "2"}, // Db
    72: {fingering: "0"}, // D
    73: {fingering: "1"}, // Eb
    74: {fingering: "2"}, // E
    75: {fingering: "0"}, // F
    76: {fingering: "23"}, // Gb
    77: {fingering: "12"}, // G
    78: {fingering: "1"}, // Ab
    79: {fingering: "2"}, // A
    80: {fingering: "0"}, // Bb
    81: {fingering: "12"}, // B
    82: {fingering: "1"}, // C
    83: {fingering: "2"}, // Db
    84: {fingering: "0"}, // D
}

function getNoteName (tpc) {
    var noteName = "";
    switch (tpc) {
        case -1: noteName = qsTranslate("InspectorAmbitus", "Fbb") + noteName; break;
        case  0: noteName = qsTranslate("InspectorAmbitus", "Cbb") + noteName; break;
        case  1: noteName = qsTranslate("InspectorAmbitus", "Gbb") + noteName; break;
        case  2: noteName = qsTranslate("InspectorAmbitus", "Dbb") + noteName; break;
        case  3: noteName = qsTranslate("InspectorAmbitus", "Abb") + noteName; break;
        case  4: noteName = qsTranslate("InspectorAmbitus", "Ebb") + noteName; break;
        case  5: noteName = qsTranslate("InspectorAmbitus", "Bbb") + noteName; break;
        case  6: noteName = qsTranslate("InspectorAmbitus", "Fb")  + noteName; break;
        case  7: noteName = qsTranslate("InspectorAmbitus", "Cb")  + noteName; break;

        case  8: noteName = qsTranslate("InspectorAmbitus", "Gb")  + noteName; break;
        case  9: noteName = qsTranslate("InspectorAmbitus", "Db")  + noteName; break;
        case 10: noteName = qsTranslate("InspectorAmbitus", "Ab")  + noteName; break;
        case 11: noteName = qsTranslate("InspectorAmbitus", "Eb")  + noteName; break;
        case 12: noteName = qsTranslate("InspectorAmbitus", "Bb")  + noteName; break;
        case 13: noteName = qsTranslate("InspectorAmbitus", "F")   + noteName; break;
        case 14: noteName = qsTranslate("InspectorAmbitus", "C")   + noteName; break;
        case 15: noteName = qsTranslate("InspectorAmbitus", "G")   + noteName; break;
        case 16: noteName = qsTranslate("InspectorAmbitus", "D")   + noteName; break;
        case 17: noteName = qsTranslate("InspectorAmbitus", "A")   + noteName; break;
        case 18: noteName = qsTranslate("InspectorAmbitus", "E")   + noteName; break;
        case 19: noteName = qsTranslate("InspectorAmbitus", "B")   + noteName; break;

        case 20: noteName = qsTranslate("InspectorAmbitus", "F♯")  + noteName; break;
        case 21: noteName = qsTranslate("InspectorAmbitus", "C♯")  + noteName; break;
        case 22: noteName = qsTranslate("InspectorAmbitus", "G♯")  + noteName; break;
        case 23: noteName = qsTranslate("InspectorAmbitus", "D♯")  + noteName; break;
        case 24: noteName = qsTranslate("InspectorAmbitus", "A♯")  + noteName; break;
        case 25: noteName = qsTranslate("InspectorAmbitus", "E♯")  + noteName; break;
        case 26: noteName = qsTranslate("InspectorAmbitus", "B♯")  + noteName; break;
        case 27: noteName = qsTranslate("InspectorAmbitus", "F♯♯") + noteName; break;
        case 28: noteName = qsTranslate("InspectorAmbitus", "C♯♯") + noteName; break;
        case 29: noteName = qsTranslate("InspectorAmbitus", "G♯♯") + noteName; break;
        case 30: noteName = qsTranslate("InspectorAmbitus", "D♯♯") + noteName; break;
        case 31: noteName = qsTranslate("InspectorAmbitus", "A♯♯") + noteName; break;
        case 32: noteName = qsTranslate("InspectorAmbitus", "E♯♯") + noteName; break;
        case 33: noteName = qsTranslate("InspectorAmbitus", "B♯♯") + noteName; break;
        default: noteName = qsTr("?")   + noteName; break;
    } 
    return noteName;

}

function log(msg) {
if (verbose)
console.log(msg);
}

function getFingering(instrument, notes) {
    var sections = instrument.split(".");
    if (sections == "undefined" || sections.length < 1)
        return "";
    var mode = sections[1] == "trombone" ? "slide" : "fingering";

    var text = "";
    for (var i = 0; i < notes.length; i++) {
        if (text != "")
            text += seperator

        var index = notes[i].pitch + baseKey;
        log("Pitch: " + index + " | NoteName: " + getNoteName(notes[i].tpc));
        if (index in noteTable  && notes[i].tieBack == null)
            if (mode in noteTable[index])
                text += qsTr(noteTable[index][mode]);
    }
    return text;
}

onRun: {
    if (typeof curScore === 'undefined')
        Qt.quit();
    var cursor = curScore.newCursor();
    var startStaff;
    var endStaff;
    var endTick;
    var fullScore = false;
    cursor.rewind(1);
    if (!cursor.segment) {
        fullScore = true;
        startStaff = 0;
        endStaff = curScore.nstaves - 1;
    } else {
        startStaff = cursor.staffIdx;
        cursor.rewind(2);
        if (cursor.tick == 0) {
            // this happens when the selection includes
            // the last measure of the score.
            // rewind(2) goes behind the last segment (where
            // there's none) and sets tick=0
            endTick = curScore.lastSegment.tick + 1;
        } else {
            endTick = cursor.tick;
        }
        endStaff = cursor.staffIdx;
    }

    for (var staff = startStaff; staff <= endStaff; staff++) {
        cursor.rewind(1)
        cursor.voice = 0;
        cursor.staffIdx = staff;

        if (fullScore)  // no selection
            cursor.rewind(0); // beginning of score

        var instrument = curScore.parts[staff].instrumentId;
        if (instrument.substring(0, 6) != "brass.") {
            log("Skipped instrument: " + instrument)
            continue;
        }

        while (cursor.segment && (fullScore || cursor.tick < endTick)) {
            if (!cursor.element || cursor.element.type != Element.CHORD) {
                cursor.next();
                continue;
            }

            var fingering = getFingering(instrument, cursor.element.notes);
            if (fingering) {
                var text = newElement(Element.STAFF_TEXT);
                text.text = fingering;
                text.pos.y = (cursor.element.notes.length - 1) * offsetFactor;
                cursor.add(text);
            }

            cursor.next();
        }
    }

    Qt.quit();
}   

}


Comments

In reply to by Vedras

It's probably possible to edit the plugin and change wherever it might say "above" to "below", but failing that, simply select one fingering, press "X" to flip it below, then click the set as style button ("S" icon) next to Placement in the Inspector.

EDIT: I see now, it's using staff text rather than fingering, and not setting the placement explicitly, but probably someone who knows the plugin framework better could advise on how to adjust this to set the placement to be "below" directly.

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