% % TXT2WAV.M Simple example to extract and plot data from *.wav files and % store as ascii data in *.txt files % % Input wav file is indicated by user % Output txt/mat files saves only two variables in txt/mat file format % y = single vector with sound information by sample interval % Fs = sample rate (samples per second) % % File prepared by J. R. White, UMass-Lowell (original Sept. 1997) % --> minor update June 1999 % % Adapté par B. Decoux le 14/10/03 pour les TP DSP EFREI % sauvegarde dans un fichier texte % name = input('Entrez le nom du fichier texte à convertir (pas d''extension): ','s'); fname1 = [name '.txt']; fid=fopen(fname1, 'rt'); % fprintf(fid, '%.7f\n', y); y=fscanf(fid, '%f'); fclose(fid); % % end of function % % Identify file to be processed name = input('Entrez le nom du fichier .wav à générer (pas d''extension): ','s'); fname2 = [name '.wav']; % % Extract info Fs=44100; wavwrite(y, Fs, fname2); sound(y,Fs) % Play sound on sound card (just once) %