How to time-align correlated wav.files

조회 수: 6 (최근 30일)
harrie houthakker
harrie houthakker 2018년 5월 9일
댓글: Walter Roberson 2018년 5월 10일
Hello,
I am a music-technology student and new to Matlab. For my graduation project i need a script to automatically time-align and layer impuls responses (audio, wav). The files are all nearly identical (let's say 90% correlated)
What i need exactly:
-I have 20 impuls responses (.wav, mono) of 2 seconds (saved on my computer by another program)
-need Matlab to:
* Automatically import the files
* Find the delay between the 20 correlated files
* Layer them to 1 new audiofile (normalized, so it won't clip)
* Save the audio file
I think i need xcorr in a recursive way?
Maybe it's a lot to ask, but i hope someone can give me a headstart. I am very motivated to learn more, but the clock is ticking and this is not my main profession.
Thanks a in advance

채택된 답변

Von Duesenberg
Von Duesenberg 2018년 5월 9일
편집: Von Duesenberg 2018년 5월 9일
This is homework so perhaps I can try to give you a couple of hints without providing you with the final solution. To import your files automatically, you'll probably need to loop through a list of your files and open them with audioread. To find the delay, yes, xcorr, or finddelay or alignsignals from the Signal Processing Toolbox should do the trick. Now I'm not sure what "layer" means in this case, but it probably refers to mixing your files, in other words, it's a simple addition. And if your signals have different sizes, you may want to zero-pad some of them, e.g. with padarray. Now this will cause your signal to clip (go above + 1 or below - 1), so you want to resize your final signal between these two values. And finally the audiowrite function will let you write your signal as a sound file.
  댓글 수: 5
harrie houthakker
harrie houthakker 2018년 5월 10일
as expected, i do need some help.
I made a for-loop to use xcorr. But how can i recall my .wav files in a better way? So with every loop i process the next .wav file?
[ir1,Fs] = audioread('1ir.wav');
[ir2,Fs] = audioread('2ir.wav');
[ir3,Fs] = audioread('3ir.wav');
n = 2;
ir = zeros(1, 10);
for k = 1:n
k
if (k == 1);
irx = ir2;
elseif (k == 2);
irx = ir3;
end
[acor,lag] = xcorr(ir1,irx);
[~,I] = max(abs(acor));
lagDiff = lag(I)
end
thanks in advance!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by