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)]); %

조회 수: 3 (최근 30일)
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)]);

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 21일
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.
  댓글 수: 1
colin fritz
colin fritz 2017년 12월 21일
thanks for the help! Switching the files around worked perfectly since I already new they all had the same sampling rate.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by