Correlation of two .wav files - unsure about the returned error.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Star Strider
il 6 Apr 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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Signal Processing Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!