How to Generate Animation (blink led feedback) ?

1

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

Hellem Answered question
0

With some midi controllers you can active blinking by sends a specific MIDI velocity to the input.

The HumaniZer Posted new comment

What if my controller doesn’t have just one input

midi note XX on Velocity 127 = led on
midi note XX off Velocity 0 = led off

I’m not sure what you mean, pretty much every midi controller has more than one input.

My interface responds as follows:

When at input a NOTE ON with a velocity of 127 is detected the LED of the corresponding midi note is lit

When input a NOTE OFF with a velocity of 0 and detect the corresponding LED is off

ok it’s easier to create an animation for a particular note velocity

0

I am also missing sort of „timer instance“. That could be created by an action, or so.  And then you have a reaction, that can react, every time the timer counted down.

Where you could specify, if you had a once-only timer, or a repeating timer, until it was turned off explicitly.

… and an ability, where you could determine the „hold time“ of a button, when it is released. To have a different behaviour in a script for „long presses“ or something.  But mayby, this is already implemented.

Florin Wach Answered question
0

For a blinking tempo synced beat related you can use this:

Listeners:

self.song().add_current_song_time_listener

Condition: define what you want

Action:

t = self.song().get_current_beats_song_time()
 s = str(t).replace(",", ".")
parts = s.split(".")
 if len(parts) >= 3 and parts[2].isdigit():
    sub = int(parts[2])
else:
    beats_f = float(t)
    sub = int((beats_f % 1.0) * 4) + 1
 if sub < 1:
    sub = 1
elif sub > 4:
    sub = 4
 if sub == 1:
    self.midi_cc_ch_0_val_16.send_value(127)
elif sub == 3:
    self.midi_cc_ch_0_val_16.send_value(0)

Right now i am trying to make it work with not listening to song_timer.

Hellem Edited answer
0

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

Hellem Changed status to publish