Momentary button to send effect with max value

3.08K viewsCSS Questions
0

I have a momentary button and I wanna send my send1 to max value (127). I also have a Knob1 that controls the send1. But additionally I want to have a that momentary button. For some reason I can’t manage to send the value of the send1 to max when pressed.

I tried with reaction, but without success (but maybe there is a easier way):

Listener: Button 1o was pressed
Action Block1:
Condition: Button 10 latest velocity value is equal – 127
Action: MIDI Controller – send MIDI velocity value to Controller input Knob1 Value 127
Action Block2:
Condition: Button 10 latest velocity value is not equal – 127
Action: MIDI Controller – send MIDI velocity value to Controller input Knob1 Value 0

Maybe it’s wront to send the velocity value to Knob1, but I couldn’t find an option how to set the send1 directly.

Any ideas on how I can achieve this?
Any help is appreciated

Rouz Answered question
Attached Files:
0

I don’t think Lists are bound to channels. Channels are just a way to separate the MIDI controllers with, so that the same CC values don’t interfere with each other (?). Or did you mean Mode, instead of Channel? I also don’t think a List is bound to a Mode; a List is just a storage container to store multiple items in, that you could use however you want. If I recall correctly, JohnC once commented that they are basically Python Dictionaries. But I’m not sure if you can address any key to a value, I’ll have to check it out myself.

There are 3 ways to use Custom Code. Whatever suits you best in the moment.

There’s this function in Ableton self.schedule_message(tick, callback_function) that puts a function back into Ableton’s program loop to be called again. The first argument tick determines how many ticks (which you could translate as frames) it takes before the function is called again. Fill in 1 to make it call the function on every tick. The second argument is the function you want to see called again (don’t add parentheses).

The way you could approach it here is (example using block level coding in a Reaction):

  • Create a Reaction that only gets called when a button is pressed down, not when it’s released. You could use the “exit reaction” method, that I explained before, inside a first Action Block, to exit when the Condition of button.cur_val = 0 is met.
  • Inside the second Action Block you can then set up an Action to do the block level custom code in. Here’s an example (untested).

first_time = True
send_value_storage = 0

send = self.song().tracks[0].mixer_device.sends[0]
example_button = self.midi_cc_ch_0_val_61

def falcon_power():

 if example_button.cur_val = 127:
   if first_time:
     send_value_storage = send.value
     send.value = 1
     first_time = False

   self.schedule_message(1, falcon_power)

 else:
   send.value = send_value_storage

As you can see in the code, self.schedule_message is called within the if statement that checks if the button is still held down. So, as long as the button is held down, this function will be rescheduled.

The variables outside the function let us store data, for as long as the rescheduling is happening. We only need certain Actions to happen when the button is pressed (and not on rescheduling), that’s why I’ve implemented the first_time variable, to control this. We can also store references to the Send or Button (or anything else that uses long lines of code) inside variables, to make the code inside the function a bit more readable.

Once the button is released, the first if statement becomes False, triggering the else statement, which doesn’t have a schedule_message call. This sets the Send’s value back to what was stored and ends the Reaction.

You could combine this with the Listener Number method I mentioned earlier. One way to do this is to store a python list of button references outside the falcon_power function (sorry for the name, couldn’t come up with anything relevant). Then insert each button reference, in the same order as the Listeners. Then use listener_number-1 as the list index to get the relevant button reference, and store this in a variable outside the function (although the listener_number might also stay the same upon rescheduling, so it probably wouldn’t be a big deal to use it inside the function as well).

Glenn V. Answered question
You are viewing 1 out of 16 answers, click here to view all answers.