if, then?
I'm trying to create a function in my patch that says if a number doesn't change by more than 5 either side for more than 1 minute, then boost volume (as a reward to the user) does anybody know how to do this? I've posted an example of the patch below
You can do something like this to figure out when the criteria is met. Then a separate bit of code for increasing the volume by whatever you want.
Actually this makes more sense for the if statement:
if ($f1 < 0.55) && ($f1 > 0.45) then 1 else 0
Thanks so much!
I'm going to look a little pathetic here but this has to be finished by Friday and I haven't got a clue what to do, I can't connect it up in the patch or seem to get it working, is anybody able to help? I wouldn't ask if I wasn't running out of time!
Joe, it clearly does work, however the if statement is hooked up to the bpm, which shouldn't really drop to between 0.45 and 0.55...
I'm fairly certain it's supposed to be hooked up to a different object in the patch that handily *does* output in that range.
I didn't mean to say what Rodrigo did didn't work I meant I couldn't find a way to make it work but I have now!
You don't specify what number you want to check for. If it is for bpm, it will work, you just have to adjust the lower/upper range to whatever it is you want.
So if you want to watch out for 120bpm with give or take 10bpm either side then it would be:
if ($f1 < 130) && ($f1 > 110) then 1 else 0
The first number will be the target number you want PLUS the target range. The lower number will be the target number you want MINUS the target range.
You could also use the split object and have it trigger message boxes with 1 and 0 respectively. (Though split will include the end points in the range)
I think I've nearly got this solved but I need a last push. I'm trying to use the and && objects to test if the current value (the BPM) was within a certain range (which is + or - 5 either way of the last recorded BPM) then toggle output of that test to activate a timer, and if the time went past 10000 ms produce a bang which calculated the new values to go into the test. I think I've got all the things I need in but I don't think I've got them connected up right, is anyone able to have a look and help me out?
Thanks for all your help so far guys!
What you have there won't work. You are never triggering the [i] object, and you are trying to compare the results of [>] with the actual BPM number.
This bit of code will compare the current bpm to the previous one, and if they are within 5bpm of each other, will send a 1. If they are not, it will send a 0.
To test it, send the different bpm values, if you send the same one twice, then it sends a 1. Just stick this in your code where the bpm comes out.
You are a hero! Thanks so much for all your help!