Forums > MaxMSP

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


Joe
August 5, 2013 | 6:46 am

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

August 5, 2013 | 7:05 am

Do you mean something like this?
<code>

– Pasted Max Patch, click to expand. –

</code>



Joe
August 5, 2013 | 7:36 am

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


August 5, 2013 | 9:15 am

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

…or what about

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

-110



Joe
August 6, 2013 | 5:30 am

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


Joe
August 17, 2013 | 11:26 am

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

August 18, 2013 | 3:16 am

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


Joe
August 18, 2013 | 6:40 am

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

August 18, 2013 | 7:59 am

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


Joe
August 18, 2013 | 9:37 am

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

All the best



Joe
August 20, 2013 | 12:19 pm

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


Joe
August 21, 2013 | 5:48 am

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

August 22, 2013 | 4:43 am

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

– Pasted Max Patch, click to expand. –


Joe
August 27, 2013 | 7:22 am

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

August 27, 2013 | 7:37 am

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

– Pasted Max Patch, click to expand. –


Joe
August 27, 2013 | 7:37 am

There is a problem with the decimal version

it is not acknowledging the + & -

– Pasted Max Patch, click to expand. –


Joe
August 27, 2013 | 7:40 am

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

thanks for all the help


Viewing 17 posts - 1 through 17 (of 17 total)