[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] File reading ?'s



OK.  I figured out how to get at the information of AIFF files.  It 
wasn't easy (searching through Hex codes in Disk Editor), but I think 
I've got it done.

But I'm not sure if MacPerl's "read" function is broken, or I just don't 
understand it.  Putting "read" calls with starting points other than 0 
gives me garbage.  There doesn't seem to be any documentation on this 
function at all in the MacPerl book online.  This approach didn't work at 
all:

-------

open (INFILE, $file) or die "Couldn't open $file";

binmode (INFILE);

 read (INFILE, $Channels, 1, 21); #Get the number of channels
 
 #Get Sample Rate info
 
 read (INFILE, $One, 1, 29); #Divisor
 read (INFILE, $Two, 1, 30); #Sample Rate
 read (INFILE, $Three, 1, 31);
 
 read (INFILE, $bitDepth, 1, 27); #Get the bit depth
 


close (INFILE);

-----

But, changed to this:

-----

open (INFILE, $file) or die "Couldn't open $file";

binmode (INFILE);

read (INFILE, $HeadRead, 54, 0); 

close (INFILE);

# Get the info from the Header

$Channels = substr($HeadRead, 21, 1);
$Depth = substr($HeadRead, 27, 1);
$One = substr($HeadRead, 29, 1);
$Two = substr($HeadRead, 30, 1);
$Three = substr($HeadRead, 31, 1);


-----

It worked fine.  Am I missing something about the "read" function?  I 
used the syntax that I found in my "Perl for Dummies" book...

Also, how do you read in the "Resource" fork?  I think that the info for 
Sound Designer 2 files are located there.

Thanks,

Jeremy

Jeremy Lee                     |   Owner- 
Sound Designer/Technician      |   Madrone Ridge Sound Design
Oregon Shakespeare Festival    |   Sound for Multimedia
                               |
                 http://www.ashland.net/madrone
-------------------------------------------------------------------------
"Is it not strange that sheeps' guts should hale souls out of men's 
bodies?"  
        -  Wm. Shakespeare

"The mime sang:"  - Alfred Jarry
------------------------


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch