-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 At 7:45 PM +0000 6/9/98, Jeremy Lee wrote: } 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); You don't need this. binmode is a no-op in MacPerl. Like Unix, files are byte streams; there's no fundamental distinction between binary and text files. } } read (INFILE, $Channels, 1, 21); #Get the number of channels I think you're expecting byte 21 of the file to be read? That's not how read works. Read the documentation again. This will put one (the next, wherever the file pointer happens to be pointing) byte from the file and put it in position 21 of $Channels. I don't know what fills the first 20 bytes of $Channels; I wouldn't be suprised to find anything. To do what you're trying to do, you'd do something like seek(INFILE,21,0) read(INFILE,$Channels,1); etc. } } #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); And *here* you're putting one byte into $Channels, the 21st byte of the file, which is not what you're doing above. Do it this way, or learn how to use unpack. Using unpack, you'll be able to fill in all of these with a single statement. } $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... "Perl for Dummies" really documents read this way? If so, you need a real book. Go out and buy "Programming Perl", by Wall, Christiansen & Schwartz ("the Camel"), which is the definitive reference for Perl. } } Also, how do you read in the "Resource" fork? I think that the info for } Sound Designer 2 files are located there. Mac::Resources is probably the way you want to do it. Heed the warnings in the documentation for it, which can be reached from the Help menu of MacPerl. } } 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 } ------------------------ - ----- Paul J. Schinder schinder@pobox.com -----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv iQA/AwUBNX4BI1ZaVc52j0XhEQLKjACeL6aCyAEF8sN96XeoQzNR3qXoJasAoOXM Kk54SKwVwlfstaEgq6qraXhu =O0tN -----END PGP SIGNATURE----- ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch