Querying whether number falls within ranges

Mike S's icon

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?

seejayjames's icon

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.

Mike S's icon

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.

$Adam's icon

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

$Adam's icon

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.

Peter McCulloch's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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