Regarding chain list and chain filtering in ctrldev drivers:
Well, indeed we have a better way for getting this now. The ctrldev_base class now implements a chain filter that you can configure in the constructor with:
# List of chain types to include (empty for all) => ["midi", "audio", "synth", "generator"]
self.chain_type_filter = []
Currently, only “OR” filtering is implemented (union). Having “AND” filtering (intersection) and combination of both would be better, but not a priority.
The base code class will take care of keeping the filtered chain list ready and updated for using by the driver:
self.chain_ids_filtered = []
There are a few related functions too:
def get_filtered_chain_id_by_index(self, index):
"""Get filtered chain ID by index
index - Index in filtered chain list
return: integer
"""
try:
return self.chain_ids_filtered[index]
except:
return None
def get_filtered_chain_by_index(self, index):
"""Get filtered chain by index
index - Index in filtered chain list
return: chain
"""
try:
return self.chain_manager.chains[self.chain_ids_filtered[index]]
except:
return None
def get_filtered_index_by_chain(self, chain):
"""Get index of chain in the filtered chain list
chain - chain to find in filtered list
return: integer
"""
try:
return self.chain_ids_filtered.index(chain.chain_id)
except:
return -1
def get_filtered_index_by_chain_id(self, chain_id):
"""Get index of chain in the filtered chain list
chain - chain to find in filtered list
return: integer
"""
try:
return self.chain_ids_filtered.index(chain_id)
except:
return -1
def get_filtered_midi_chan_by_index(self, index):
"""Get filtered chain MIDI channel by index"""
try:
return self.chain_manager.chains[self.chain_ids_filtered[index]].midi_chan
except:
return None
You can see how all this is used in the ctrldev_zynmixer base class. If you want a more complete (and complex) example, you can check the mackiecontrol driver, that now allows to filter chains using the specific buttons that some devices have.
Regards!