Storing value of led button for recalling after shift action

thopa

2014-04-23 22:50:36

I have a button that controls mute on / off of a channel in Ableton, it has a led. The led colour responds to the velocity received. 10 is white and 20 is yellow.

If the channel is muted then the button receives the message 9a 01 10, white

If the channel is unmuted then the button receives the message 9a 01 20, yellow

I created a shift button (9a 02 pp) that when is pressed it triggers a timer (TIMER1) that changes the Led colour to red while having the shift button pressed, also changing what message the button sends (so i can trigger loop recording in ableton)

Input 9a 02 pp

if pp=127 then g0=1
if pp=0 then g0=0

OUTPUT TIMER1

Another translator that changes the led to red depending on if the shift button is pressed or not:

Input TIMER1

if g0=1 then pp=10
if go=1 then pp=50

OUTPUT 9a 01 pp

And another translator is triggered when i release the shift button, that is meant to return the led to it original state, on or off. For this i tried creating a global variable that holds a value depending on the state of the led, on or off:

Store Value Translator

Input 9a 01 pp

if pp=10 then ga=0
if pp=20 then ga=1

Out:NONE

And finally the translator that tells the led what state it was originally depending on the global variable ga

if ga=0 then pp=10
if ga=1 then pp=20

Out 9a 01 pp

Basically want i want to do is have the shift button change the led colour and midi message, so i can trigger loop recording, and then when i release the shift button the led goes back to its original state, on or off.

I haven’t been using homes for too long, i bet there is a way to store the value of the led button originally, band when the shift button is released send that value back to the led.

Thanks a lot!!

DvlsAdvct

2014-04-23 23:11:04

Hi thopa

What you're doing it totally possible, but we're going to streamline your process, okay? You're correct to save the state in a global variable, and we're going to need a global variable for mute state (ga) and shift (gb). We don't actually need to use timers for this, but instead just a few translators. Timers are not a bad idea, but I think what I'm going to present will just be cleaner.

The first translator is going to track the Mute state with a global variable being counted and cycled between 0 (off) and 1 (on).

Then the second translator is going to track the shift function, having it send the Red state when pressed, and then return to white or yellow based on the Mute state.

Code: Select all

Translator 1: Mute On/Off
Incoming Message: 9A 01 7F
Rules: ga=ga+1
if ga>1 then ga=0
if ga==0 then pp=32
if ga==1 then pp=16
Outgoing Message: 9A 01 pp

Translator 2: Shift On/Off
Incoming Message: 9A 02 pp
Rules: if pp==127 then Goto "On"
if pp==0 then Goto "Off"
Label "On"
pp=80
Exit rules, execute outgoing action
Label "Off"
if ga==0 then pp=32
if ga==1 then pp=16
Outgoing Action: 9A 01 pp
I'm guessing on the rule values mainly because I'm not 100% sure you were working in decimal or hex, but just change them to your hearts content. Let me know if that works

Thanks
Jared

thopa

2014-04-23 23:58:06

Hi Jared,
Many thanks for the quick response!
Yes that looks much neater than my take.
I was wondering where does the gb go? Is it on the second translator?
Im working on decimal,
I will give it a go tomorrow when i go back to the studio,
Thanks a lot for helping me out!!

DvlsAdvct

2014-04-24 00:28:37

Oh, I wrote the code after the introduction. You shouldn't need the GB since you don't need to store the state of the shift control because it's a momentary and not a toggle. Let me know how it works out. :)

Jared

thopa

2014-04-24 17:44:09

Hi I have been trying your idea but couldn't get it to work, i think it because of my settings.

Here is what i have been using so far, for each led button i have on my livid controller I made three translators for each of the led buttons:

*Led 1 Translator 1 (this one defaults the led to white, if channel is muted, velocity 10-White color)

MIDI FROM BOMES AND BRAIN2 CONTROLS

INPUT 9A 02 40
OUTPUT 9A 02 10

MIDI OUT TO BOMES VIRT. AND BRAIN2 CONTROLS

*LED 1 Translator 2 (This one defines the color to YELLOW if channel is on, unmuted)

MIDI FROM BOMES

INPUT 9A 02 7F
OUTPUT 9A 02 20

OUTPUT TO BRAINS

*LED 1 TRANSLATOR 3 TO (This one is used for the feedback from Ableton)

MIDI FROM BOMES VIRTUAL

INPUT 8A 02 40
OUTPUT 9A 02 10

MIDI OUTPUT TO BRAINS

The shift button transmits 9A 2B 40 OR 9A 2B 00 (pressed / unpressed=

Should i include the global variable in any of these translator to make it work?

Hope you can help me out :)

Any help is very much appreciated!!!

DvlsAdvct

2014-04-24 19:13:24

Hi thopa

I'm still not 100% sure how you have this set up. Can you please attach the project to this thread?

Thanks
Jared

thopa

2014-04-24 23:06:33

Hi,

Here it is, dont know if to attach the bomes file or the text.

Sorry if it is a mess.

Text:

Project: LIVIDCOLOURs24042014
Project MIDI IN ports: "Brain2 : Controls (Livid Instruments, Inc.)", Bome's Midi Translator 1 Virtual In
Project MIDI OUT ports: Bome's Midi Translator 1 Virtual Out, "Brain2 : Controls (Livid Instruments, Inc.)"
_____________________________________________________________

[x] Translator 0.8: led1offstatuswhitelivid
Incoming: Note On ch.11: D-1 (#2), vel 64, on ports "Brain2 : Controls (Livid Instruments, Inc.)", Bome's Midi Translator 1 Virtual In
Outgoing: Note On ch.11: D-1 (#2), vel 16, to ports "Brain2 : Controls (Livid Instruments, Inc.)", Bome's Midi Translator 1 Virtual Out

[x] Translator 0.9: led1onstatusRedlivid
Incoming: Note On ch.11: D-1 (#2), vel 127, on port Bome's Midi Translator 1 Virtual In
Outgoing: Note On ch.11: D-1 (#2), vel 32, to port "Brain2 : Controls (Livid Instruments, Inc.)"

[x] Translator 0.10: led1offstatusfeedAbleton
Incoming: Note Off ch.11: D-1 (#2), vel 64, on port Bome's Midi Translator 1 Virtual In
Outgoing: Note On ch.11: D-1 (#2), vel 16, to port "Brain2 : Controls (Livid Instruments, Inc.)"

thopa

2014-04-25 01:06:59

I cleared the code, and left the code for buttom led 1, hope this helps.

Thanks!

DvlsAdvct

2014-04-25 03:33:47

Alright, so you haven't tried using the global variables yet.

What I would recommend doing is starting from scratch and using the translators I included earlier. What you need to decide is when you want to receive feedback from Ableton to drive your LEDs or when you want to use the controller action to drive your LEDs. I don't usually like the way Ableton feeds back MIDI information, so I rely almost exclusively on using the controller itself. I would also separate commands going to Ableton and commands going to Livid so you can get all the bugs worked out, and then if necessary combine them into a smoother code, but at least at that point you'll know how it needs to work.

This isn't going to work if you don't use global variables, as I've outlined earlier in the thread. Your first translator and the your last translator outlined do the same thing, as well. They both receive the same message on Virtual Port 1 and send the same message to your controller, just the first translator ALSO sends messages elsewhere. Have you tried using the translators and rules I outlined previously?

Jared

thopa

2014-04-25 10:13:16

Hi,

I did try the goblal variables, but couldnt get it to work.

I have other global vairables used for the soft take over mode as stated in another post in the forum, so i have knobs sending different cc depending on the state of a shift button, those global variables are working.

I will start a new canvas from scratch and follow your tips. Sorry but when i started this is the only way o got it to work. I will try using only my controller for led feeback and not ableton.

Do you think it would have any effect if i change the button leds to toggle insted of momentary?

Ill let you know how it goes.

Thanks!

DvlsAdvct

2014-04-25 14:05:48

Before you start a clean canvas, can you just attach the whole project to the thread as a .bmtp file? I want to take a look at it and see if I can put it together. It's easier to just do in the project then pass code back and forth over the forum. That way I can also see what other global variables you're using and make sure everything is consistent.

Thanks
Jared

thopa

2014-04-28 12:11:09

Hi Jared,

I got it working.

I had to reconfigure the led buttons and create different global variables, but is all good now. Also it wouldnt work if i had feedback from Ableton, so i got rid of that.

On quick question.

How could i make a shift button based on two buttons? This two buttons are the preexisting shift buttons. I would like to create a shift button when both of the shift buttons are pressed.

Should i do this with timers???

Thanks a lot

DvlsAdvct

2014-04-28 17:04:39

Hi thopa

You can do this with timers, but you don't need to. Each button needs its own global variable value so it can act as a shift on its own, but then it will change the value if the other button is pressed. We are going to use g0 for both buttons. It would look something like this:

Code: Select all

Translator 1: Shift 1
Incoming Message: 90 01 pp
Rules: if pp==0 then Goto "Down"
if pp==127 then Goto "Up"
Label "Down"
if g0==1 then g0=0
if g0==3 then g0=2
Exit rules, execute outgoing action
Label "Up"
if g0==0 then g0=1
if g0==2 then g0=3
Exit rules, execute outgoing action
Outgoing Message: None

Translator 2: Shift 2
Incoming Message: 90 02 pp
if pp==0 then Goto "Down"
if pp==127 then Goto "Up"
Label "Down"
if g0==2 then g0=0
if g0==3 then g0=1
Exit rules, execute outgoing action
Label "Up"
if g0==0 then g0=2
if g0==1 then g0=3
Exit rules, execute outgoing action
Outgoing Message: None
So what happens is when you press button one and release it on its own g0 cycles between 0 and 1. If you press button 2 on its own it cycles g0 between 0 and 2. But if you press button 1 while button 2 is pressed it will move g0 from 2 to 3, or 1 to 3 if button 1 is already pressed and you press button 2.

Does that make sense?