function sound(s,fs)
length_of_s=length(s);
bits=16;
dataChunkSize=length_of_s*2;
RiffChunkID='RIFF';
RiffChunkSize=dataChunkSize+36;
RiffFormType='WAVE';
fmtChunkID='fmt ';
fmtChunkSize=16;
fmtWaveFormatType=1;
fmtChannel=1;
fmtSamplesPerSec=fs;
fmtBytesPerSec=fs*bits/8;
fmtBlockSize=bits/8;
fmtBitsPerSample=bits;
dataChunkID='data';
unwind_protect
   wavefile=strcat(tmpnam(),'.wav');
   fid=fopen(wavefile,'wb','ieee-le');
   % 'RIFF' chunk
   fwrite(fid,RiffChunkID,'uchar');
   fwrite(fid,RiffChunkSize,'uint32');
   fwrite(fid,RiffFormType,'uchar');
   % 'fmt ' chunk
   fwrite(fid,fmtChunkID,'uchar');
   fwrite(fid,fmtChunkSize,'uint32');
   fwrite(fid,fmtWaveFormatType,'uint16');
   fwrite(fid,fmtChannel,'uint16');
   fwrite(fid,fmtSamplesPerSec,'uint32');
   fwrite(fid,fmtBytesPerSec,'uint32');
   fwrite(fid,fmtBlockSize,'uint16');
   fwrite(fid,fmtBitsPerSample,'uint16');
   % 'data' chunck
   fwrite(fid,dataChunkID,'uchar');
   fwrite(fid,dataChunkSize,'uint32');
   s=round((s+1)*65535/2)-32768;
   fwrite(fid,s,'int16');
   fclose(fid);
   system(sprintf('wavplay \'%s\'',wavefile));
unwind_protect_cleanup
   unlink(wavefile);
end_unwind_protect
