[PD] peak amplitude in pd vanilla (was: [env~ ] vs [vsnapshot~ ]: which one is more cpu consuming?)

Matt Barber brbrofsvl at gmail.com
Tue Feb 9 15:48:37 CET 2010


>
> As I understand it (and hopefully i am not completely wrong..) you don't
> have to 'store' a list and 'then' read again it to find the max magnitude.
> It's as simple as the following:
>
> (some signal)
> *I*
> *I* [pd metro at samplerate]
> *I*/
> [vsnapshot~ ]
> |
> [abs ]
> |
> [moses ]X[t f ]
>            |
>         [f ]
>

I think I may have misunderstood your task earlier.  In any case,
you'll probably still do what you want more efficiently at the signal
level:

---------------------------------------------------

[inlet~]  [block~ 1]
 |
[abs~]  [delread~ $0-compare 0]
 |          /
 |        /
[max~]
 |\
 |  \
 |  [delwrite~ $0-compare 1]
 |
[outlet~]

---------------------------------------------------

The [delread~] should be a one-sample delay, so you're just comparing
the previous maximum with the current sample and outputting the larger
of the two.  Then on the outside you can poll that with snapshot~
periodically just like you did your float object above.
If you need to reset it, I think you can just have the [delread~] feed
into a [*~] with a [line~] that jumps from 1 to 0 and back to 1.  Use
[switch~ 1] instead of [block~ 1] if you want to be able to test the
cpu load from that patch.  I hope this works.

I don't think that [env~] does what you want it to at all.

Matt




More information about the Pd-list mailing list