Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

.wav file header info

Question posted by: Rajesh Kapur (Guest) on July 17th, 2005 02:26 AM
Hi,

Does anyone know how to extract the header information like duration, bit
rate, audio channel configuration etc from a wave file? An example (if
possible) would really help ...

Thanks.
- Rajesh


Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Andy Hassall's Avatar
Andy Hassall
Guest
n/a Posts
July 17th, 2005
02:26 AM
#2

Re: .wav file header info
On Wed, 14 Jan 2004 13:59:20 -0600, "Rajesh Kapur" <rkapur@mpr.org> wrote:
[color=blue]
>Does anyone know how to extract the header information like duration, bit
>rate, audio channel configuration etc from a wave file? An example (if
>possible) would really help ...[/color]

http://www.google.com/search?hl=en&...v+header+format

Or search for WAV on http://www.wotsit.org/

Use unpack <http://php.net/unpack> to decode the header. The format looks
quite simple, so here's an example.

<pre>
<?php
$fp = fopen('chord.wav', 'r');
fseek($fp, 20);
$rawheader = fread($fp, 16);
$header = unpack('vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits',
$rawheader);
print_r($header);
?>
</pre>

Outputs:

Array
(
[type] => 1
[channels] => 2
[samplerate] => 22050
[bytespersec] => 88200
[alignment] => 4
[bits] => 16
)

--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>

 
Not the answer you were looking for? Post your question . . .
183,906 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors