Filter löschen
Filter löschen

Audioread Impulse noise detection and removal of impulse signals

8 Ansichten (letzte 30 Tage)
Please find the attached source code file and audio file * .wav file.
I would like to filter out the impulse noise from the right channel.

Akzeptierte Antwort

Adam Danz
Adam Danz am 11 Feb. 2020
Bearbeitet: Adam Danz am 12 Feb. 2020
This uses findpeaks to locate the impuse signal in channel 2 of the wave file. Peaks are required to be at least 3 standard deviations larger than the mean signal. The values are replaced with the median of that channel (excluding the impulse signal). fFilt is the filtered version of f.
% Read in wav file
FileName = 'rec_noise.wav'; %full path is better
[f,fs] = audioread(FileName);
% Locate peaks
minHeight = mean(abs(f(:,2))) + std(abs(f(:,2)))*3; % min height to be 'peak'; 3 std above mean
[pks, locs] = findpeaks(abs(f(:,2)), 'MinPeakHeight',minHeight);
pks = pks .* sign(f(locs,2)); % pks is only used for plotting
% Replace peaks with the median value of f(:,2) expluding outliers.
% You could also just remove those values but you'd need to remove them in chan 1, too.
isOut = ismember(1:size(f,1), locs);
replacementValue = median(f(~isOut,2)); % you could also use NaN, 0, etc....
fFilt = f;
fFilt(isOut,2) = replacementValue;
Plot the results.
clf()
% Plot channel 1
sp(1) = subplot(3,1,1);
plot(sp(1), f(:,1),'DisplayName','chan 1')
title(sp(1), 'channel 1')
% Plot channel 2
sp(2) = subplot(3,1,2);
plot(sp(2), f(:,2),'DisplayName','chan 2')
title(sp(2), 'channel 2')
% Show outliers (impulses)
hold(sp(2),'on')
plot(sp(2),locs, pks, 'rx', 'DisplayName', 'Outliers')
% Plot the filtered channel 2
sp(3) = subplot(3,1,3);
plot(sp(3), fFilt(:,2),'DisplayName','chan 2 Filtered')
title(sp(3), 'channel 2 filtered')
linkaxes(sp)
200212 152024-Figure 1.png
  20 Kommentare
Life is Wonderful
Life is Wonderful am 25 Feb. 2020
Bearbeitet: Life is Wonderful am 2 Mär. 2020
I have raised a new issue. Please find the below link for more information
Can you please help me ? Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by