Removing parts of an audio clip containing silence (Strip Silence)

Just Evan's icon

Just Evan

9月 17 2024 | 10:29 午後

Hello. Is it possible to make a device that removes parts of an audio clip containing silence?

I think need to load the audio into buffer~ --> peek~ find indexes below the volume threshold...

Also how can I get the index intervals between silence and signal something like: Signal -- Silence_A -- Silence_B -- Signal, where Silence_A is the entry point into silence and Silence_B is the exit point before a new signal appears and so on in a circle until the clip ends?

πŸ‘½'tWβˆ†s βˆ†lienzπŸ‘½'s icon

πŸ‘½'tWβˆ†s βˆ†lienzπŸ‘½

9月 17 2024 | 11:42 午後

you need to incorporate 'hysteresis' into your detection:

once it falls below threshold, wait for a certain time before it can set a marker as the 'startSilence' marker(the timing is up to you, but you could start with trying something like 20ms of silence needed minimum). if the threshold goes back up before this time is up, then it's not truly a silence you want but just an abrupt change towards being below threshold.

if it satisfies the hysteresis condition, then you can mark that as a 'StartOfSilence' marker, then once it goes back above threshold after that, you can mark that index as a 'EndOfSilence' marker('Start...' and 'End...' can be variables in gen codebox, or stored within coll, etc.)... you don't need hysteresis for the 'End' since it should be following a significant amount of silence.

following that, you need to fade-out slightly before 'StartOfSilence' index, and fade-back-in slightly after 'EndOfSilence' index, and then you can cut the audio in between the fades by copying the audio starting at the fade-back-in point, all the way to the end of the buffer~, and paste that back right at the 'StartOfSilence' index.

then... rinse and repeat, rinse and repeat... until all silences are copied over :)

the process i described above is something i did within a Max-based tool i created, while working 2 years as full-time audio-ad producer at Pandora, because they had me on a very basic job cutting slates(the ID that comes before the ad, which is also followed by silence to be cut...) from client-ads, in between producing in-house ads. it was a shit job where i got badly exploited by the company, same as every other corporate american crap audio job i've ever worked :(

therefore, i don't like to think too hard about this type of thing, and i definitely won't remember what i did, but i'll upload the tool i made and perhaps looking at the C file here can help with a more advanced form(i believe i used RMS to detect things more reliably with hysteresis... but i don't want to explain the code... if it helps it helps, otherwise, ignore it)

PandoramaJamma0_9.zip
zip

___________________

there are probably much more efficient variations on what i described above(as in the way you detect, store variable/marker of index, and copy/cut... perhaps, you don't want to fade after End-Of-Silence if that might adjust a transient/attack to a kick-drum,etc... in which case, you can fade-in sooner and record a slightly different kind of index for the copy/cut-point(s)... but the general gist is the same: utilize hysteresis to detect the start, fade-out, detect the end, fade-back-in, cut/copy)... might even be more efficient in terms of speed to mark all silences and then do the multiple cuts/copies all in one go by utilizing an extra buffer... the extra buffer can help with resizing for the new total length, at the end, too.

i'm unable to think clearly on this(it's a depressing memory for me :( ...funny, how an algorithm can carry a feeling after you've been exploited to produce it)...but hopefully the general idea helps, and others might have better solutions or perhaps [mxj buf.Op] patches or similar that could help.

__________________

F--K Pandora radio! 😀

[Edit: @Cycling74, feel free to edit my post or ban me if the above goes against rules πŸ˜‹πŸ”«]

Source Audio's icon

Source Audio

9月 18 2024 | 12:27 午後

You will have hard time making this work, even that it is possible

why not use dedicated sample editor to batch process files you need to use ?

here max detected audio portions would need to be copied (including fades)

to another buffer ...


Just Evan's icon

Just Evan

9月 18 2024 | 2:29 午後

Source Audio, Do you use a separate application to detect silence and export audio portions/indexes?

Source Audio's icon

Source Audio

9月 18 2024 | 2:37 午後

First screen shot is Audio Editor TwistedWave,

which like quite few other editors has option to detect and remove silences.

That short video at the bottom outputs detected audio portion

positions from coll.

I used custom external to get audio / silence indexes.

Source Audio's icon

Source Audio

9月 18 2024 | 2:40 午後

P.S

you asked for something that removes silent parts from audio file.

not something that exports individual slices without silent parts.

Just Evan's icon

Just Evan

9月 18 2024 | 5:47 午後

Source Audio, you talked about a custom external to get audio / silence indexes, is it available for download?

Source Audio's icon

Source Audio

9月 19 2024 | 7:53 εˆε‰

el.buffet~ check events

but ... be warned, some functions make max patch unusable.

I have modified version of it for personal use only, which uses samples insead of ms

for most functions.

Just Evan's icon

Just Evan

9月 19 2024 | 10:46 εˆε‰

Source Audio, this externals only for mac?

Source Audio's icon

Source Audio

9月 19 2024 | 12:10 午後

you can download from here latest version which includes windows externals.

P.S.

I am afraid that package is left in chaotic state.

on first link, windows externals are missing, on github release

at least external of interest - el.buffet~, misses functions

which should be there, compiled version does not match latest source code ...

I have extracted some functions from it, compiled mac version for personal use

which works properly.

But I am afraid, you will have no luck with windows version,

at least not to get slices of audio/silence parts.

Source Audio's icon

Source Audio

9月 20 2024 | 1:59 午後

Are you still interested in this ?

I am thinking about installing visual studio and compiling my version for windows.

Just Evan's icon

Just Evan

9月 20 2024 | 5:13 午後

Source Audio, yes, that would be great! Perhaps in the future this will also be useful to someone! Thank you!