midimonster icon indicating copy to clipboard operation
midimonster copied to clipboard

osc: provide mechanism for emitting initialisation commands

Open OddBloke opened this issue 3 years ago • 2 comments

I'm currently working on an integration with REAPER which has some global configuration options that can be set via OSC. I would like to emit these commands once immediately after the OSC backend's connection is initialised (and, ideally, as they should only need that single invocation, never again).

Currently, I have to map an input to this setting, and remember to set that input correctly before my integration will work as expected.

OddBloke avatar Dec 20 '21 01:12 OddBloke

A generic mechanism for this could be to enable configuring a Python function as an init hook, and have that emit all the setup events I would need. So something like this could work for my use case:

def init_hook():
   midimonster.output("setup_1", 1)
[python py1]
module = my_module
init-hook = my_module.init_hook

[map]
py1.setup_1 > my_osc./device/track/follows/last_touched

OddBloke avatar Dec 20 '21 01:12 OddBloke

Hi @OddBloke, thanks for your in-depth report! Both programming backends (lua and python) support initially setting channels at load time by directly calling the respective output(channel, value) API in the global scope.

For example, in Python you could (as a minimized example) do

import midimonster

midimonster.output("test", 1.0)

This will output 1.0 on the test channel once the translation is starting up. You could also replace that by a call to an init_hook function :)

Hope this helps!

cbdevnet avatar Dec 20 '21 22:12 cbdevnet