SOLVED: python & midi remote script: ButtonElement behaviour

Learn about building and using Max for Live devices.
Post Reply
ring (Simon Slowik)
Posts: 121
Joined: Fri Oct 30, 2009 3:35 pm

SOLVED: python & midi remote script: ButtonElement behaviour

Post by ring (Simon Slowik) » Thu Jun 17, 2010 10:44 am

Dear folks!

I built a Midi Remote Script with python.
There I have a button element to be used within M4L.

The code in python:

Code: Select all

self._TAP_button = ButtonElement(is_momentary, 1, 0, 14)
self._TAP_button.name = 'TAP'
The M4L-device in ableton looks like this:

Image

It works perfect, but only after I've given the blue hand from one device to another. (That means I open a new live set, drop in two devices, focus the first one and then focus the second.)

It seems that the ButtonElement or the control surface needs to be initialized by that procedure. But the transport buttons work from the beginning...


Any solutions?

cheers,
ring
Last edited by ring (Simon Slowik) on Sun Jun 20, 2010 11:17 am, edited 1 time in total.

phattline
Posts: 176
Joined: Sun Jul 05, 2009 5:54 pm

Re: python & midi remote script: ButtonElement strange behaviour

Post by phattline » Thu Jun 17, 2010 8:34 pm

loadbang instead of the max button "bang"...

ring (Simon Slowik)
Posts: 121
Joined: Fri Oct 30, 2009 3:35 pm

Re: python & midi remote script: ButtonElement strange behaviour

Post by ring (Simon Slowik) » Thu Jun 17, 2010 9:07 pm

That's not the problem. The ID of the button_element comes out at the beginning (and doesn't change if I "bang" again) and is alright. Just there is no connection to the MIDI Remote Script...

ring (Simon Slowik)
Posts: 121
Joined: Fri Oct 30, 2009 3:35 pm

Re: python & midi remote script: ButtonElement strange behaviour

Post by ring (Simon Slowik) » Sun Jun 20, 2010 11:14 am

I solved it myself. You've got to add a value listener and a dummy method that does simply NOTHING when the button's value changes. Instead you can do something within M4L.

Here's the python code:

Code: Select all

# put this in your control surface class
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        button = ButtonElement(False, 0, 0, 0)
        button.name = 'Button'
        button.add_value_listener(self._button_value)

    def _button_value(self, value):
        pass

Post Reply