Certain amount of time condition, help please
Certain amount of time condition, help please
hallo!
i am using accelerometer data to send a midi cc out. but i want the acc. script to work ONLY if the condition happens for a certain amount of time, lets say 1.000 mls.
this is it:
'if (Enable.x==1)
{
if (accelerometer[0]>-0.500+right_sens.x) x=0;
else x=1;
}'
this way it won't be triggered by an accidental movement, but only when i keep in that posicion for a while.
any help please??
thanks a lot
i am using accelerometer data to send a midi cc out. but i want the acc. script to work ONLY if the condition happens for a certain amount of time, lets say 1.000 mls.
this is it:
'if (Enable.x==1)
{
if (accelerometer[0]>-0.500+right_sens.x) x=0;
else x=1;
}'
this way it won't be triggered by an accidental movement, but only when i keep in that posicion for a while.
any help please??
thanks a lot
Re: Certain amount of time condition, help please
Have you checked the built-in "time" variable in Lemur manual page 124;
Re: Certain amount of time condition, help please
yep. i googled and checked all the manual looling for "time". but the page 124 it sounded like Chinese for me, i am as good scripting as driving a plane. i need an starting point, something that can help me where to start.
Re: Certain amount of time condition, help please
please,
i just need to know, how to delay some miliseconds a given message or script, like a cc out... ctlout (0,10,11,12), or others...
thanks in advance.
i just need to know, how to delay some miliseconds a given message or script, like a cc out... ctlout (0,10,11,12), or others...
thanks in advance.
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Certain amount of time condition, help please
The reason you haven't been given a quick answer if that delaying things in Lemur is actually not easy. I don't have the editor handy, but maybe google around the forum for the double tap script ( something about double tapping a slider to set to a default). You'll see the extra code needed to delay, but be warned, it's not a simple beginner script concept.
Re: Certain amount of time condition, help please
There are many ways to "delay" a trigger......I usually resort to indirect ways (such as the "decay" of a pad object) in order to avoid the "on frame" scripts....
Using a on frame script you will be needing two extra variables...One, lets call it "g" will act as a "gate" for the onframe script......if g=0 the onframe script will be skipped, if anything else it will be executed. Then you also need a second variable lets call it t which will store the "time" when the trigger happened.
So, when the initial trigger happens you must also trigger:
Then in the onframe script you have:
Notice, that we "close" our gate (we set g to 0) so that the onframe script STOPS being executed when we are done with our delayed action. Also notice that in our example above the delayed action is defined by time-t>.5 so its around 500mseconds.
here is the above example in action - a pad sets a value to 1 with a delay of 500mseconds.
Feel free to send me your actual template if you want me to adjust the idea to your script accordingly.
Using a on frame script you will be needing two extra variables...One, lets call it "g" will act as a "gate" for the onframe script......if g=0 the onframe script will be skipped, if anything else it will be executed. Then you also need a second variable lets call it t which will store the "time" when the trigger happened.
So, when the initial trigger happens you must also trigger:
Code: Select all
g=1;
t=time;
Code: Select all
if (g==0) return;
if (time-t > .5){
what we need here to happen;
g=0;
}
here is the above example in action - a pad sets a value to 1 with a delay of 500mseconds.
Feel free to send me your actual template if you want me to adjust the idea to your script accordingly.
- Attachments
-
- delay-example.jzml
- (6.54 KiB) Downloaded 91 times
Re: Certain amount of time condition, help please
Also keep in mind the rather genius way of using the internal midi clocks of Lemur with start, stopping to get delayed triggers WITHOUT the need of onframe scripts.
Re: Certain amount of time condition, help please
thanks a lot softcore!
i will use this for many things. i appreciate so much your offering, here is my lemur project. as you can see, this is very simple: i want that the rec buttons work in "exlcusive" mode, so when i press one of them, the last pressed one gets it's state "off". but my problem is that they send also all their midi data out, and the last cc my computer gets, is all the "rec off" send by the scripts that turn them off. so i thought i could delay my "rec on", so it would be sent sligthly after all the "rec off".
but this is a fantastical work around way of doing things, i am sure there's a way my rec buttons only send it's cc out when they are pressed, but not when are turned off by a script, or at least, that the last value sent, is the button i am actually pressing, not all the buttons turned off by the script.
i must take a rest... : /
thanks a lot for your help.
david
i will use this for many things. i appreciate so much your offering, here is my lemur project. as you can see, this is very simple: i want that the rec buttons work in "exlcusive" mode, so when i press one of them, the last pressed one gets it's state "off". but my problem is that they send also all their midi data out, and the last cc my computer gets, is all the "rec off" send by the scripts that turn them off. so i thought i could delay my "rec on", so it would be sent sligthly after all the "rec off".
but this is a fantastical work around way of doing things, i am sure there's a way my rec buttons only send it's cc out when they are pressed, but not when are turned off by a script, or at least, that the last value sent, is the button i am actually pressing, not all the buttons turned off by the script.
i must take a rest... : /
thanks a lot for your help.
david
- Attachments
-
- rec buttons exclusive.jzml
- (5.63 KiB) Downloaded 56 times
Re: Certain amount of time condition, help please
Ok help me figure out some things here.....
If you press rec1 on, and you want it to be "exclusive"....why is it that you DONT want the rest of buttons to transmit their "off" midi message? I dont get it.
is that simply because this order of midi messages doesnt let you midi map each button or is there something else Im missing?
If you press rec1 on, and you want it to be "exclusive"....why is it that you DONT want the rest of buttons to transmit their "off" midi message? I dont get it.
is that simply because this order of midi messages doesnt let you midi map each button or is there something else Im missing?
Re: Certain amount of time condition, help please
it's because i am using the rec buttons for a max patch, and the last message i am actually interested getting, is the "rec ON", the 127, not the 0.
i need that message to open a gate object, but that gate get's closed as soon as it get's any 0. the script sent each time i turn on a rec button turning off the rest of buttons, make those 0 messages to be sent AFTER my 127, then my gate in max gets closed. i need the 127 to be sent as the last CC.
is that possible?
thanks a lot.
i need that message to open a gate object, but that gate get's closed as soon as it get's any 0. the script sent each time i turn on a rec button turning off the rest of buttons, make those 0 messages to be sent AFTER my 127, then my gate in max gets closed. i need the 127 to be sent as the last CC.
is that possible?
thanks a lot.