Variable values

Discuss Lemur and share techniques.
Salt+Slug
Newbie
Posts: 48
Joined: 02 Jan 2012 00:46

Variable values

Post by Salt+Slug »

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
Last edited by Salt+Slug on 15 Feb 2012 20:46, edited 1 time in total.
Moog LittlePhatty Stage2, Novation Ultranova, Live8 suite, NI Massive, NI FM8, Max/Msp, LaunchPad, APC-40, and a lot more
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Variable values

Post by Macciza »

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' . . .

Code: Select all

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
Last edited by Macciza on 15 Feb 2012 22:48, edited 1 time in total.
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Salt+Slug
Newbie
Posts: 48
Joined: 02 Jan 2012 00:46

Re: Variable values

Post by Salt+Slug »

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!
Moog LittlePhatty Stage2, Novation Ultranova, Live8 suite, NI Massive, NI FM8, Max/Msp, LaunchPad, APC-40, and a lot more
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Variable values

Post by Macciza »

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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
kraftf
Regular
Posts: 124
Joined: 14 Dec 2011 06:36

Re: Variable values

Post by kraftf »

Yeah correct except from the old_val variable which should be declared outside the script as an expression or else it will die when the script ends.
Salt+Slug
Newbie
Posts: 48
Joined: 02 Jan 2012 00:46

Re: Variable values

Post by Salt+Slug »

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
(242.11 KiB) Downloaded 78 times

the objects in question is the "Master_OutputLevel" (envelopes page) and the "MUTE2" (quick jam)
Moog LittlePhatty Stage2, Novation Ultranova, Live8 suite, NI Massive, NI FM8, Max/Msp, LaunchPad, APC-40, and a lot more
kraftf
Regular
Posts: 124
Joined: 14 Dec 2011 06:36

Re: Variable values

Post by kraftf »

Here is your fix.
By the way very nicely designed template. Don't know hat it does cause I don't have a phatty. but it looks really nice.
Attachments
PhattyUniversalV1MONOCROMEv1.2.jzml
(243.84 KiB) Downloaded 90 times
Salt+Slug
Newbie
Posts: 48
Joined: 02 Jan 2012 00:46

Re: Variable values

Post by Salt+Slug »

Thanks man, I will let you know if it works right when I get home (working Zappa Plays Zappa tonight) and thank you for your kind compliment!
Moog LittlePhatty Stage2, Novation Ultranova, Live8 suite, NI Massive, NI FM8, Max/Msp, LaunchPad, APC-40, and a lot more
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Variable values

Post by Macciza »

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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Salt+Slug
Newbie
Posts: 48
Joined: 02 Jan 2012 00:46

Re: Variable values

Post by Salt+Slug »

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
(242.13 KiB) Downloaded 87 times

Code: Select all

 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);
 }
Moog LittlePhatty Stage2, Novation Ultranova, Live8 suite, NI Massive, NI FM8, Max/Msp, LaunchPad, APC-40, and a lot more
Post Reply