On 11-May-2005, Doug Stewart wrote:
| I have been working at fixing wavread, and I have run into a snag.
|
| I am running Andy Adler's port 2.1.42 and
|
| cygwin with 2.1.50
|
| In 2.1.42 this code works
|
|
| % read riff chunk ChunkID 4 bytes
| RIFF_str=char(fread(fid,4,'uchar'));
| if (strcmp(RIFF_str,'RIFF')==0)
| fclose(fid);
| error(sprintf('%s is not a WAV file',wavefile));
| end
|
| but in 2.1.50 it doesn't
| but this does
|
| % read riff chunk ChunkID 4 bytes
| RIFF_str=char(fread(fid,4,'uchar'));
| if (strcmp(RIFF_str','RIFF')==0)
| fclose(fid);
| error(sprintf('%s is not a WAV file',wavefile));
| end
|
| I had to transpose the RIFF_str for the strcmp to work.
|
| So my question is
| 1 - is this a windows problem?
| 2 - did strcmp change or char change?
| 3 - more importantly what way does the latest version work?
For compatibility, fread returns a column vector, even if the result
is a character string. But you could also write
char (fread (fid, [1, 4], "uchar"))
if you want a row vector.
BTW, you can write
error ("%s is not a WAV file", wavefile);
instead of using sprintf because the error function processes
arguments the same as printf.
jwe