removing pops/clicks from audio file

조회 수: 38 (최근 30일)
Mitja Kocjancic
Mitja Kocjancic 2022년 5월 15일
댓글: Star Strider 2022년 5월 15일
Hello there, I have the folowing file: https://transfer.sh/fR2wht/vinyl.mp3
which includes pops and clicks because vinyl got scratched
you can hear them even better if you listen to part between 2 songs
I tried to remove them using a simple method (Walk through all the samples from start to finish., If we detect large difference in amplitude and oscillations, we have found a click., then we just set samples inside click amplitude to 0 to correct it) but it seams my click remover removes nothing it also seams to adds aditional clicks to the signal (although it does work on silcence, if signal is selent, then there is no clicks)
clearvars;
close all;
clear sound;
%% Read in the file
info = audioinfo("vinyl.mp3");
Fs = info.SampleRate;
signal_silence = audioread("vinyl.mp3", round([66, 70] * Fs)); %Read between 2 songs, where there is silence
disp("Sample rate: " + Fs);
%sound(signal_silence, Fs);
%Plot our signal
figure;
subplot(1,2,1)
%plot(signal_silence);
specgram(signal_silence(:,1),1024,Fs);
caxis([-15 15]);
title('Spectrogram of Original signal')
%% Remove clicks
threshold = .2; %threshold where click starts
diffsig = diff(signal_silence);
diffsig(abs(diffsig)>threshold) = 0; %Set click value to 0
newsig = cumsum(diffsig); %signal without clicks
%% See signal
subplot(1,2,2)
%plot(newsig);
specgram(newsig(:,1),1024,Fs);
caxis([-15 15]);
title('Spectrogram of cleaned signal')
%% Listen to signal
sound(newsig, Fs);
As you can see from Spectrogram and time domain, there is additional click added while, if there is silcence, clicks are not heard, as soon as song starts, threshold kikcs in and block usable signal as well
Hope anyone has any idea what to do, Thanks for Anwsering and Best Regads

채택된 답변

Star Strider
Star Strider 2022년 5월 15일
The filloutliers function (or one of its friends) could be an option —
[y,Fs] = audioread('https://transfer.sh/fR2wht/vinyl.mp3');
t = linspace(0, size(y,1)-1, size(y,1))/Fs;
figure
subplot(2,1,1)
plot(t, y(:,1))
title('L Ch')
grid
subplot(2,1,2)
plot(t, y(:,2))
title('R Ch')
grid
xlabel('Time (s)')
sgtitle('Original')
yfo = filloutliers(y, 'clip', 'movmedian',150);
figure
subplot(2,1,1)
plot(t, yfo(:,1))
title('L Ch')
grid
subplot(2,1,2)
plot(t, yfo(:,2))
title('R Ch')
grid
xlabel('Time (s)')
sgtitle('After ‘filloutliers’')
.
  댓글 수: 2
Mitja Kocjancic
Mitja Kocjancic 2022년 5월 15일
Wow, this actually works, thanks :)
Star Strider
Star Strider 2022년 5월 15일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by