I am looking for a quicker way to analyse a sound file and pinpoint the loudest point.
I am using soundfiler to put the sound into an array and I can easily find the peak by cycling through the array at message rate and checking each value against a float, storing the current value in the float if it is higher………. but this is very slow for longer files.
If I try to speed things up using line~ and bang~ , my patch misses the actual peak. It seems to skip through the array missing out lots of values.
Any suggestions to speed things up?
-
Finding peak of an audio file
-
@nuromantix Hello there......
I think you could send the -normalize flag, and then look for the value "1"..... which might be slightly faster....
.... and Thomas Musil made an object that will do what you are looking for [tab_max_index array] which might be fast enough on its own....... which is in the iem_tab folder of Pd-extended......
tab_max_index.zip
David. -
This is where the recent Vanilla additions really become useful. [array max] and [array min] will do it for you with a single bang.
Beware though the the maximum point in an array might not correspond to the loudest point. For that you might need to use [env~] to calculate the amplitude, and [max] to track the maximum.
-
Thanks Liam, that does it very quickly indeed!