Browse Source

support key labels. prepare cc labels, no GUI for that yet

master
Nils 3 years ago
parent
commit
26c1d5c2be
  1. 15
      engine/instrument.py
  2. BIN
      engine/resources/000 - Default.tembro
  3. 4
      template/calfbox/sampler_layer.c

15
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 <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

BIN
engine/resources/000 - Default.tembro

Binary file not shown.

4
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 <control>
{ "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);
}

Loading…
Cancel
Save