From 26c1d5c2be423d40eeb8df4eb8521ca21ee312f7 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 20 Feb 2022 19:47:02 +0100 Subject: [PATCH] support key labels. prepare cc labels, no GUI for that yet --- engine/instrument.py | 15 +++++++++++++-- engine/resources/000 - Default.tembro | Bin 20480 -> 20480 bytes template/calfbox/sampler_layer.c | 4 +--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/engine/instrument.py b/engine/instrument.py index f0ab3fc..aafebef 100644 --- a/engine/instrument.py +++ b/engine/instrument.py @@ -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 + self.keyLabels = {} #Pitch int:str opcode label_key# in + 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 + self.keyLabels = self.program.get_key_labels() #opcode label_cc# in + #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 diff --git a/engine/resources/000 - Default.tembro b/engine/resources/000 - Default.tembro index 846869356a49eb6b141742e48cee905da1f3c225..1a37b1ef1c276407a3797ded373294666b15556d 100644 GIT binary patch delta 857 zcma)4&u-H&9IkJ}NNlJDb<>303L%8hWIK*cB?98M3nvg9*G6Ue(onxzv{Rp!p8Vq0|4^;HlUBE+GX0otm@wH{rBbcaEj&l31dT8F8xXgw& z(?#?OdA41Zpj4O0bLf#lsgib7D)SWSVXPBnkSr3^H+Gb!{o7m6%DrmN^yli!8SY3h zS^L^3}?O0Z!p>T(sh$B6Ba})66WG6;s1!)bYdPj zeBF@46R(Ac8<{~4-*@=%YCh*4AF>V z1GK?$tP5M}`~^h0+*SFGOP3EK#_;yh@+yvT^jat5eWh{;pOgV!93!fO)W7wT?<$s?DSXyg?*ht#h_qx*j? I&*ORT4-aGSoB#j- delta 380 zcmY+=ze>YU6vy$LMZ`g*B@#vIRm34kIp_X4XVKEp*C<$uptiIW*MjZhRFlQA;3H)5 zMSOuiiT5UrwwXWo`{QJ`g4qg|Z>KEQMr27?J8fAaBoc>_!kplt0Qfn~r$=elcyDeS zi=HZ4deNLiq9rs4g^dV@hGG6|#QRXRj@R&^;w+h;7}DjUh!OuNXted>7sPNr7!RkT z&VlmZ?YKX99KLkar1v~}>ffc4-fQul-b3Dn&+KfG7}}b~5M!=m1(egRYFaH4&Hvad xk4gL;n_EkKS>Y>R#u{5h7qHWA7hhNS#^ds)@CPhXC~NfZcgpScMbT}?d%q1RSyTW3 diff --git a/template/calfbox/sampler_layer.c b/template/calfbox/sampler_layer.c index 4386738..bea11ec 100644 --- a/template/calfbox/sampler_layer.c +++ b/template/calfbox/sampler_layer.c @@ -482,8 +482,7 @@ struct sampler_layer_param_entry sampler_layer_params[] = { FIELD_NONFUNCTIONAL("master_label") //ARIA FIELD_NONFUNCTIONAL("global_label") //ARIA FIELD_NONFUNCTIONAL("sw_label") //Keyswitch. ARIA - FIELD_NONFUNCTIONAL("label_cc#") //ARIA - FIELD_NONFUNCTIONAL("label_key#") //sfizz opcode + //label_cc and label_key are in sfzloader.c because they are under { "genericmod_#_#_#_#", -1, slpt_generic_modulation, 0, 0, NULL, NULL, NULL }, }; @@ -2105,4 +2104,3 @@ void sampler_layer_update(struct sampler_layer *l) cbox_rt_execute_cmd_async(l->module->module.rt, &rtcmd, lcmd); } -