Need help fixing Audio Read Error reading in a WAV file
이전 댓글 표시
I keep getting an error trying to read in a WAV file that says: Error using audioread (line 127) Range requested is greater than the total number of samples in the file. TotalSamples is 0.
I am trying to plot the time domain and the FFT of WAV file by the frequency domain.I have looked online for similar errors, but have found nothing. I have my code below.
file = 'wav_tester_new';
[y, Fs] = audioread(file); %read in WAV file
sound(y, Fs); %play the WAV file
t=0:1/Fs:(length(y)-1)/Fs; %sampling frequency
figure(1);
plot(t,y); %plot WAV file by time domain array t
title('WAV File in Time Domain');
ylabel('Amplitude');
xlabel('Length (in seconds)');
n=length(y)-1;
f=0:Fs/n:Fs; %frequency domain
wavefft=abs(fft(y)); %FFT of WAV file
figure(2);
plot(f,wavefft); %plot the FFT of WAV file by the frequency domain array f
xlabel('Frequency in Hz');
ylabel('Magnitude');
title('WAV File FFT');
댓글 수: 1
ahmed
2023년 1월 2일
Error in sound (line 4)
[y, fs] = audioread('recording.m4a');
답변 (2개)
Star Strider
2014년 6월 6일
The audioread function needs the file extension as well. (The soon-to-be-obsolete wavread assumes a ‘.wav’ file.)
See if:
file = 'wav_tester_new.wav';
improves things.
댓글 수: 2
Jennifer
2014년 6월 6일
Star Strider
2014년 6월 6일
You need to either:
- put your file in your user directory ( ‘C:\. ..\Documents\MATLAB\...’ in Windows ) or
- include the full path to the file in the file name.
ARUN PRATAP SINGH
2017년 6월 15일
0 개 추천
audioread is no longer available to play wav file. Just use wavread instead of that. I hope it helps.
댓글 수: 3
apurva raj
2020년 4월 9일
it is not accepting wavread.Audioread is showing the same error
zina shalchi
2020년 9월 25일
wavread is not supporeted any more
[Size, Sfreq, NbS, opt] = wavread (File, 'size');
and when I replace it with audioread I got errors too many parameters
[Size, Sfreq, NbS, opt] = audioread (File, 'size');
do you know how to solve this problem please?
Walter Roberson
2020년 9월 25일
You can use audioinfo() https://www.mathworks.com/help/releases/R2015b/matlab/ref/audioinfo.html to get that kind of information.
카테고리
도움말 센터 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!