필터 지우기
필터 지우기

How can I remove the discontinuity in concatenation of wav arrays?

조회 수: 4 (최근 30일)
Hello, I'm a beginner in matlab. I have a question: I have tried to concatenate two wav arrays, and I have played the result of the concatenation. There's a small discontinuity between the two sounds in the reproduction, although I have eliminated a number of samples at the end of the first sound and the beginning of the second. I can't remove other samples without damaging the information contained in the signals. How could I solve this problem? I wish the final sound seemed as natural as possible (the two initial sounds are syllables, and the final one is the word formed by the two syllables). This is a piece of the code:
%The two sounds have the same sampling frequency.
[sound1,Fs]=wavread('ca.wav');
sound2=wavread('ne.wav');
sound1=sound1(1:(size(sound1,1)-500));
sound2=sound2(50:end);
sound3=[sound1' sound2'];
sound(sound3,Fs);

채택된 답변

Wayne King
Wayne King 2012년 9월 15일
편집: Wayne King 2012년 9월 15일
How big is the discontinuity? I'm assuming the two waveforms are both essentially zero-mean waveforms. If not, you'll want to shift them to make them zero mean.
Then, one thing you can do is to apply a moving average filter to smooth out the discontinuity. I'll use a 5-point moving average filter here. I would try a low order filter first, because you probably don't want to filter your signal too much (it is a lowpass filter). The larger the magnitude of the discontinuity, the higher order you would need.
t = 0:0.01:1;
x = cos(2*pi*t).*(t<=0.5)+cos(2*pi*t-pi/8).*(t>0.5);
plot(t,x,'r'); hold on;
h = 1/5*ones(5,1);
y = filtfilt(h,1,x);
plot(t,y,'b')
  댓글 수: 3
Wayne King
Wayne King 2012년 9월 15일
sound1 = detrend(sound1,0);
sound2 = detrend(sound2,0);
Assuming that the two waveforms don't have more complicated trends than a DC shift.
Micaela
Micaela 2012년 9월 15일
Ok, now the final sound is really better. Thanks a lot!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by