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

5 次查看(过去 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.

请先登录,再进行评论。

更多回答(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