importtemplate.engine.api#we need direct access to the module to inject data in the provided structures. but we also need the functions directly. next line:
fromtemplate.engine.apiimport*
importtemplate.engine.ly2cboxasly2cbox
#New callbacks
classClientCallbacks(Callbacks):#inherits from the templates api callbacks
def__init__(self):
@ -36,18 +39,22 @@ from template.engine.api import callbacks
#Populate Channel Activity and Channel Instrument Changes midi callbacks
_registerMidiCallbacks()
playTestSignal.patterns={channel:ly2cbox.pattern("c'16 g c",channel)forchannelinrange(1,17)}
playTestSignals={channel:ly2cbox.pattern("c'16 g c",channel)forchannelinrange(1,17)}
#Send initial Data etc.
logger.info("Sending initial callbacks to GUI")
callbacks._soundfontChanged()
callbacks._ignoreProgramChangesChanged()
logger.info("Fluajho api startEngine complete")
def_registerMidiCallbacks():
"""This needs to be a function to delay execution until we have a session and nsm loaded
ourdata."""
@ -76,6 +83,7 @@ def _registerMidiCallbacks():
#Sampler
playTestSignals:Dict[int,bytes]={}#channel:cboxPatternBytes patterns are defined in startEngine because we obviously need to wait for cbox to be ready.
raiseValueError(f"Midi Channel must be between 1 and 16 inclusive. Yours is {channel}")
callbacks._channelActivity(channel)
session.data.midiInput.scene.play_pattern(playTestSignal.patterns[channel],150.0,id=channel)#If there is already an adhoc pattern with a given non-zero id, stop it and release all the pending notes. Retry until all the notes are released.
session.data.midiInput.scene.play_pattern(playTestSignals[channel],150.0,id=channel)#If there is already an adhoc pattern with a given non-zero id, stop it and release all the pending notes. Retry until all the notes are released.