470,565 Members | 2,223 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,565 developers. It's quick & easy.

.wav file header info

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
Jul 17 '05 #1
1 22727
On Wed, 14 Jan 2004 13:59:20 -0600, "Rajesh Kapur" <rk****@mpr.org> wrote:
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 ...


http://www.google.com/search?hl=en&i...+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 <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Roy | last post: by
4 posts views Thread by Frank Kociemba | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.