[PD] absolute values of a list of numbers?

Claude Heiland-Allen claude at mathr.co.uk
Fri Feb 16 15:09:02 CET 2018


Hi Peter,

On 16/02/18 13:43, Peter P. wrote:
> I am using William Brent's [cepstrum~] to calculate cepstral
> coefficients from a section of an audio signal. My object outputs 512
> the real-valued coefficients as pd message list, which I would like to
> convert to their absolute value. I can't seem to find an easy way to do
> this except for possibly sending the list to an array and using tabread
> to serialize, calculate the absolute value for every element and send it
> back to another array, then requesting it as a list again. Has anyone
> got a better idea? 

you could put it in a table of size 512, then trigger dsp in a switch~d
off subpatch with blocksize 512:

"0, bang"
 |
[switch~ 512]

[tabreceive~]
 |
[abs~]
 |
[tabsend~]

Order of execution means you can use the same table at both ends.

Then copy the table to a list ([array get] ? Not sure of the best way
these days).

If the list were longer or not a power of two you could use [tabplay~]
and [tabwrite~], with multiple bangs to the [switch~] if necessary.


Claude
-- 
https://mathr.co.uk



More information about the Pd-list mailing list