필터 지우기
필터 지우기

Correlation of two .wav files - unsure about the returned error.

조회 수: 3 (최근 30일)
Taylor Gray
Taylor Gray 2019년 4월 6일
댓글: Taylor Gray 2019년 4월 9일
Hi, I spectrally analysed a machine gun sample and used a spectral modelling synthesis model in Max/MSP to procedurally generate it in real-time and now I'm wanting to use correlation to see how close I got. Due to lack of knowledge in MATLAB I'm looking for a little help to gain my metric. I have attached the audio files
clear, clc, close all
% get a section of the sound file
[x, fs] = audioread('Machine_Gun.wav'); % load an audio file
x = x(:, 1); % get the first channel
N = length(x); % signal length
t = (0:N-1)/fs; % time vector
[y, fs] = audioread('Dry_Synthesized_Machine_Gun.wav'); % load an audio file
y = y(:, 1); % get the first channel
n = length(y); % signal length
T = (0:n-1)/fs;
data = [x y];
correlation = corrcoef(data);
This was my failed attempt and i got the below error message:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in test (line 12)
data = [x y];
  댓글 수: 2
Star Strider
Star Strider 2019년 4월 6일
They have to be the same lengths to use any of the correlation functions. Consider using the Signal Processing Toolbox resample (link) function on one of them (esssentially interpolation with an anti-aliasing filter) to create an equal-length vector. Note that this changes the sampling frequency as well.
I don¹t know how your synthesis model works or what it produces. Perhaps adjusting those parameters will produce appropriate-length vectors. Be certain that the sampling frequencies for both signals are the same, or the result will not be reliable.
Another option might be to do a Fourier transform of both records, with the same fft length. Then compare the two spectra that should now have the same frequency vector.
Taylor Gray
Taylor Gray 2019년 4월 9일
I made sure that the sampling frequencies are the same and had a look at the resample function but I'm just not really understanding how to get the similarity metric using correlation on the attached files.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by