Community Forums Archive

Go Back

Subject:Trim audio if under a treshold
Posted by: bejj
Date:8/31/2013 3:40:46 AM

Hello,

In a 24 bit .wav file, I want to delete all what is below -90dB
at *the end of the file* (not at the beginning)

See screenshot here :
[img]
https://dl.dropboxusercontent.com/u/83031018/forum/trim_from_end_below_tresh.png

How to do this?

I have done a code with examinating each sample in loop (beginning at the end of the file) :

i= file.FileLength;
while ((Math.Abs(file.GetSample(i,0)) < tresh) && (i > 0))
{ i -- ; }
file.CropAudio (0,i);


But this is veryyyyyyyyyyyy slowww...

Do you have another method ?
Thank you in advance !

Thanks!

Message last edited on8/31/2013 3:41:51 AM bybejj.
Subject:RE: Trim audio if under a treshold
Reply by: roblesinge
Date:9/2/2013 11:48:14 AM

What you'd probably want to do is just look for the part of your file where you want the crop to start. You already know your end point, so that half is easy. Work backwards from the end in larger chunks of samples until you find audio above your threshold, then work forwards from there in even smaller chunks until you find the point you're looking for. Then you just call the crop function once on using the start point you found and the end of the file as parameters.

If I have time this week, I can try and give you a code example, but that should get you started.

Rob.

Go Back