Audioread Impulse noise detection and removal of impulse signals

6 ビュー (過去 30 日間)
Life is Wonderful
Life is Wonderful 2020 年 2 月 11 日
コメント済み: Life is Wonderful 2020 年 3 月 18 日
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.

採用された回答

Adam Danz
Adam Danz 2020 年 2 月 11 日
編集済み: Adam Danz 2020 年 2 月 12 日
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 件のコメント
Life is Wonderful
Life is Wonderful 2020 年 2 月 25 日
編集済み: Life is Wonderful 2020 年 3 月 2 日
I have raised a new issue. Please find the below link for more information
Can you please help me ? Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by