0001 function urbiSound2Wav (sound,wavFile)
0002
0003
0004 fid = fopen(wavFile,'wb');
0005 if fid==-1
0006 error (sprintf('Unable to open %s', wavFile));
0007 end;
0008
0009 full_size = sound.length;
0010 size_char = 1;
0011 size_short = 2;
0012 size_int = 4;
0013
0014 size_of_wav_header = 4 + size_int + 4 + 4 + size_int + size_short + size_short +size_int + size_int + size_short + size_short + 4 + size_int;
0015
0016 H = ['RIFF'];
0017 H = [H urbiInt2Chars(50 + full_size/sound.channel, size_int)];
0018 H = [H 'WAVE' 'fmt '];
0019 H = [H urbiInt2Chars(16, size_int)];
0020 H = [H urbiInt2Chars(1, size_short)];
0021 H = [H urbiInt2Chars(sound.channel, size_short)];
0022 H = [H urbiInt2Chars(sound.Fs, size_int)];
0023 H = [H urbiInt2Chars(floor(sound.Fs * sound.channel * (sound.nbits / 8)), size_int)];
0024 H = [H urbiInt2Chars((sound.nbits/8) * sound.channel, size_short)];
0025 H = [H urbiInt2Chars(sound.nbits, size_short)];
0026 H = [H 'data'];
0027 H = [H urbiInt2Chars(full_size/sound.channel, size_int)];
0028
0029 fwrite(fid, H , 'uchar');
0030
0031 fwrite(fid,sound.samples,'uchar');
0032 fclose(fid);