-
Notifications
You must be signed in to change notification settings - Fork 0
/
doBanksDiffer.py
executable file
·129 lines (94 loc) · 4.73 KB
/
doBanksDiffer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/python3
# coding=UTF8
import sys
import lib.NonlinearLabsBankTools as NonlinearLabsBankTools
import lib.ids
def readable(id: str) -> str:
if id.find("-") != -1:
number = id.split("-")[1]
return str(lib.ids.ParameterNumber(int(number)))
else:
return str(lib.ids.ParameterNumber(int(id)))
def banksDiffer(bank1: NonlinearLabsBankTools.NLParser, bank2: NonlinearLabsBankTools.NLParser, verbose: bool = False) -> bool:
hadDiff = False
banks1 = bank1.getBanks()
banks2 = bank2.getBanks()
if len(banks1) != 1 or len(banks2) != 1:
if verbose:
print(f"banks have different sizes: {len(banks1)} != {len(banks2)}")
hadDiff |= True
return True
banks1 = banks1[0]
banks2 = banks2[0]
if banks1.getVersion() != banks2.getVersion():
if verbose:
print(f"banks have different versions: {banks1.getVersion()} != {banks2.getVersion()}")
hadDiff |= True
print(f"banks1: {banks1.getName()}")
print(f"banks2: {banks2.getName()}")
for preset in banks1.getPresets():
presetHadDiff = False
otherPreset = banks2.findPreset(preset.getName())
if otherPreset == None:
if verbose:
print(f"{banks1.getName()}-{preset.getName()} not found in {banks2.getName()}")
hadDiff |= True
presetHadDiff |= True
continue
for parameter in preset.getParameters():
otherParameter = otherPreset.findParameter(parameter.getID())
if otherParameter == None:
if verbose:
print(f"{banks1.getName()}: {preset.getName()} Parameter with ID: {parameter.getID()} not found in {otherPreset.getName()}")
hadDiff |= True
presetHadDiff |= True
continue
doKeyCheck = False
if doKeyCheck:
myKeyCount = len(parameter.getKeys())
otherKeyCount = len(otherParameter.getKeys())
if myKeyCount != otherKeyCount:
if verbose:
print(f"{banks1.getName()}: {preset.getName()} Parameter-Keys for {parameter.getID()} differ: {myKeyCount} != {otherKeyCount}. This is most likely a redefinition of a parameter (Modulate/Unmodulateable).")
myKeys = " ".join(parameter.getKeys())
otherKeys = " ".join(otherParameter.getKeys())
if verbose:
print(f"keys for parameter of the first argument: {myKeys}")
print(f"keys for parameter of the second argument: {otherKeys}")
hadDiff |= True
presetHadDiff |= True
myValue = parameter.getNodeValue("value")
otherValue = otherParameter.getNodeValue("value")
if myValue != otherValue:
if verbose:
print(f"{preset.getName()}: {readable(parameter.getID())} Parameter-Value: {myValue} != {otherValue}")
hadDiff |= True
presetHadDiff |= True
if otherParameter.getNodeValue("pedalMode") != parameter.getNodeValue("pedalMode"):
if verbose:
print(f"{preset.getName()}: {parameter.getID()} Pedal-Mode: {parameter.getNodeValue('pedalMode')} != {otherParameter.getNodeValue('pedalMode')}")
hadDiff |= True
presetHadDiff |= True
if otherParameter.getNodeValue("modSrc") != parameter.getNodeValue("modSrc"):
if verbose:
print(f"{preset.getName()}: {parameter.getID()} mod-source: {parameter.getNodeValue('modSrc')} != {otherParameter.getNodeValue('modSrc')}")
hadDiff |= True
presetHadDiff |= True
if otherParameter.getNodeValue("modAmount") != parameter.getNodeValue("modAmount"):
if verbose:
print(f"{preset.getName()}: {parameter.getID()} modulation-amount: {parameter.getNodeValue('modAmount')} != {otherParameter.getNodeValue('modAmount')}")
hadDiff |= True
presetHadDiff |= True
if presetHadDiff:
print(f"{preset.getName()} has differences!")
return hadDiff
if len(sys.argv) < 2:
print("use: ./doBanksDiffer.py bank1 bank2")
exit(1)
import os
verbose = os.environ.get('VERBOSE', False)
bank1 = sys.argv[1]
bank2 = sys.argv[2]
b1 = NonlinearLabsBankTools.NLParser(bank1)
b2 = NonlinearLabsBankTools.NLParser(bank2)
print(f"Banks differ: {banksDiffer(b1, b2, verbose)}")