Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track no-sound area in a .wav file?

Tags:

java

audio

mfc

wav

How to track sections without sounds in a wav file?

A small software that I want to develop is dividing a wav file, and it consider a no volume area as a dividing point.

How can a program know that volume of a wav file is low? I'll use Java or MFC.

like image 910
Chu-Chu- Avatar asked Dec 07 '25 10:12

Chu-Chu-


2 Answers

I've had success with silence detection by calculating RMS of the signal. This is done in the following manner (assuming you have an array of audio samples):

    long sumOfSquares = 0;
    for (int i = startindex; i <= endindex; i++) {
        sumOfSquares = sumOfSquares + samples[i] * samples[i];
    }
    int numberOfSamples = endindex - startindex + 1;
    long rms = Math.sqrt(sumOfSquares / (numberOfSamples));

if rms is below a certain threshold, you can consider it being silent.

like image 136
Buhb Avatar answered Dec 09 '25 23:12

Buhb


Well, a wave file is basically a list of values, which represents a sound wave discretely divided with some rate (44100 Hz usually). Silence is basically when values are near 0. Just set some threshold value and look for continuous ( let's say 100ms length) regions where value is below that threshold.

like image 27
Mirek Pluta Avatar answered Dec 10 '25 01:12

Mirek Pluta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!