Python Script Creator/Generator (function factory)

A

Andrej Mitrovic

Hello,

I have the following situation: I've got a 3rd party application that
has a Python API. The applicaiton has integrated support for MIDI
Hardware Controllers, which can be used to manipulate various
parameters of the application. The app can also load Python User
Scripts, which can define the mapping between the Controllers and
Parameters, but they can also be used to define the behavior of those
mappings as well.

I want to provide my users a GUI App that allows them to map their
MIDI Controllers to the application's Parameters, but with a specific
behavior. Once they've defined the mappings and behavior, my
application would generate a custom Python User Script, which then
gets loaded by the 3rd party app.

I've already got MIDI covered, and the GUI. Deployment via Pyinstaller
has been taken care of as well. My application can currently map
Controllers to Parameters in a 1:1 fashion, and can generate a simple
python User Script with all the mappings. What I'm left with
implementing is the behavior part.

Let me give you a simple example of a possible behavior that the user
could select:

- The user has a button on their MIDI Hardware (a simple type of MIDI
controller)
- The first time the button is hit, a specific parameter is selected
in the 3rd party application.
- The second time the button is hit, a different parameter is
selected.
- And so on, depending on the behavior of the function that's mapped
to that MIDI button

So, in essence, a simple User Script would look something like this
(pseudocode-ish):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
swap_parameters()
if button1 was_hit_the_first_time:
select parameter1
else:
select parameter2

buttons = (
button1 = swap_parameters()
button3 = parameter3
button4 = parameter4
....
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What I had in mind, was to have a collection of behaviors stored in a
file (basically functions such as "swap_parameters") which the user
could select via my application, map them to a specific MIDI
Controller (such as a Button), and generate the User Script.

In essence, I'm trying to build a function factory that's specific to
the 3rd party application's provided API. But the user would have the
ability to change the way the function works. In the above example,
the user might want their MIDI Button to select parameter2 first, and
parameter1 the second time.

Has anyone had any experience with generating functionality this way,
and could you give me some pointers in the right direction? Any tips,
advice, book recommendations are more than welcome.


Kind regards,
Andrej Mitrovic
 
A

Andrej Mitrovic

I forgot to mention, I'm using Python 2.5.x. I can't use Python 3
unfortunately, the 3rd party application uses Py2.5.x internally, so I
have to limit the functionality to that version.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top