[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wavread problems update
From: |
Doug Stewart |
Subject: |
wavread problems update |
Date: |
Mon, 09 May 2005 12:10:08 -0500 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
While modifying wavread.m I came across an issue with strcmp
here is part of wavread:
fpi = fopen(infile,'r');
id = fread(fpi, 1,'int32');
if (strcmp(id,'RIFF')!=0)
error(sprintf('%s not a WAV file',infile));
end
disp(sprintf('Input file \'%s\' is RIFF format:',infile));
nbytes = fread(fpi, 1,'int32');
disp(sprintf('\tTotal length = %d bytes',nbytes));
subfmt = fread(fpi, 1,'int32');
s(4)=round(subfmt/(256^3));
sb=subfmt-s(4)*256^3;
s(3)=round(sb/256^2);
sb=sb-s(3)*256^2;
s(2)=round(sb/256^1);
sb=sb-s(2)*256^1;
s(1)=round(sb);
ss=setstr(s);
disp(sprintf('Subformat = \'%s\' ',ss));
if (strcmp(subfmt,'WAVE')!=0)
error('*** Cannot handle subformat %s',subfmt);
end
In the section
id = fread(fpi, 1,'int32');
if (strcmp(id,'RIFF')!=0)
we are reading a 32 bit number from the file and in the "if strcmp" we
are assuming it is a string.
But this does not work. Should strcmp handle this?
To make it work I took the 32 bit number apart into 8 bit numbers and
made a string then it works.
this code is not elegant yet and is not a finished product.
I just wanted to know if I should make strcmp handle this?
also is there a function that will do what I have done in the following?
( take a number and assume it is some ascii chars)
s(4)=round(subfmt/(256^3));
sb=subfmt-s(4)*256^3;
s(3)=round(sb/256^2);
sb=sb-s(3)*256^2;
s(2)=round(sb/256^1);
sb=sb-s(2)*256^1;
s(1)=round(sb);
ss=setstr(s);
Doug Stewart
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- wavread problems + ploting tools+ using octave classes in C++, Marc Vinyes, 2005/05/08
- Re: wavread problems + ploting tools+ using octave classes in C++, Doug Stewart, 2005/05/08
- Re: wavread problems (focusing on this), Marc Vinyes, 2005/05/08
- Re: wavread problems (focusing on this), Doug Stewart, 2005/05/08
- Re: wavread problems (focusing on this), Marc Vinyes, 2005/05/08
- Re: wavread problems (focusing on this), Doug Stewart, 2005/05/08
- Re: wavread problems (focusing on this), Doug Stewart, 2005/05/08
- Re: wavread problems (focusing on this), Miroslaw Kwasniak, 2005/05/09
- Re: wavread problems (focusing on this), Robert A. Macy, 2005/05/08
- wavread problems update,
Doug Stewart <=
- New wavread available, Doug Stewart, 2005/05/09
- Re: New wavread available, Robert A. Macy, 2005/05/10
- Re: New wavread available, Doug Stewart, 2005/05/10
- Re: New wavread available, Robert A. Macy, 2005/05/10
- Re: wavread problems (focusing on this), Miroslaw Kwasniak, 2005/05/09
- Re: wavread problems (focusing on this), Søren Hauberg, 2005/05/08
Re: wavread problems + ploting tools+ using octave classes in C++, Marc Vinyes, 2005/05/08
Re: wavread problems + ploting tools+ using octave classes in C++, Miroslaw Kwasniak, 2005/05/09