Skip to content

Instantly share code, notes, and snippets.

@bskari
Created October 7, 2019 06:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bskari/d6bc1fbb37855624373c96d156db8225 to your computer and use it in GitHub Desktop.
Save bskari/d6bc1fbb37855624373c96d156db8225 to your computer and use it in GitHub Desktop.
Ocarina fingering plugin for MuseScore
// vim: syntax=javascript
//=============================================================================
// MuseScore
//
// Note fingerings for 4/6 hole ocarina
//
// Contribution Artur Vilà Canal, Joachim Schmitz, BurkardS, Brandon Skari
// Copyright (c) 2011 Karl Gerhards, (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.
//=============================================================================
import QtQuick 2.0
import MuseScore 1.0
MuseScore {
version: "1.0"
description: "This plugin adds ocarina fingering"
menuPath: 'Plugins.Ocarina Fingering'
onRun: {
if (typeof curScore === 'undefined')
qt.Quit();
var sixHole = true; // false for 4 hole
var griff;
if (sixHole) {
griff = function(midi) {
midi -= 20;
var fingering;
switch (midi) {
case 40: fingering = "⠛\n⠉"; break; // C
case 41: fingering = "⠓˚\n⠉"; break; // C#
case 42: fingering = "⠓\n⠉"; break; // D
case 43: fingering = "⠋◦\n⠉"; break; // Eb
case 44: fingering = "⠋\n⠉"; break; // E
case 45: fingering = "⠃\n⠉"; break; // F
case 46: fingering = "⠚\n⠉"; break; // F#
case 47: fingering = "⠒\n⠉"; break; // G
case 48: fingering = "⠊\n⠉"; break; // G#
case 49: fingering = "⠂\n⠉"; break; // A
case 50: fingering = "⠐\n⠉"; break; // Bb
case 51: fingering = "⠈\n⠉"; break; // B
case 52: fingering = "\n⠉"; break; // C
case 53: fingering = "⠐\n⠈"; break; // C#
case 54: fingering = "\n⠈"; break; // D
case 55: fingering = "⠂\n"; break; // Eb
case 56: fingering = "\n˚"; break; // E
default: fingering = "";
}
return "\n" + fingering;
};
} else {
griff = function(midi) {
midi -= 20;
var fingering;
switch (midi) {
case 40: fingering = "⠛"; break; // C
case 41: fingering = "⠓˚"; break; // C#
case 42: fingering = "⠓"; break; // D
case 43: fingering = "⠋◦"; break; // Eb
case 44: fingering = "⠋"; break; // E
case 45: fingering = "⠃"; break; // F
case 46: fingering = "⠚"; break; // F#
case 47: fingering = "⠒"; break; // G
case 48: fingering = "⠊"; break; // G#
case 49: fingering = "⠂"; break; // A
case 50: fingering = "⠐"; break; // Bb
case 51: fingering = "⠈"; break; // B
case 52: fingering = ""; break; // C
default: fingering = "";
}
return "\n" + fingering;
};
}
var cursor = curScore.newCursor();
cursor.staffIdx = 0;
cursor.voice = 0;
cursor.rewind(0); // set cursor to first chord/rest
var textold = "xxx";
while (cursor.segment) {
if (cursor.element && cursor.element.type == Element.CHORD) {
var text = newElement(Element.STAFF_TEXT)
text.text = griff(cursor.element.notes[0].pitch);
text.pos.y = 9;
if (text.text != textold)
cursor.add(text);
textold = text.text;
if (text.text = textold)
cursor.add(text);
textold = text.text;
}
cursor.next();
}
Qt.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment