Need help with logical structure
Hello
I wonder whether someone could help me with the following Max 4 patch:
I have got a signal which increases or decreases like a wave. It's values (float) are usually between 1.0 - 50.0, but when it moves I do not get all the values, most of the times it is leaving out some decimals.
[1.1, 1.2, 1.4, 1.6, 1.9, 2.1, 2.2, 2.0, 1.8, 1.6, 1.5, 1.4, 1.2, 1, 1, ....] - I could not use select.
I would like to receive bangs whenever the signal passes an devision, whenever it steps into an other level, here if it reaches, passes an integer. I kinda achieved a result today (if structures, and onebangs), but would not say I am happy with it.
If there is a better solution for this problem, I would love to know about it. Any help appreciated:
All the best
Krisztian
CODE:
Here is another try, but would need a lot of cabling:
You could remove repeated triggers using the [change] object before the [select] rather than all the [onebang]s afterwards. If you want to specify different boundary points you could look into using [if] with some < > in the statement. Or this handy javascript will do it all for you if you give it a list of arguments where you want the boundaries to be. You'll still need to use a [select 0 1 2 3 etc] afterwards.
lh
var divs = arrayfromargs(jsarguments).slice(1);
var prev = -1;
function msg_float(x) {
for (i=0; i
check(x,i);
}
}
function check(a,b) {
if (adivs[divs.length-1]) {
result = -1;
}
if (a>divs[b] && a
result = b;
}
if (result!=prev) {
outlet(0,result);
prev = result;
}
}
maybe I am misunderstanding what you are trying to do, but this seems easier....
sorry, did not get a notification, thank you for the answers, I will look into them. best, K