CSS extra coding
I see that CSS allows to use some coding inside action blocks. It works well when some condition, parsing code added there. But i see a problem with adding attributes. As there are not enough modifiers, and storing data outside is not comfortable, i would like to know:
Is there a way to store data inside CSS scripts?
ChatGPT is suggesting to add this code into an action:
if not hasattr(self, "_rec_blink_active"): self._rec_blink_active = False if not self._rec_blink_active: self._rec_blink_active = True self.midi_cc_ch_0_val_16.send_value(57)
But this crushes ableton really hard so the reaction stop working correctly by parts or the whole reaction misses…
Only PC reboot helps.
So is there a way to add attributes and store data there? What is a correct way to do so if possible?
!!! BE CAREFUL !!!
It was considered that functions declared in separate listeners would be available from a reaction where they were declared only – BUT AT SOME CASES – it goes really wrong. So:
!!! USE UNIQUE !!!
- functions names
- parameters names
What is the user class? How to work with it?
See the section “External Custom Coding with user.py” here: https://community.remotify.io/knowledge/custom-coding-in-reactions-css/
You can make methods in this class and then call them inside your Reactions; e.g. “self.user.[method_name](arguments)”. Your function naming won’t conflict with other names from CSS’s functions this way.
One important note: if you want to access some of the functions from Live’s API (like “send_midi”) inside your User class instance, then you’ll have to add something like the following inside the “__init__”:
“self.c_instance = c_instance”
This “c_instance” contains access to those Live API functions. So if you then want to call “send_midi” from inside the User class, you can use “self.c_instance.send_midi( … )”.
Great!
Thank you!
One benefit from using a user.py file is that you can make adjustments to your code, and reload Ableton without having to build a new script with the CSS app.
For example:
Let’s say you have a method in the User class called “test()”; inside this test method you can setup whatever code you like; you build a Reaction with CSS that’s triggered by a button press and that calls “self.user.test()”; you only need to build this mapping once but can then alter the code of the “test()” method whenever you like, reloading the script in Ableton will make “test()” perform the altered code.
And if you’re using Ableton Live Beta, then reloading Ableton is as simple as with a keyboard shortcut:
https://remotify.io/instant-reload-midi-remote-scripts-in-ableton-live/
Thank you!
I use Ableton 11 for vst 2 PC midi messages support.
It won’t work on newer Ableton 12 with vst 3 …(((
Sign up
User registration is currently not allowed.
Or define them inside the user.py file, then they’re part of the User class.