How to find silence in a buffer~?

I have been trying for some time now to analyse a buffer~ to find areas of silence. I can do this crudely in real time by playing it back and recording when a gain~ output reaches 0 and recording timings in a coll but would like to be able to do this in non-real time without playing back the audio. Is this possible?

I have tried using peek~ and mxj buf.Op but can’t get it to work. Anyone got a pointer on where to try next?

I just had a go but am a bit tired :p … I’m not sure if this will always work even if the buffer starts and/or ends with silence … it probably does but you should test it :)

If it does work properly I can explain how it works if you need me to. Also, you could replace the [== 0.] part with whatever you need to. For example, to find any sample higher than a given dBFS value, put {[abs 0.] into [> 0.]} and then set the "threshold" of [> 0. ] with [float] into [dbtoa ] …

I think there are externals around to do this though. Alex Harker’s [descriptors~ ] would probably work.

Attachments:

Record two channels of audio: the first is the audio, the second is the decibel level. (via average~ or something similar) You’ll need to delay the first channel to account for the "warm-up" time that averaging takes. Delay~ will work for this. (you could even just record the thresholding function)

I would highly recommend the use of thresh~ or a similar two-stage threshold detector to debounce your threshold signal. (imagine your threshold value is -70 dB. What happens if your signal is fluttering between -69 and -71 dB? Yick.)

haha … yeah my patch doesn’t work properly :p Pretty much just delete everything after [f ] and deal with the perpetual 0 first output in a different way depending on whether or not it signifies the start of a silent section.