Momentary button to send effect with max value

4.35K 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

Yo Glenn, you are a legend man 🙂

I moved your user.py to my script folder and changed these lines:

buttons= {
  1 : self.c_instance.midi_cc_ch_1_val_61,
  2 : self.c_instance.midi_cc_ch_1_val_62,
}

Then I created a simple reaction (global mode) with 2 button pressed listeners for those 2 buttons and an action code with:
self.user.full_on_press_reset_on_release(reaction_listener_number)
Wasn’t sure if I need to place an exit as well..?

In Ableton I get no changes in the send value when I press the button. I get these logs (twice) for every button press:

LISTENER NUMBER >>> 1

(test) There’s a problem with ‘Action Block 1’ in reaction ‘send to maxxx’ (from ‘Button 10 was pressed’ listener) >>> ‘css_trynew’ object has no attribute ‘midi_cc_ch_1_val_61’


Listener number is correct. It seems it does not find the referenced button, but in the app Button 10 shows (CC/1/61). Should be correct, right?

Rouz Edited answer
1

The channels you’re getting from hovering over a button on the controller template, starts counting from 1 (to 16). But in the code it starts counting from 0 (to 15). So you just need to detract 1 from the channel.

You could also temporarily start making a condition in a reaction with that button, then the code for that button will appear below the condition (if you’re ever uncertain). Remember to throw away the Condition afterwards, or it might produce an error.

Inside the structure of ‘midi_cc_ch_1_val_61’ there are 3 variables that can change depending of how your template is set up:

  • cc could also be note
  • the channel (counting from 0 to 15)
  • the value (counting from 0 to 127)

About the Listener Number logging

There must be a line of code I forgot to comment out, near the top of the function. It logs twice because the function is called both on press and on release.

The Exit Reaction shouldn’t be necessary, but it won’t hurt either.

Glenn V. Answered question
0

Hi again, after setting the channel to 0 .. it was working .. YEAH 🙂
In the meantime I also got the sends 3+4 for shift mode to work. So glad 🙂

Just wanna make some small changes, because I don’t want the buttons to trigger sends of the selected channel, but the channel they visually belong to.

So I would pass in the reaction the channel explicitly (for example 0 for the 1st channel):
self.user.full_on_press_reset_on_release(reaction_listener_number, 0)
Then in the users.py I would create a buttons list for every channel that would be selected by the argument. Or would you do it differently?

Btw, no idea why it is logged once per click and once when the button is released. Not sure what you meant i should comment out.

Thanks for your support. Really appreciate it.

Glenn V. Posted new comment

Hey Rouz, I don’t know if you’ve noticed but I posted a newer version of the script (+ documentation and a few pre-made Reactions where you just need to change the Modes and the Listeners on) a few days ago.

0

I found a way, for dividing the list of buttons among different tracks, that works (by using the result and remainder of a division between the listener_number and the amount_of_buttons_assigned_per_track) but in the process came across something that bugged me about modes.

Initially I had only tested the funtion being called by a Reaction in the Global Mode. That meant that the function would be called, in whatever Mode was active. This worked fine. But what if you wanted to use the same buttons for other functionalities in different Modes?

To isolate this function to a specific Mode, you’d need to make a Reaction that calls the function from Mode 1 and then another Reaction that calls the function from Shift Mode, under the same Listener conditions. If you wouldn’t create the same Reaction for the Shift Mode, then the buttons wouldn’t fire the function while in Shift Mode. The problem that arises from this is that Shift Mode is inside the domain of the Global Mode, and can be called upon from within any other Mode.

EXAMPLE: if we’ve changed from Mode 1 to, let’s say, Mode 2, then activating Shift Mode from Mode 2 would still let you call upon the function, which would make the relative Sends change values whenever 1 of the Listeners is activated. To reword this a bit: while in Mode 2, none of the buttons would activate a Send; but when using Shift Mode from within Mode 2, the buttons would activate the Sends relative to the Shift Mode. This would be unwanted behaviour; we only want Shift Mode to activate Sends when coming from Mode 1.

So, I’ve been thinking on how to resolve this problem but it’s been a bit of a headache. I’ve found a solution that works fine but it’s also a little messy. I’m going to take my time to review the code; maybe a better solution will arise or else I’m just going to try and mitigate the amount of bugs that can occurr.

For now, here’s the piece of code I’m using to solve what you asked for:

Glenn V. Posted new comment

Could you use a condition in the reaction to check the active mode first?
script > active mode number

If the Reaction with the custom function was set in a Global Mode, then you might be able to use this approach. But then we would have to keep track of the previous mode so that the Reaction only fires in Shift Mode when the Main Mode was active beforehand. This would also mean people need to figure out the Active Mode Numbers in their script and insert them in the Reaction and script. I was hoping to find a way around this.

Atm, I’m using 2 Reactions that keep track of the Main Mode and Shift Mode’s activation and deactivation. If the time between Main Mode deactivating and Shift Mode activating is less than 1 second, a variable in the script will tell the function it can proceed while in Shift Mode. It works but now we have at minimum 3 Reactions, if we use a Global Mode to fire the function with, or 4 Reactions, if we’d separate the function calls for the Main Mode and the Shift Mode.

I’ve tried combining the Reactions that tracked Mode Activation and Deactivation with the respective Reactions that would call the function. It seems to be working as intended, meaning I was able to slim it down to only 2 Reactions (one for the Main Mode and one for the Shift Mode) + with the added benefit that the user won’t have to input the active_mode_number inside the script anymore.

If it would be possible to slim it down to only 1 Reaction, that would be the best outcome. I’ll give it some time still, maybe an idea will come.

I noticed there’s nog Listener anymore for when the “Mode has Changed”. Is this because of the implementation of the Global Mode in CSS3? That Listener would have been useful in this circumstance.

0

Here’s a link to v2. The folder contains:

  • the user.py file
  • a json with 2 Reactions
  • a Google Doc with info

Let me know how it works on your end.

Rouz Posted new comment

FYI, it is not necessary anymore to insert any mode_numbers in the user.py file. I found another way to track modes.

Hi Glenn, sorry had some busy days.
Great, that you managed to code another version. Thanks for sharing 🙂

I will need to check the read me and figure out how to set up the script. Will write you here once I got it working