Forums > MaxMSP

Silly problem

December 20, 2008 | 10:39 am

Hi there!
Here is my problem:
I have an numeric input which change super fast. Sometimes it increase sometimes it decrease, sometimes it loop a range of values.
I’m looking for something which get each variation and count it. Independently from what the input is doing.
My first logic attempt is into the attached patch, from which you can also better understand which is the problem.

I know that it’s a silly problem but I spent 2 hours looking for an object or something and I finally chose to write a post.

Thanks a lot!


December 20, 2008 | 11:24 am

This patch should do what you are asking. It takes the difference between each input from the number box and uses [accum] to keep a running total.

lh

– Pasted Max Patch, click to expand. –

December 20, 2008 | 1:58 pm

Thanks for your patch!
At the beginning I thought it was perfect but I found a problem.
When a value increments regularly is perfect but, if suddenly the value change from, for instance, 1000 to 0 the [expr] outputs a big number.
What I’m looking for is something which interprets each change from the input, even this huge jumps, as an increment of 1.

Hope you can help me again!
Thanks again anyway!


December 20, 2008 | 5:47 pm

I’m not sure I understand what you are looking for. It seems to me that what you just described is exactly what your original patch did. If you change the values in the number box using your mouse it will output non-continuous values and each of these will trigger a bang which will [+ 1] to your tally. Connect a [print] directly to your number box and do some fast scrolling to see what it outputs.

If you could try to explain it in a bit more detail, or include a patch which describes what your expected input and corresponding output values would be then I might be able to help some more.

lh


December 20, 2008 | 8:08 pm

So you just want every change, regardless of direction, to increment a counter? If so, it’s quite simple.

best,
Zachary

– Pasted Max Patch, click to expand. –

December 20, 2008 | 8:38 pm

On Dec 20, 2008, at 2:39 AM, Luca De Rosso wrote:

> I know that it’s a silly problem but I spent 2 hours looking for an
> object or something and I finally chose to write a post.

Are you expecting that a number box will send all digits while
dragging? It doesn’t, when dragged quickly.

Here’s your patcher edited to add an abstraction I use called
EveryNumber (which is saved as a subpatcher for easy uploading). It
sends bangs for the delta between numbers.

– Pasted Max Patch, click to expand. –

Chris Muir
cbm@well.com

http://www.xfade.com


December 20, 2008 | 8:50 pm

Am I missing something or could you simplify your EveryNumber patch to the one I’ve included below?

lh

– Pasted Max Patch, click to expand. –

December 20, 2008 | 9:15 pm

On Dec 20, 2008, at 12:50 PM, Luke wrote:

> Am I missing something or could you simplify your EveryNumber patch
> to the one I’ve included below?

Works for me.

-C

Chris Muir
cbm@well.com

http://www.xfade.com


December 20, 2008 | 9:30 pm

Ah great, I have to double check things like that just in case I’ve missed something out. More objects doesn’t always make a patch more complex!

Although I’m fairly sure I won’t be simplifying another of your patches any time soon Chris =) I’d just like to say that the patches you have over at xfade taught me a lot when I first started learning max, thank you for sharing them.

lh


December 20, 2008 | 10:50 pm

But just to be clear, Chris and lh’s solutions (which are both great) are useful if the input results from mouse-click-and-drag activity on a number box in Max (due to the way the object behaves when dragging quickly).

If the numbers in this incoming stream are NOT the result of clicking and dragging a number box, but are coming from live input or some automated process and are not stepwise in nature, than you probably don’t want to use the same approach – a simple [change]->[trigger b]->[counter] will suffice, correct?

best,
Zachary

– Pasted Max Patch, click to expand. –

December 20, 2008 | 11:12 pm

On Dec 20, 2008, at 1:30 PM, Luke wrote:

> Although I’m fairly sure I won’t be simplifying another of your
> patches any time soon Chris =) I’d just like to say that the patches
> you have over at xfade taught me a lot when I first started learning
> max, thank you for sharing them.

My pleasure. A lot of the quick and dirty examples I post are just
that: illustrating one of the many ways that some given task can be
done in Max. They aren’t necessarily paragons of efficiency, or
sometimes even clarity, much of the time.

Unless I’m using something a fair amount, I don’t tend to revisit my
approach, so many times the examples are rough.

- C

Chris Muir
cbm@well.com

http://www.xfade.com


December 21, 2008 | 10:16 am

Thanks for all your help folks!
However I had the chance to quickly check them out so I can’t tell if I found the right solution. I’ll do that tomorrow for sure!!

Anyway I would like to explain better the problem as I understood that it wasn’t that much clear.
I’m using the external [xgroove~] which outputs his actual position reading a sample expressed in milliseconds or in samples.
What I have is a [gate] which is activated by pressing a button. Once I press it I want that mySpecialCounter starts counts each variation of sample or millisecond from that point.
Why each variation and just not the first and the last value I get? Because while I’m pressing this button some things can happen to the groove so it will start to send out not just a value which increase but something which change continuously "direction".
So, what I basically need is a delta t, got directly from the sample and not from a parallel solution like a [metro] or something which counts time passed.

Anyway, this was just to try to be more clear. Is such a hard thing for me since english is not my mother tongue.
I’ll check everything out tomorrow and I’ll let you know.
Thanks!


December 22, 2008 | 10:52 am

I figured out why all your patches don’t fit perfectly with my needs. The truth is that they do perfectly half of the work as they follow perfectly a variation if increasing or decreasing numbers. The problem is with big jumps..

You can test it yourself. If you drag the number box everything works fine. But, supposing that if you have a number different that zero, for instance 100, and you type in the number box zero the result will be a big step for the counter. and not just an increment of 1 step.
This is what the same thing that happens to my input. I have numbers that augments like 1, 2, 3, 4, 5, 6, 7, 8, etc. And suddenly I get a 2. Well, I want that the step from 8 to 2 is counted as 1 and not like 6.

I hope you can suggest something even for this problem. =)


December 22, 2008 | 5:24 pm

degezo,

Um… no, it sounds to me like the simple solution I gave is what you’re looking for. I think where you’re getting confused is that you’re clicking and dragging on a number box in an attempt to imitate some algorithmic stream of data that in reality is not produced by clicking and dragging on a number box. The number box has it’s own unique quirks, and since it sounds like you won’t actually be sitting there clicking and dragging it during your piece, you should set up some kind of automated simulation of the data. I provided something similar above, but here it is again, clear as can be:

You said:
"I have numbers that augments like 1, 2, 3, 4, 5, 6, 7, 8, etc. And suddenly I get a 2. Well, I want that the step from 8 to 2 is counted as 1 and not like 6."

-The below patch uses drunk to get similar behavior, producing both step-wise and larger leaps in value. ANY change in value will increment the counter by 1. IF your process will occasionally produce the same value twice, and you want that to increment the counter as well, simply take the change out of the chain.

best,
Zachary

– Pasted Max Patch, click to expand. –

December 24, 2008 | 10:57 pm


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