how can i read audio file in matlab?

Thread Starter

sepideh-gh

Joined Mar 5, 2012
4
hi . i use this code for read wav file but i don't know is it true or fale?please direct me.(i want read a wav file that it is in my flash , i copy it to my hard but when use this code i don't give any result)
[y Fs]=wavread('H:\k\term3\audio files\pop.wav');
wavplay(y,Fs);
:confused:
 

panic mode

Joined Oct 10, 2011
2,761
here is working code that reads, manipulates and then saves WAV file:

Rich (BB code):
% read in sound file and determine length and period
[signal, Fs, bits_per_sample]=wavread('speech.wav');

L=length(signal); % file length
T=1/Fs;           % sample period
t=[0:L-1]*T;      % time vector in seconds

% define echo and amplitude values
Te=40;           % set echo to 300 ms 
alpha = 0.9;      % scale amplitude of echo
DelaySec = round(Te / 1000); % must be integer
te = round(DelaySec / T); % echo delay as integer (rel. to sample period)

signalplusecho=1:L+te; % declare it as vector before loop
for t = 1:L+te
   if (t<te)  
       signalplusecho(t)=signal(t);
   elseif (t>=L)              
       signalplusecho(t)=signal(t-te);
   else  
       signalplusecho(t)=signal(t) + alpha*signal(t+te);
   end
end

wavwrite(signalplusecho,Fs,8, 'speechwithecho.wav');
 

m_arezoo

Joined Apr 13, 2012
1
hi
i do this work but also it has an error, please help me

??? Error using ==> wavread at 166
Invalid field name: ''.
Error in ==> read at 4
[signal, Fs, bits_per_sample]=wavread('C:\Users\hp\Desktop\abc.wav');
 

panic mode

Joined Oct 10, 2011
2,761
@m_arezoo

you sent me PM regarding this. unfortunately you also disabled your own PMs so one can't reply. you need to look at the code sample you sent me and verify that path and file names are correct. Read error messages - they are there for you.
 
Top