comparison scripts/audio/wavread.m @ 7151:aeeb646f6538

[project @ 2007-11-09 19:34:17 by jwe]
author jwe
date Fri, 09 Nov 2007 19:35:52 +0000
parents 373c39904877
children da8e4aa06134
comparison
equal deleted inserted replaced
7150:68a1b616b7df 7151:aeeb646f6538
113 endif 113 endif
114 if (i++ == 64) 114 if (i++ == 64)
115 fclose (fid); 115 fclose (fid);
116 error ("wavread: file contains no data chunk"); 116 error ("wavread: file contains no data chunk");
117 endif 117 endif
118 end 118 endwhile
119 119
120 ## data chunk size 120 ## data chunk size
121 ck_size = fread (fid, 1, "uint32", 0, BYTEORDER); 121 ck_size = fread (fid, 1, "uint32", 0, BYTEORDER);
122 122
123 ## determine sample data type 123 ## determine sample data type
188 188
189 if (bits_per_sample == 24) 189 if (bits_per_sample == 24)
190 yi = reshape (yi, 3, rows(yi)/3)'; 190 yi = reshape (yi, 3, rows(yi)/3)';
191 yi(yi(:,3) >= 128, 3) -= 256; 191 yi(yi(:,3) >= 128, 3) -= 256;
192 yi = yi * [1; 256; 65536]; 192 yi = yi * [1; 256; 65536];
193 end 193 endif
194
194 if (format_tag == FORMAT_PCM) 195 if (format_tag == FORMAT_PCM)
195 ## normalize samples 196 ## normalize samples
196 switch (bits_per_sample) 197 switch (bits_per_sample)
197 case 8 198 case 8
198 yi = (yi - 128)/127; 199 yi = (yi - 128)/127;