Detecting a fast numerical increase or drop

Aug 7, 2013 at 9:50am

Detecting a fast numerical increase or drop

I have incoming numbers of 0 – 127, how would I want to do something like this: if $i1 decreases by 30 in 10ms then bang.

I’m trying to create sword effects triggered by wiimote movements and I want the “clang” sample to be triggered if a sudden decrease in accelerometer data is detected.

Any ideas?

Thanks in advance, you guys have been great in the few days since I got my Max license. Hopefully I’ll have learnt enough to be able to help out others before too long.

#258250
Aug 7, 2013 at 10:42am

Not to self promote, but I’ve made a video tutorial on doing basically exactly what you’re describing. You can cheggiddout here:

That being said, if you’re looking for something you can copy-paste, something like this might get you started:

<code>

– Pasted Max Patch, click to expand. –

</code>

#258252
Aug 7, 2013 at 10:49am

One way to detect a large drop between successive input values. Edit: posted this before seeing Sam’s response. Different approach to timing but otherwise similar…

<code>

– Pasted Max Patch, click to expand. –

</code>

#258253
Aug 7, 2013 at 1:37pm

Thanks both.

Sam – is there any reason why the patch you describe in your video wouldn’t work using the ctlin object rather than udp?

This is what I have at the moment and it doesn’t seem to be working. The number object displays incoming MIDI numbers so osculator is working fine.

Edit: I’ve decided to just go with the UDP method as it seems to be working well. I am curious as to why my patch wasn’t working though…

– Pasted Max Patch, click to expand. –
#258275

You must be logged in to reply to this topic.