Zagavarr
Zagavarr

Reputation: 301

Remove impulse noise from .wav file using Matlab

I have the following audio signal (mono, one channel): enter image description here

In the time domain I would like to remove the isolated disturbance (click, pop, crack), leaving the rest intact, as shown in image. What would be the most appropriate method to do this in Matlab®? Audio signal is represented as one-dimensional vector. Any code example is appreciated.

Upvotes: 2

Views: 1523

Answers (1)

learnvst
learnvst

Reputation: 16193

First I try to approximate your signal with this code . .

x = zeros(10,1);
x = [x; randn(50,1)];
x = [x; zeros(100,1)];
x = [x; -1; 1];
x = [x; zeros(10,1);];

stem (x)

The next step it to extract the envelope using a simple moving average filter and zero phase filtering

nFilt = 10;
b = ones(nFilt,1)/nFilt;

y = filter(b,1,flipud(abs(x)));
y = filter(b,1,flipud(abs(y)));

hold on; plot(y, 'r')

enter image description here

Once you have that, simple thresholding will help you to remove the isolated event . .

x(y<0.2) = 0;
figure; stem(x, 'g')

enter image description here

Tweak the filter kernel / threshold value to suit your needs.

Upvotes: 3

Related Questions