|
| 1 | +//============================================================================= |
| 2 | +// MuseScore |
| 3 | +// Harmonica plugin |
| 4 | +// |
| 5 | +// Copyright (C)2012 lasconic |
| 6 | +// |
| 7 | +// This program is free software; you can redistribute it and/or modify |
| 8 | +// it under the terms of the GNU General Public License version 2. |
| 9 | +// |
| 10 | +// This program is distributed in the hope that it will be useful, |
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +// GNU General Public License for more details. |
| 14 | +// |
| 15 | +// You should have received a copy of the GNU General Public License |
| 16 | +// along with this program; if not, write to the Free Software |
| 17 | +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | +//============================================================================= |
| 19 | + |
| 20 | + // 57A A# B C C# D D# E F F# G G# |
| 21 | +var holes = ["+1", "", "-2", "", "+3", "" , "", "-4", "", "", "-6", "", |
| 22 | + "+7", "", "-8", "", "+9", "-10", "", "+11", "", "-12", "-14", "", |
| 23 | + "+13", "", "-16","", "+15", "", "-18", "+17", "", "-20", "", "", |
| 24 | + "+19" |
| 25 | +]; |
| 26 | + |
| 27 | +var shift = 57; |
| 28 | + |
| 29 | + |
| 30 | +function applyFingerings(score, fingerings, shift) |
| 31 | + { |
| 32 | + var cursor = new Cursor(score); |
| 33 | + cursor.staff = 0; |
| 34 | + cursor.voice = 0; |
| 35 | + cursor.rewind(); // set cursor to first chord/rest |
| 36 | + while (!cursor.eos()) { |
| 37 | + if (cursor.isChord()) { |
| 38 | + var pitch = cursor.chord().topNote().pitch; |
| 39 | + var index = pitch - shift; |
| 40 | + if(index >= 0 && index < fingerings.length){ |
| 41 | + var textString = fingerings[index]; |
| 42 | + if (textString.length > 0) { |
| 43 | + var text = new Text(curScore); |
| 44 | + text.text = textString; |
| 45 | + text.yOffset = 6; |
| 46 | + text.xOffset = -1; |
| 47 | + cursor.putStaffText(text); |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + cursor.next(); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | +//--------------------------------------------------------- |
| 56 | +// init |
| 57 | +//--------------------------------------------------------- |
| 58 | + |
| 59 | +function init() |
| 60 | + { |
| 61 | + } |
| 62 | + |
| 63 | +//------------------------------------------------------------------- |
| 64 | +// run |
| 65 | +//------------------------------------------------------------------- |
| 66 | + |
| 67 | +function run() |
| 68 | + { |
| 69 | + applyFingerings(curScore, holes, shift); |
| 70 | + } |
| 71 | + |
| 72 | +var mscorePlugin = { |
| 73 | + menu: 'Plugins.Harmonica Tablature.Hohner Highlander, A side', |
| 74 | + init: init, |
| 75 | + run: run |
| 76 | + }; |
| 77 | + |
| 78 | +mscorePlugin; |
| 79 | + |
0 commit comments