Calculating average velocity of a change in a slider
Background: I'm trying to create a patch to operate various parameters of a pfft 'freeze' via a simple spring-loaded pedal. When the player presses the spring-loaded pedal down to the floor, a bang is triggered causing a 'freeze' snapshot of the live audio to be taken. As the pedal is then released this synthesised ('frozen') output may be brought in, either gradually (by releasing the pedal slowly) or immediately (by releasing it immediately).
Question: I would like for the performer to be able to adjust the width (in frames - default set to 8) of the snapshot taken for the pfft analysis depending on how quickly they push down the pedal. So, if they push the pedal down very quickly, perhaps only one frame will be used to synthesise the 'freeze' output; if they push it down very slowly then maybe 20 frames will be used. I would like to know how to create something that will analyse the average rate of change from a value just below the 'pedal released' value on the slider (which will be 126) to just above the 'pedal down' value (which will be 1). I want this calculation to automatically reset if the slider value returns to the starting value (126).
I am very new to MaxMSP so I don't really know the language or objects very well but I hope there might be someone that understands what I'm trying to do and can help. Thanks in advance!
Hi
Sounds like a very interesting performance tool; here's a simple patch to determine rate of change, complete with fake footpedal:
Brendan
Here's another way to do it (using the footpedal from Brendan) using timer. I also threw in a median filter. This can be handy because the mean is overly influenced by outlier values, whereas median is better at ignoring them.
timer (both inlets), then accum and / or zl group and mean.
Thanks so much! I'll have a look and let you know how I get on.
@Peter, I think your patch is the closest to what I want to achieve; however, I'm encountering a problem and I'm unsure as to why it's happening. When I execute a 'fake footpedal' bang with a time duration of (e.g) 430ms, current time comes out with a reading of 420, while zl median produces 160 and mean produces 948.9. Are these supposed to be averages of the velocity? If so, why would they not produce exactly the same number for this test? The other problem is that when I execute again, changing nothing, I get different results: (2) Current Time - 420, zl median - 420, mean - 1001; (3) ditto except mean = 1053; (4) 1105; (5) 420; from the 5th repetition onwards all value outcomes equal 420. Any idea why this might be happening? I wonder if there might be a way of encorporating Brendan's method (which seems to be more reliable velocity gauge) by accumulating the velocity values (when descending only) over the time taken to travel from 120 to 0 and then calculating the median velocity from that. Obviously with this method I would need to reset the 'accumulator' output to zero when the pedal value is released. Thanks again for your help!
Simon, are you just after the average velocity of getting from 126 to 1, resetting if you go over 126? If so, this is probably what you want, again, using Brendans fake pedal
Essentially, this is just doing ds/dt to get velocity (treating position on the pedal as a 1d vector, and negating the result), think miles per hour on a speed trial, you just care about the start, end, and time taken.
Tony
Hi, I didn't look at the patches above but coincidentally I was checking out mnm.delta in the FTM package yesterday: http://ftm.ircam.fr/index.php/Download
It gives the velocity and acceleration derivatives of a stream of data, eg. a sensor/pedal input, with filtering options. Might be useful to you.
@Tony, thanks very much. I think this is just about what I need. I'll probably post the whole thing on the forum for people to use (and notice faults in, I'm sure, once I'm done.