Connecting Tech Pros Worldwide Help | Site Map

.wav file header info

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 02:26 AM
Rajesh Kapur
Guest
 
Posts: n/a
Default .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



  #2  
Old July 17th, 2005, 02:26 AM
Andy Hassall
Guest
 
Posts: n/a
Default 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&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 <andy@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.