Getting an error that says Error using audioread (line 135) Range requested is greater than the total number of samples in the file. TotalSamples is 109936. Also, Error in cocktailparty (line 15) [x2,Fs] = audioread('ssm2.wav',[1 size(x1,1)]); %

5 Ansichten (letzte 30 Tage)
i
sempty(which('fastica'))
display('add path of FastICA toolbox');
addpath(strcat(pwd,'\FastICA_25'));
end
% read the data in
% sound files are from http://cnl.salk.edu/~tewon/Blind/blind_audio.html
[x1,Fs] = audioread('ssm1.wav'); % source #1 sound track
[x2,Fs] = audioread('ssm2.wav',[1 size(x1,1)]); % source #2 sound track
[y1,Fs] = audioread('rsm2_mA.wav',[1 size(x1,1)]); % reciever: mic #1 sound track
[y2,Fs] = audioread('rsm2_mB.wav',[1 size(x1,1)]); % reciever: mic #2 sound track
% Fs: sampling rate
% plot the orignal and mixing waveforms
t = linspace(0,size(x1,1)/Fs,size(x1,1)); % time axis
figure(1)
subplot(2,2,1);
plot(t,x1,'b');
title('x1:source #1 sound track');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,2);
plot(t,x2,'r');
title('x2: source #2 sound track');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,3);
plot(t,y1,'c');
title('y1: reciever: mic #1 sound track');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,4);
plot(t,y2,'m');
title('y2: reciever: mic #2 sound track');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
% ICA analysis using FastICA
x = [x1,x2]';
r = fastica(x,'g','gauss'); % fastica gui command: fasticag
% The output levels of this algorithm are arbitrary, normalize to 1
r = r/max(max(abs(r)));
% save output audio file
audiowrite('PC1.wav',r(1,:),Fs);
audiowrite('PC2.wav',r(2,:),Fs);
% plot the results and original data on the same figure
figure(2);
subplot(2,2,1);
plot(t,x1,'m');
title('x1: true sound wave');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,2);
plot(t,x2,'m');
title('x2: true sound wave');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,3);
plot(t,r(1,:),'r');
title('IC1: estimated sound wave');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);
subplot(2,2,4);
plot(t,r(2,:),'r');
title('IC2: estimated sound wave');
xlabel('Time (s)');
ylabel('Amplitude');
xlim([0 max(t)]);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Dez. 2017
Your source2 soundtrack, ssm2.wav has fewer samples than your source1 soundtrack ssm1.wav
You should consider reading all of the files and then clipping down to the shortest of them.
In theory the files might be different sampling frequencies, so you should also consider clipping at the shortest duration instead of the smallest number of samples, and converting all of them to the same sample frequency.

Weitere Antworten (0)

Kategorien

Mehr zu Audio Processing Algorithm Design finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by