insert delay between emitted events?

19 views
Skip to first unread message

nonsequitarian

unread,
Nov 22, 2022, 8:40:36 PM11/22/22
to mididings
Hi there,

I'd like to use mididings as a proxy between my mixing console controller and my DAW so I can customize some of the commands, inspired by what the author of this post is doing with MaxMSP or PureData. I'm off to a promising start, but I can't figure out one important piece.

For some incoming events I want to immediately send out the original event followed by a follow-up event 50ms later, but I can't figure out how to do it. I've tried using Process and having the python code return a generator that has a `time.sleep` call after the first yield, but this isn't working; mididings waits until it has all of the events and then sends them out all at once.

Is there any way to introduce latency between the output events that are triggered by a single input event?

Thanks!

-r

nonsequitarian

unread,
Nov 23, 2022, 2:45:10 AM11/23/22
to mididings

Answering my own question for future seekers:

I figured out how to do this with `Call` and the `output_event` function; `Call` invokes a non-blocking function, and `output_event` lets me emit events from there outside of the flow of the original event path. I've posted a gist with my solution. Suggestions for improvement welcome.

One piece of weirdness is that the function I specify seems to be getting called twice each time, so I had to use a global variable to track this and immediately return every other call. Anyone know if that's expected?

-r

Stéphane Gagnon

unread,
Nov 23, 2022, 8:10:51 AM11/23/22
to mididings
It's easier to help with the script code.

It's normal that the delay method is called twice, it is because of your Filter(NOTE) in the run section. In mididings, the symbolic constant NOTE stand for NOTEON and NOTEOFF.

If you want that the delay method to be called once, depending your use case, change your filter to Filter(NOTEON) Or Filter(NOTEOFF), that's what I do offently in my script.

Stéphane Gagnon

nonsequitarian

unread,
Nov 23, 2022, 2:37:45 PM11/23/22
to mididings
*slaps forehead*

Yes, of course, so obvious in retrospect. Thanks for pointing it out.

-r

nonsequitarian

unread,
Nov 23, 2022, 11:50:52 PM11/23/22
to mididings
Just leaving a link to the (extremely simple) end result for future seekers.
Reply all
Reply to author
Forward
0 new messages