General

Variable values

Started by Salt+Slug on .

Sign in or create an account to join the conversation.

17 posts

Topic starter
So I have a question about applying values from one object to another. I have a fader, who's "X" is a control change (master volume level). It's controller is "cc7" & scaled 0-127 as per the midi implementation chart in the synth's manual. It works perfectly. Where my problem is, is when I try to create a pad for making a "temporary quick mute", so that when pressed, it brings the cc7 value to 0, and when in the off-state, it returns it's value to current value of the "X" of the fader (it needs to come back at the level the master fader is at, not above it. I guess it's value needs to be = Master_Output.x to 0 or something like that, but I just can't get it to work that way.)
Maybe I need to make it so the pad sends a 0 value to the fader and not cc7. thus effecting cc7 via the faders reaction to the pad on-state. But in doing this how do I return the pad's off state to the current "X" value of the fader, I don't want the fader to move unless physically moved (creating master out volume & the variable value to return to in the pad's off-state.

Help Please!!!!

Salt+Slug
Hi

A few different approaches possible I guess. . .
Basically MIDI does not care where the message comes from so just send it from the pad,
If you post some code it may make it easier but here is something that shows one way to do it . . .
Use as an 'action' expression on the Pad executes on 'x' . . .
decl this_x=x;
decl this = getobject();
decl col = getattribute(Fader,'color');
decl old_val = Fader.x;

if (this_x){     // this checks if x=1
setattribute(Fader,'color', RGB(0,0,1));
ctlout(0,7,0,0); // Send 0 on cc7 however you want
}
else{
setattribute(Fader,'color',RGB(0,1,0));
ctlout(0,7,old_val,0);  // This sends the old volume val
}
Changes color of Fader to show it is muted
I guess is one approach, it works, but needs tweaking for values etc

Cheers
MM
Thanks for the help Macciza, I cant possibly express how much I appreciate your input. Now I just have to figure out how to make it work. I am completely new to the world of scripting, and can accomplish only very simple patches in Max (although I can manipulate and use patches). I am sad that I only have Max5, and not MLR.I am not sure how to communicate with live or any thing other than using virtual midi portsThat being said this is also the first point in time where I have even had time to sit down and figure this stuff out. So, I am trying to learn, & trying to spend as much time as I can going through other templates, and foraging the internet for answers. But, when I look at this coding stuff it really blows me away.

It seems like I should be able to atleast just invert the scale of the pad from 0-127 instead to 127-0 thus inverting the value of the pad, so that in its OFF state it sends fader value 127 and in the ON state it sends 0 fader value.(99.9% of the time the output volume is all the way up anyway) I just cant seem to get the pad to respond backwards or to the Master_OutputLevel fader object.

Maybe there is a way to just make the default state of the pad ON, and the selected state OFF, does any one think that could work?

I don't think I need color info as the fader is on another "page" of the same container, I just need a way to read the fader's x value as the pad's OFF value and a way to set the pads ON value to 0
Again, I truly appreciate your help!
Hi
added another comment to the code above.

I think you are 'over thinking' it - you just need to 'remember the current fader setting, send a cc7 0 to mute the channel, then resend the 'old value' . . .
That is what the above script does - the ctlout lines in the script sends the cc7 data - 0when pressed - old value when released

Hope that helps
MM
So I futtzed around with it for a long time to day, I managed to get a custom button(pad) object to do the job, I actually made an expression for old_val=Master_OutputLevel.x and some where in there I got the mute to work I don't know what I did and I may need someone to take a look and clean up. I don't know what I did but it atlest sends the 0 message when it's supposed to but on the off it always seems to send 127, so now at this point I need to figure out how to receive the current Master_OutputLevel.x because my script is seeing expression "old_val" but not doing anything with it because instead of fader level it comes back at full
I am on my IPad right now but will post the template when I go back upstairs...

I really appreciate everyone's help!
PhattyUniversalV1MONOCROMEv1.2.jzml
the objects in question is the "Master_OutputLevel" (envelopes page) and the "MUTE2" (quick jam)
Dude,
say high to the Dweez, from Down Under for me - saw him here a few years back . . .
Play a few Zappa tunes myself on the guitar, Chunga's Revenge a bit lately . . .

I dont think your version quite gets it Kraftf- sends th 127 from the x value and toggles rather than momentary's the mute values
I tidied up an approach more like I outlined earlier, had the channel arg wrong before I think-

Use this in the only script (I call it action()) executing on 'x' / 'any' change under the MUTE button - and disable the MUTE.x value . . .
delete the other unused vars and scripts - old_val does not need to be defined under MUTE, it's only used locally . .

decl this_x = x;
decl old_val= Master_OutputLevel.x; //save Fader value to variable
old_val= floor(old_val*127); // convert 0-1 to 0-127

if (this_x) // this checks if x=1
{   
ctlout(0,7,0,1); // Send midiout0 on cc7 val of 0 on channel 1 or however you want
}
else
{
ctlout(0,7,old_val,1);  // This sends the old volume val
}

This takes the direct approach of simply send the midi messages needed rather than telling the fader to do something that the sends the message
The main difference here is that of using scripting to send midi rather than any interface object which can be a better solution sometimes . .

Cheers
MM
well Im home and iv input the code as stated, it seemed to work then I went to get something to eat and "poof" its acting like it was yesterday its getting frustrating because im not even sure how to monitor that old_val is being transmitted by MUTE2 in the else state, so I know the IF statement is working correctly its the else statement, I have every thing running on Midi 0 so thats the only thing i'v changed in the coding :::pulls hair out:::
PhattyUniversalV1MONOCROMEv1.2.jzml

 decl this_x=x;
 decl old_val=Master_OutputLevel.x;
 old_val=floor(old_val*127);
 
 if(this_x)
 {
 ctlout(0,7,0,0);
 }
 else
 {
 ctlout(0,7,old_val,0);
 }
Hi
You need to set the script execution to 'On Expression' 'x' 'any' -so it respond to any change of x varaiable (not manua)l . . .
Deselect the 'x'value for MUTE2 otherwise it sends 0/127 because of the midi mapping - we are using the x value in the script instead
Delete the old_val and this_x expression that you added there are not needed externally

In the script,
if (this_x) will result in 1 or 0 when pad is pressed and execute accordingly, it is the same as if (this_x == 1)
by using (this_x = 1) with only 1 = sign assigns 1 to this_x so it always results in 1 , follow . . . = is assign, == is comparison
I find the if(this_x) approach is best as it avoids the issue unless needed

It's always best to double-check before changing parameters to be sure . .
Use the listings in the bottom of the project pane showing internal functions - in others you will see ctlout parameters detailed .
The first arg is the target the final arg is the channel number 1 - 16 ( I accidently did 0 in the first script)
Because this is sending MIDI I use MidiMonitor to check that it is working, which it was

Leave the z value of the fader unassigned or disabled unless you are using it somewhere.

Do all those steps and it should work.
How was Dweezil ?
Cheers
MM
Macciza,
Dweezle was freak-out awesome! Such a nice guy. Everyone in his band and on his crew, and the great people at Audio Integreated Research (A.I.R.) were so awesome to work with. I learned about a lot of new things yesterday and had a blast doin it.
As for code, I'm on my way upstairs right now to fix. If I catch a tour going down to your part of the world, I owe you a few good beers. Thank you for putting up with my ignorance, I did not know about = vs == and now I won't forget it.

Cheers
S+S
Sorry I misunderstanded what he was going for. Thought he need a toggle of the MasterVol current value.
Macciza wrote:Dude,
say high to the Dweez, from Down Under for me - saw him here a few years back . . .
Play a few Zappa tunes myself on the guitar, Chunga's Revenge a bit lately . . .

I dont think your version quite gets it Kraftf- sends th 127 from the x value and toggles rather than momentary's the mute values
I tidied up an approach more like I outlined earlier, had the channel arg wrong before I think-

Use this in the only script (I call it action()) executing on 'x' / 'any' change under the MUTE button - and disable the MUTE.x value . . .
delete the other unused vars and scripts - old_val does not need to be defined under MUTE, it's only used locally . .

decl this_x = x;
decl old_val= Master_OutputLevel.x; //save Fader value to variable
old_val= floor(old_val*127); // convert 0-1 to 0-127

if (this_x) // this checks if x=1
{   
ctlout(0,7,0,1); // Send midiout0 on cc7 val of 0 on channel 1 or however you want
}
else
{
ctlout(0,7,old_val,1);  // This sends the old volume val
}

This takes the direct approach of simply send the midi messages needed rather than telling the fader to do something that the sends the message
The main difference here is that of using scripting to send midi rather than any interface object which can be a better solution sometimes . .

Cheers
MM
Salt+Slug wrote:I'm still not getting it, and starting to get a little agitated, maybe just going to drop the function. I have a gig today so i wont get much more looked at today. Thank you both for your input
I know that situation, but remember that you can only rely on established equipment on stage. Of course we want to include the latest tools (and Lemur is one hell of a tool!) in our setup, but it may take some time. For example, I recently wanted to setup my iPad in a new location. I had my templates, my netbook as network bridge, everything was there and working. Everything? No, I forgot the xml files for Cubase. But I still got my trusted hardware controllers there (AlphaTrack, BCF), so it wasn't a problem, just a minor lack of versatile control.

Anyway, I just wanted to say that we're in the same boat, or 'in the same hospital' like we use to say where I live. There are a couple of things I'd like to do with Lemur, and I know it's possible. Needs some time I think to get really familiar with new tools.
I dont know what I did differently on the last go, but man you freakin nailed it! You are the BEST!
now, to try and figure out how to get the program changing custom buttons to function similarly. they are scaled 0-0,0-1,0-2,0-3, and so on till 99, what i need is when pressed it transmits the scaled number (0 through 99), but i also need it to first send a zero to reset the value received at the synth before sending the new PC value.... any ideas? Essentially I want the selection of one to turn off any other that might be selected, reset the value to 0 and the send new value.