Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nozomu-y committed Nov 5, 2022
1 parent d09ddd0 commit e261316
Showing 1 changed file with 74 additions and 45 deletions.
119 changes: 74 additions & 45 deletions movable-do.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,79 @@ MuseScore {
property real fontSizeMini: 0.7

function nameChord(notes, text, small, movableDoOffset, notationIndex) {
var movableDo = []
switch (notationIndex) {
case 0:
movableDo = ['d', 'di', 'ro', 'r', 'ri', 'ma', 'm', 'f', 'fi', 'se', 's', 'si', 'lo', 'l', 'li', 'ta', 't']
break
case 1:
movableDo = ['', 'ド♯','レ♭', '', 'レ♯', 'ミ♭', '', 'ファ', 'ファ♯','ソ♭', '', 'ソ♯','ラ♭', '', 'ラ♯','シ♭', '']
break
var tpcToTonalPitch= {
"31": "A##",
"19": "B",
"7": "Cb",
"24": "A#",
"12": "Bb",
"0": "Cbb",
"29": "G##",
"17": "A",
"5": "Bbb",
"22": "G#",
"10": "Ab",
"27": "F##",
"15": "G",
"3": "Abb",
"32": "E##",
"20": "F#",
"8": "Gb",
"25": "E#",
"13": "F",
"1": "Gbb",
"30": "D##",
"18": "E",
"6": "Fb",
"23": "D#",
"11": "Eb",
"-1": "Fbb",
"28": "C##",
"16": "D",
"4": "Ebb",
"33": "B##",
"21": "C#",
"9": "Db",
"26": "B#",
"14": "C",
"2": "Dbb"
}
var tpc2pitch = {
"31": 16,
"24": 14,
"29": 13,
"22": 11,
"27": 10,
"32": 8,
"25": 7,
"30": 6,
"23": 4,
"28": 3,
"33": 1,
"26": 0,
"19": 16,
"12": 15,
"17": 13,
"15": 10,
"20": 8,
"13": 7,
"18": 6,
"11": 5,
"16": 3,
"21": 1,
"14": 0,
"7": 16,
"0": 15,
"5": 13,
"10": 12,
"3": 10,
"8": 9,
"1": 7,
"6": 6,
"4": 3,
"-1": 5,
"9": 2,
"2": 0
var tonalPitchToMovableDo = {
'A##': ['t', ''],
'A#': ['li', 'ラ♯'],
'G##': ['l', ''],
'G#': ['si', 'ソ♯'],
'F##': ['s', ''],
'E##': ['fi', 'ファ♯'],
'E#': ['f', 'ファ'],
'D##': ['m', ''],
'D#': ['ri', 'レ♯'],
'C##': ['r', ''],
'B##': ['di', 'ド♯'],
'B#': ['d', ''],
'B': ['t', ''],
'Bb': ['ta', 'シ♭'],
'A': ['l', ''],
'G': ['s', ''],
'F#': ['fi', 'ファ♯'],
'F': ['f', 'ファ'],
'E': ['m', ''],
'Eb': ['ma', 'ミ♭'],
'D': ['r', ''],
'C#': ['di', 'ド♯'],
'C': ['d', ''],
'Cb': ['t', ''],
'Cbb': ['ta', 'シ♭'],
'Bbb': ['l', ''],
'Ab': ['lo', 'ラ♭'],
'Abb': ['s', ''],
'Gb': ['se', 'ソ♭'],
'Gbb': ['f', 'ファ'],
'Fb': ['m', ''],
'Ebb': ['r', ''],
'Fbb': ['ma', 'ミ♭'],
'Db': ['ro', 'レ♭'],
'Dbb': ['d', ''],
}
var sep = "\n"
// change to "," if you want them horizontally (anybody?)
Expand All @@ -86,7 +114,8 @@ MuseScore {
if (typeof notes[i].tpc === "undefined")
// like for grace notes ?!?
return
name = movableDo[tpc2pitch[String((parseInt(notes[i].tpc) - movableDoOffset + 35 + 1) % 35 - 1)]]
var tonalPitch = tpcToTonalPitch[String((parseInt(notes[i].tpc) - movableDoOffset + 35 + 1) % 35 - 1)]
name = tonalPitchToMovableDo[tonalPitch][notationIndex]

text.text = name + oct + text.text
}
Expand Down

0 comments on commit e261316

Please sign in to comment.