@ -122,7 +122,9 @@ class Instrument(object):
self . currentKeySwitch : int = None # Midi pitch. Default is set on load.
self . playableKeys : tuple = None #sorted tuple of ints. set by _parseKeys through chooseVariant. Set of int pitches. Used for export.
self . keyLabels = { 60 : " Middle C " , 53 : " 𝄢 " , 67 : " 𝄞 " }
self . controlLabels = { } #CC int:str opcode label_cc# in <control>
self . keyLabels = { } #Pitch int:str opcode label_key# in <control>
def exportStatus ( self ) - > dict :
""" The call-often function to get the instrument status. Includes only data that can
@ -143,6 +145,7 @@ class Instrument(object):
result [ " currentKeySwitch " ] = self . currentKeySwitch
result [ " playableKeys " ] = self . playableKeys
result [ " keyLabels " ] = self . keyLabels
result [ " controlLabels " ] = self . controlLabels #CCs
return result
def exportMetadata ( self ) - > dict :
@ -304,6 +307,7 @@ class Instrument(object):
return
def findKS ( data , writeInResult , writeInOthers ) :
if " sw_label " in data :
label = data [ " sw_label " ]
#remove leading int or key from label
@ -333,6 +337,7 @@ class Instrument(object):
def findPlayableKeys ( data : dict , writeInResult : set ) :
""" Playable keys can be on any level. Mostly groups and regions though. """
if " key " in data :
notePitch : int = midiName2midiPitch [ data [ " key " ] ]
writeInResult . add ( notePitch )
@ -357,7 +362,6 @@ class Instrument(object):
hierarchy = self . program . get_hierarchy ( ) #starts with global and dicts down with get_children(). First single entry layer is get_global()
allKeys = set ( )
for k , v in hierarchy . items ( ) : #Global
globalData = k . as_dict ( )
swlokeyValue = globalData [ " sw_lokey " ] if " sw_lokey " in globalData else " "
@ -379,6 +383,13 @@ class Instrument(object):
findKS ( k3AsDict , result , others )
self . playableKeys = tuple ( sorted ( allKeys ) )
self . controlLabels = self . program . get_control_labels ( ) #opcode label_cc# in <control>
self . keyLabels = self . program . get_key_labels ( ) #opcode label_cc# in <control>
#Add some defaults.
for k , v in { 60 : " Middle C " , 53 : " 𝄢 " , 67 : " 𝄞 " } . items ( ) :
if not k in self . keyLabels :
self . keyLabels [ k ] = v
logger . info ( f " Finished parsing possible keyswitches in the current variant/cbox-program for { self . name } { self . currentVariant } . Found: { len ( result ) } keyswitches. " )
if not result :
return None