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

1 vue (au cours des 30 derniers jours)
Taylor Gray
Taylor Gray le 6 Avr 2019
Commenté : Taylor Gray le 9 Avr 2019
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 commentaires
Star Strider
Star Strider le 6 Avr 2019
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 le 9 Avr 2019
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with Signal Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by