Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically detect and extract an audio envelope

All suggestions and links to relevant info welcome here. This is the scenario:

Let us say I have a .wav file of someone speaking (and therefore all the samples associated with it).

I would like to run an algorithm on the series of samples to detect when an event happens i.e. the beginning and the end of an envelope. I would then use this starting and end point to extract that data to be used elsewhere.

What would be the best way to tackle this? Any pseudocode? Example code? Source code?

I will eventually be writing this in C.

Thanks!


EDIT 1

Parsing the wav file is not a problem. But some pseudo-code for the envelope detection would be nice! :)

like image 399
Eric Brotto Avatar asked Feb 14 '11 16:02

Eric Brotto


2 Answers

The usual method is:

  1. take absolute value of waveform, abs(x[t])
  2. low pass filter (say 10 Hz cut-off)
  3. apply threshold
like image 193
Paul R Avatar answered Nov 17 '22 05:11

Paul R


You could use the same method as an old fashioned analog meter. Rectify the sample vector, pass the absolute value result though a low pass filter (FIR, IIR, moving average, etc.), than compare against some threshold. For a more accurate event time, you will have to subtract the group delay time of the low pass filter.

Added: You might also need to remove DC beforehand (say with a high-pass filter or other DC blocker equivalent to capacitive coupling).

like image 3
hotpaw2 Avatar answered Nov 17 '22 06:11

hotpaw2