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

Error in sound (line 4)
[y, fs] = audioread('recording.m4a');

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

답변 (2개)

Star Strider
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

I tried this, but instead got the error Error using audioread (line 74) The filename specified was not found in the MATLAB path.
You need to either:
  1. put your file in your user directory ( ‘C:\. ..\Documents\MATLAB\...’ in Windows ) or
  2. include the full path to the file in the file name.

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

ARUN PRATAP SINGH
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

it is not accepting wavread.Audioread is showing the same error
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?

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

카테고리

질문:

2014년 6월 6일

댓글:

2023년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by