Knowing when a number is within range of a randomly changing number

Aug 5, 2013 at 6:46am

Knowing when a number is within range of a randomly changing number

Hi

This might seem straight forward to some people but I am having difficulty even explaining what I am trying to achieve never mind producing a system that does it.

Is there a way to understand when a number is within a range of e.g 20 less or 20 more or equal to the random numbers?

I looked at the help file for ‘compare’ and they use a system similar to what I am trying to achieve but you can’t choose to say if the number is e.g either equal or close enough to equal by about 20 either

So anything further away than the number by 20 is toggle off, in the range is toggle on.

This is what I have so far…

– Pasted Max Patch, click to expand. –
#258057
Aug 5, 2013 at 7:05am

Do you mean something like this?
<code>

– Pasted Max Patch, click to expand. –

</code>

#258058
Aug 5, 2013 at 7:36am

Yeah that’s the ticket!

I have made some more changes to it with regards to it resetting the system after its banged, but yeah its working pretty good now. Thanks for the help dude

#258062
Aug 5, 2013 at 9:15am

`[expr (\$i1>=\$i2)&&(\$i1<=\$i3)&&(\$i4>=\$i2)&&(\$i4<=\$i2)]`

…or what about

`[if (\$i1>=\$i2)+(\$i1<=\$i3)+(\$i4>=\$i2)+(\$i4<=\$i2) then bang]`

-110

#258076
Aug 6, 2013 at 5:30am

Cheers for that Roman. Think I will stick with this method for now just so I can visually see what is going on.

Here is the updated version

There are some changes to make the blue boxes decimals, which meant the range of those boxes needed to be altered to reflect the decimals & negative values

– Pasted Max Patch, click to expand. –
#258168
Aug 17, 2013 at 11:26am

Hi guys,

sorry to have to bring this thread back up but I have encountered a problem with an updated version of the system which I can not figure out.

Basically where the -50 and + 50 are I am trying to make it so that these numbers change over time too. So the scale object works out the number fine, but is there a way of transferring those numbers that are changing over time in the number of – 50 and + 50. So the range would change?

I hope that makes sense, here is what I have so far

– Pasted Max Patch, click to expand. –
#259146
Aug 18, 2013 at 3:16am

I don’t know if I understood correctly… but I guess the numbers you get with [scale] are the width of your range, aren’t they?
So, if you want to “center” that range, you just have to divide them by two and send them in the right inlet of the [- ] and [+ ] operators.

– Pasted Max Patch, click to expand. –
#259171
Aug 18, 2013 at 6:40am

Hey

Those changes don’t seem to work unfortunately. I am trying to acknowledge (via toggle on) if the right red number box and the right blue number box are ‘in range’ with the number in both the left red box and the left blue box.

But the ‘range’ is changing over time. I tried deleting the 50 and directly sending the range number into the right inlet of the ‘-’ and ‘+’ but that still doesn’t seem to work.

See below – it’s not understanding the if in range or not

– Pasted Max Patch, click to expand. –
#259181
Aug 18, 2013 at 7:59am

Ok, the matter is that almost every Max object has only one “hot” inlet (usually the left one), so if you want the “range” changes to be visible, you’ll need to retrigger the red and blue boxes everytime the range values change.

– Pasted Max Patch, click to expand. –
#259188
Aug 18, 2013 at 9:37am

Okay, thanks for clearing that up. I wasn’t aware the numbers needed to be re-triggered

All the best

#259203
Aug 20, 2013 at 12:19pm

Sorry to bring this up again, but there are still some issues.

The issue is that it understands when the right numbers are within range or under the left numbers, however it is not recognising when it is over the range.

If the right number goes over 100 + range it isnt turning off

Hope this makes sense its driving me up the wall

– Pasted Max Patch, click to expand. –
#259452
Aug 21, 2013 at 5:48am

I seem to have fixed the issue regarding the range now, I think the problem was the left blue and right number was not connected to the – and + left inlet. Seems to work now anyway. However, if you noticed the system at the bottom which bangs when both the red and blue are in range is not working. It seems to bang when the red enters the range even though the blue isnt.

I thought the &&, sel 1 would sort that but its not working. So any ideas regarding that would be great

j

– Pasted Max Patch, click to expand. –
#259519
Aug 22, 2013 at 4:43am

Hey,
Would all of that not be a lot simpler with the [split] object ?

– Pasted Max Patch, click to expand. –
#259623
Aug 27, 2013 at 7:22am

Alright dude, yeah that seems a much simpler method of getting around it

Take a look at this update, it just means I can change the range as opposed to it being set to + 20 & – 20

Just need to check the decimal version works now

All the best

– Pasted Max Patch, click to expand. –
#260052
Aug 27, 2013 at 7:37am

Decimal version : u probably just need to set a floating point as default to the split

– Pasted Max Patch, click to expand. –
#260053
Aug 27, 2013 at 7:37am

There is a problem with the decimal version

it is not acknowledging the + & -

– Pasted Max Patch, click to expand. –
#260054
Aug 27, 2013 at 7:40am

sorry I posted that without refreshing the page. Yeah you are right, it works great now

thanks for all the help

#260055

You must be logged in to reply to this topic.