Skip to content

Commit 0479dbe

Browse files
committed
Better articulation matching
1 parent dcc7934 commit 0479dbe

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

UACC List.csv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1,long,note-whole,Generic,Sustain,Long,,
1+
1,long,note-whole,Generic,Sustain,Long,Non Vib,
22
2,long,alt-wave,Alternative,Air,,,
33
3,long,note-whole,Octave,8ves,8va,,
44
4,long,note-whole,Octave muted,,,,
@@ -13,7 +13,7 @@
1313
13,long,tremolo,Tremolo soft,Tremolo low,,,
1414
14,long,tremolo,Tremolo hard,Tremolo high,,,
1515
15,long,tremolo-sul-pont,Tremolo sul,Tremolo muted low,,,
16-
16,long,vibrato,Vibrato,Molto,Pulses,,
16+
16,long,vibrato,Vibrato,Molto,Pulses,Vib,
1717
17,long,sul-tasto,Higher,Sul Tasto,Bells Up,,
1818
18,long,sul-pont,Lower,Sul Ponticello,,,
1919
19,long,,Lower muted,,,,
@@ -74,12 +74,12 @@
7474
74,textured,trill-perf4,Trill perf 4th,Trill Perfect,,,
7575
75,textured,multitongued,Multitongue,Double Tongue,,,
7676
76,textured,multitongued,Multitongue muted,,,,
77-
77,,,,,,,
77+
77,textured,vibrato-molto,,Mordent,Ornament,,
7878
78,,,,,,,
7979
79,,,,,,,
80-
80,textured,phrase,Synced - 120bpm (trem/trill),Slow,,,
81-
81,textured,phrase,Synced - 150bpm (trem/trill),Medium,Phrase,,
82-
82,textured,phrase,Synced - 180bpm (trem/trill),Fast,,,
80+
80,textured,phrase,Synced - 120bpm (trem/trill),,,,
81+
81,textured,phrase,Synced - 150bpm (trem/trill),Medium,Phrase,bpm,
82+
82,textured,phrase,Synced - 180bpm (trem/trill),,,,
8383
83,,,,,,,
8484
84,,,,,,,
8585
85,,,,,,,

main.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from pathlib import Path, PurePath
33

44
class ArticulationBank:
5+
merged_result = ""
6+
57
def __init__(self, source_file_path) -> None:
68
self.root = untangle.parse(source_file_path)
79
self.articulation_list = []
@@ -11,6 +13,7 @@ def __init__(self, source_file_path) -> None:
1113

1214
def GenerateHeader(self):
1315
header = f'//! g="Converted Maps" n="{self.bank_name}"\nBank * * {self.bank_name}\n'
16+
ArticulationBank.merged_result += header
1417
return header
1518

1619
def GenerateArticulations(self):
@@ -19,6 +22,7 @@ def GenerateArticulations(self):
1922
if (art.art_action is not None):
2023
articulations += f'//! c={art.art_color} i={art.art_icon} o={art.art_action}\n{art.art_progchange} {art.art_name}\n'
2124

25+
ArticulationBank.merged_result += articulations + "\n"
2226
return articulations
2327

2428
def ParseArticulations(self):
@@ -87,14 +91,21 @@ def FindUACC(art_name):
8791

8892
def FindUACC2(art_name):
8993
pc, color, icon = "127", "default", "note-quarter"
94+
match, match_candidate = "", ""
95+
match_score, cur_match_score = 0, 0
9096

9197
for i in UACCList.reader:
92-
match = difflib.get_close_matches(art_name, i["names"])
98+
match_candidate = difflib.get_close_matches(art_name, i["names"], cutoff=0.2)
99+
100+
if (len(match_candidate) > 0):
101+
cur_match_score = difflib.SequenceMatcher(None, match_candidate[0], art_name).ratio()
102+
103+
if (cur_match_score > match_score):
104+
match = match_candidate[0]
105+
match_score = cur_match_score
106+
cur_match_score = 0
93107

94-
if (len(match) > 0):
95108
pc, color, icon = i["id"], i["color"], i["icon"]
96-
else:
97-
pass
98109

99110
UACCList.uacc_file.seek(0)
100111
return pc, color, icon
@@ -118,9 +129,19 @@ def ConvertExpressionMaps():
118129

119130
FileOps.ExportReabank(result, map)
120131

132+
def ExportMergedReabank():
133+
export_path = PurePath(Path.cwd(), "Reabank Export", "Merged Export.reabank")
134+
file = open(Path(export_path), "w")
135+
file.write(ArticulationBank.merged_result)
136+
file.close
137+
121138
def FindExpressionMaps():
122139
FileOps.expression_maps = sorted(Path.cwd().rglob('*.expressionmap'))
140+
print(str(len(FileOps.expression_maps))+" expression maps found...")
123141

142+
print("EXPRESSIONMAP TO REATICULATE CONVERTER")
143+
print("Starting conversion...")
124144
FileOps.FindExpressionMaps()
125145
FileOps.ConvertExpressionMaps()
146+
#FileOps.ExportMergedReabank()
126147
input("Conversion complete. Press a key to continue...")

0 commit comments

Comments
 (0)