How to Generate Animation (blink led feedback) ?
Hello
There is a timer that can call callback functions in the scripts ?
There is a command creating a reaction when selected clip is playing ?
Thanks
Here is a working example of blink behavior with no time listener. Tempo relative, beat oriented for a clip_slot state.
We need to define a function for blinking in the reaction. All is in one reaction.
Listeners:
self.song().tracks[self.track_num(0)].clip_slots[self.scene_num(0)].add_has_clip_listener
For a function definition we use a separate Action block 1 –
Actions:
def MultiBlinking(clip_slot, on_value, off_value, stop_condition):
# Get the current position within the bar
beat_time = self.song().get_current_beats_song_time()
parts = str(beat_time).replace(",", ".").split(".")
sub_beat = int(parts[2]) if len(parts) >= 3 and parts[2].isdigit() else 1
# Check stop condition
if stop_condition():
# If the condition is met, exit the function
return
# If this is the main beat (e.g. sub_beat == 1) — send the "on" value
if sub_beat == 1:
self.midi_cc_ch_0_val_16.send_value(on_value)
# If this is the secondary beat (e.g. sub_beat == 3) — send the "off" value
elif sub_beat == 3:
self.midi_cc_ch_0_val_16.send_value(off_value)
# Schedule the next call to continue blinking
self.schedule_message(
1,
lambda: MultiBlinking(clip_slot, on_value, off_value, stop_condition)
)
Then we need to add another action block that will trigger the function. I used next:
Action Block 2 –
Conditions:
self.song().tracks[self.track_num(0)].clip_slots[self.scene_num(0)].has_clip == False
self.song().tracks[self.track_num(0)].clip_slots[self.scene_num(0)].will_record_on_start == True
Actions:
# Get the index of the current track and scene track_index = self.get_sessbox_track_offset() + 0 scene_index = self.get_sessbox_scene_offset() + 0 # Get the required clip slot clip_slot = self.song().tracks[track_index].clip_slots[scene_index] # Now call the MultiBlinking function with this clip_slot MultiBlinking( clip_slot=clip_slot, on_value=57, off_value=0, stop_condition=lambda: not clip_slot.will_record_on_start )
And now it is blinking!!
Will test out next for other clip states in same reaction. I suppose that same function can be used for other clip_slot states.
Tested with other Action Blocks for triggered clip_slot to send out different values – works perfect!!
Sign up
User registration is currently not allowed.