Forums > MaxMSP

Querying whether number falls within ranges

May 1, 2012 | 5:45 pm

Hello all,

I’m using mousestate to get the horizontal mouse position when hovering over a waveform. I have a set of ranges on the waveform that change, and there can be any number of these ranges.

Essentially I need to display multiple start and end points ala the select tool in waveform~, and give some visual feedback to the user when they hover over a range.

I can store the ranges, but can’t really query the data how I would like. With one range it would be something like "if mouse position > start of range & < end of range then highlight", but with multiple ranges that change I've no idea what object(s) to use.

Perhaps I need to get in to SQL for this task?


May 1, 2012 | 6:33 pm

you should be able to do it with cascading [if] statements, or maybe [split] can help set things up. But if that gets weird, try javascript, or [jstrigger]?
You shouldn’t need SQL.


May 1, 2012 | 8:39 pm

But I may have 30 different ranges one time, and 5 the next time. The problem I think is that the number of ranges change, and the values of them change each time a process is completed – It’s all dynamic.

I envisaged an object where I could take the integer from mousestate, and feed this in to (leproblemefixer) which would then output the index of the range, and start and end points. Coll essentially, but one that I could query in more depth.


May 1, 2012 | 9:33 pm

Hi,

I have an object in my library called [sadam.split] which was developed exactly for these situation. It behaves like the normal [split] object, but you can give as many ranges as you wish. You can download it from http://www.sadam.hu/software .

Hope this helps,
Ádám


May 1, 2012 | 9:39 pm

OK, to be a bit more precise, the number of ranges in [sadam.split] is constant, you have to specify it at object creation time. However, the limits of the ranges can be changed dynamically. In other words, you can dynamically ‘kill’ a given range by setting the minimum and maximum values of the given range to the same number.


May 1, 2012 | 10:01 pm

This one’s dynamic. vexpr + zl.sum is a fun trick for boolean logic… (only checks if it is one of the ranges, but you can get that

– Pasted Max Patch, click to expand. –

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