[mididings] How to pass cli arguments for inits in a mididings script

26 views
Skip to first unread message

Athanasios Silis

unread,
Jun 1, 2020, 5:20:36 PM6/1/20
to midi...@googlegroups.com
Hi everyone,
I want a mididings script to listen for midi events from a few controllers (3 to be exact). I want these  controller numbers (midi CC) to be variable but can be set during start up of the script. So I want to set these 3 vales during run time.

How do I go about this ? I have not found something related in the documentation yet.
Did I overlook it ?

Thank you in advance for your help.
Athanasios

STEFETS - https://github.com/stefets/live-config/

unread,
Jun 1, 2020, 6:06:13 PM6/1/20
to mididings
Hi Athanasios,

What I did for my part, was to load a JSON configuration file at the start of the script, between imports and the Mididings config () section. Then I can use the configuration dictionary anywhere in the script ...

Take a look at one of my scripts, then search for the word configuration

You can find the config.json file in the scr directoy.

Hope this help! 

Stéphane Gagnon
Speak french/englisth

Athanasios Silis

unread,
Jun 5, 2020, 5:02:22 AM6/5/20
to midi...@googlegroups.com
Hi Stephane!
thank you!
This will do I wonder though about the general layout of the mididings python script.
Where is the main, who calls the config function  Is there an init function in order to take care of initialisation stuff?

Thank you!

--
You received this message because you are subscribed to the Google Groups "mididings" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mididings+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mididings/cffffbc3-03a7-488f-9cf7-6b8491fcec02%40googlegroups.com.

STEFETS - https://github.com/stefets/live-config/

unread,
Jun 5, 2020, 10:46:00 AM6/5/20
to mididings
Hi Athanasios,

In a mididings script it is not recommended to have a main or init function, it's a particular need of mididings to be optimal.

Since it's Python, the script is parse from from the top to the end, that's why I load my json config right after the imports in order to be able to use my configuration dictionnary in the subsequent lines.

To have a Mididings script stable and optimal, is to have the Run section as the very last instruction of a script. It's a bad practice to put anything after the run() section at the end of a script.

Thanks ! :)
Stéphane Gagnon
Speak french / english
To unsubscribe from this group and stop receiving emails from it, send an email to midi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages