function [] = makeraw(wavfile, len); % Compute the sample rate of the codec. fsdes = round((25e6)/(12*256)); % Read the audio vector x, the sample rate fs, and the number of bits per % sample nbits [x,fs,nbits] = wavread(wavfile); % Resample the audio signal to have the correct sample rate. y = resample(x,fsdes,fs); % Zero-pad or truncate the .wav file to be 65536 samples. if length(y) < len, y = [y; zeros(len-length(y),1)]; else y = y(1:len); end; % Normalize the audio signal to have a max and min of +/- 32767, so that % fits into a 16 bit signed number. y = 32767*y/max(abs(y)); % Write the raw audio file to disk. rawfile = [wavfile(1:end-3), 'raw']; fid = fopen(rawfile,'wb'); size(y) fwrite(fid,y,'short'); fclose(fid);