python delay message

201 viewsCSS Questionsdelay python
0

Hi!

i want to send midisysex message with a delay

i have tried

<code><span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="c1"># Sleep for 3 seconds</span></code>

self._send_midi()

but it freezes whole ableton...
how can message be sent after a small delay?
Glenn Verhaeghe Answered question June 22, 2024

or how to add delay for an action?

0

I’m not entirely sure but I don’t think it can be done natively in CSS with how the code is processed. This is how i think it’s processed: in Ableton’s main loop, Ableton checks MIDI messages. If you were to code with a delay to those messages, then the main loop is put on hold for that time, freezing Ableton.

One possible workaround, that I haven’t tested myself, would be to make a 3 second empty clip in ableton, start the clip after a certain action is activated, then when the clip ends, it activates another action (for example).

Another possible workaround would be to save a starting time, then constantly activate an action that checks if the current run through Ableton’s main loop is 3 seconds later than that starting time stamp. If not, the action does nothing. If it is, then the action activates whatever you want it to activate. It is possible to save dictionaries and lists in modifiers, wherein you can save any settings.

This is just of the top of my head. It might not work when you try to implement it.

Hellem Posted new comment June 23, 2024

In all that cases we need to do unnecessary stuff…
I can create max4live device with a reader from event and add delay function for a desired lag… I hope there is a way to do delay natively in CSS…

The aim is to transfer parameters names for Ha-lion plugin. I send PC message – and parameters are changing. Also there is a parameter called program change – and it displays the current loaded program. The issue is that listener is set up for parameters changing and it transfers the last parameter but not the current cus Ha-lion needs some time in milliseconds to load patch. So now my workaround is to create max4live device that bands with a delay if parameters were changed, but it has same problem – it transfers old parameter.. so I need to create max4live delay with just bang, and listen to that bang parameter with delay and only then transfer parameters….
Is there a way to create a listener that works fine in this situation? Which can start an action not in the moment when parameters were changed but at that moment when parameters were renewed? Or add a delay in python? Or implement wait function?

You are viewing 1 out of 1 answers, click here to view all answers.