Invalid Audio File, too many samples
이전 댓글 표시
Hi all,
I have tried to implement the following codes:
H = ones(16, 1);
siz = wavread('hello.wav', 'size');
tot_samples = siz(1); %/ 74539 samples
a=1;
while(a<tot_samples)
x = wavread('hello.wav', [a a+15]); %/ read 16 samples each time
y=H*x; %/ multiply together
a = a + 16;
end
sound(y); %/ plays all the y
I keep getting "Invalid Wave File. Reason: Sample limits out of range." How can i get solve this error?
Also, after multiplying, how can i add up all the "y" and play it as a single audio file?
채택된 답변
추가 답변 (2개)
Wayne King
2012년 9월 24일
1 개 추천
You cannot have the first sample being 0, MATLAB indexes from 1.
댓글 수: 4
Rick
2012년 9월 24일
Thomas
2012년 9월 24일
look at the edits to my answer you have a couple of issues that are causing the problem..
Wayne King
2012년 9월 24일
편집: Wayne King
2012년 9월 24일
It also stands to reason that you cannot have your a variable, a, get closer to the end of the file than 15 samples, so your terminating condition should be
tot_samples-15
not while(a<tot_samples). And why did you pick a length that is not a divisor of the total file length?
Rick
2012년 9월 24일
From, a cursory glance: you have initialized
i=0 There is no index of 0 in matlab and so it cannot play (0-15) range Also your way of calling ones is incorrect
try H=ones(16,1)
Try not to use 'i' as variable since it is in Matlab (complex function). In matlab the way to put comments is use '%' and not '*/'
EDIT
Also you are sampling upto tot_Sample when you have to until (tot-samples -15) otherwise you will run out of bounds again on the top end
댓글 수: 3
your last iteration will go from
i=tot_samples-15
to
i+15
which is
tot_samples-15 +15
(i.e. the end)
You donot hear anything because 15 samples is too small to hear
try
siz=wavread('hello.wav','size');
tot_samples = siz(1); % 74539 samples
i=1;
for i=1:1000:tot_samples-1000
i
x = wavread('hello.wav', [i i+1000]); % read 1000 samples
sound(x);
end
Rick
2012년 9월 24일
카테고리
도움말 센터 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!