Sounds Logical
Send Page To a Friend

Table Of Contents Previous Page Next Page

[M-Pack 1 overview]

M-Pack 1: WAV file processing: MATLAB function reference

wavinfo
Version 1.2 Requires MATLAB 6.0 (R12) or later

Read the header information from a WAV format audio file. If called without an output argument, the results are displayed.

File format: m-file
Editable source code:
yes
Utilises non-editable functions: no
Platform:
PC/Windows
Required MATLAB Toolboxes: none (except core MATLAB)
Demo version limitations: p-code only (non-editable); demo banner displayed
Syntax:

info=wavinfo(filename);

Arguments:
Input:
filename

name of input WAV file (with optional .WAV extension).

Output:
info

[optional] structure containing header information with the some or all of the following fields (note: the italicized fields do NOT correspond to fields contained in the WAV file header -- they are included to provide supplementary descriptive information based on that found in the header):

  • FormatTag code corresponding to WAV file format (e.g. 1 for WAVE_FORMAT_PCM, 65534 for WAVE_FORMAT_EXTENSIBLE etc)
  • FormatDescription verbal description of format
  • NumberOfChannels number of (interleaved) channels
  • SampleRate sample rate (in Hz)
  • AvBytesPerSec should equal: SampleRate*BlockAlign; gives indication of data throughput (e.g. for design of I/O buffers, etc)
  • BlockAlign should equal: ContainerBits*NumberOfChannels/8
  • BitsPerSample ambiguously defined for WAVE_FORMAT_PCM. Originally intended to be the actual valid number of bits, but often used as container size (in bits). For WAVE_FORMAT_EXTENSIBLE, unambiguously defined as container size (in bits)
  • cbSize length (in bytes) of extra information at end of fmt chunk (must be greater than or equal to 22 for WAVE_FORMAT_EXTENSIBLE)
  • ValidBitsPerSample actual number of bits per sample (only explicitly included in header for WAVE_FORMAT_EXTENSIBLE).
  • ChannelMask (in decimal format) which prescribes the multichannel speaker allocation for WAVE_FORMAT_EXTENSIBLE. Type 'help chnmsk2spkrlist' to read more about the ChannelMask property.
  • SpeakerList cell array containing ordered list of speakers (only valid for WAVE_FORMAT_EXTENSIBLE
  • ChannelMaskFormats sub-structure containing ChannelMask in decimal, binary, and hexadecimal formats (only valid for WAVE_FORMAT_EXTENSIBLE)
  • ContainerBytes size of sample container (expressed in bytes)
  • ContainerBits size of sample container (expressed in bits)
  • SamplesPerChannel number of samples per channel
  • Notes useful information about the file e.g. if ValidBits ambiguity detected for WAVE_FORMAT_PCM
  • Error description of fatal error encountered when attempting to open and/or read the file

See the M-Pack 1 overview (plus references) for a discussion of the WAV format.

Makes use of the chnmsk2spkrlist function to determine the speaker list from the ChannelMask.

An error is reported if the file has the WAVE_FORMAT_EXTENSIBLE FormatTag but does not have the SubFormat field corresponding to the PCM storage format (Microsoft GUID KSDATAFORMAT_SUBTYPE_PCM).

 

  chnmsk2spkrlist convert ChannelMask to speaker list
  wavin    WAV file reading
  wavout     WAV file writing
Examples:
Ex.1 Query the header of a mono WAV file named wavewarp.wav located in the directory ..\WAVFiles
 
  >> wavinfo('..\WAVfiles\wavewarp.wav');
   
 
FormatTag:
1
 
FormatDescription:
'Microsoft WAVE_FORMAT_PCM'                 
 
NumberOfChannels:
1
SampleRate:
44100
AvBytesPerSec:
88200
 
BlockAlign:
2
 
BitsPerSample:
16
 
ContainerBytes:
2
 
ContainerBits:
16
 
SamplesPerChannel:
229280
     
Ex.2 Query the header of a 4-channel WAV file named 4channel.wav located in the directory ..\WAVFiles
 
  >> info=wavinfo('..\WAVfiles\4channel.wav');
     
 
FormatTag:
65534
 
FormatDescription:
'Microsoft WAVE_FORMAT_EXTENSIBLE'
 
NumberOfChannels:
4
 
SampleRate:
44100
 
AvBytesPerSec:
352800
 
BlockAlign:
8
 
BitsPerSample:
16
 
cbSize:
22
 
ValidBitsPerSample:
16
 
ChannelMask:
263
 
SpeakerList:
{4x1 cell}
 
ChannelMaskFormats:
[1x1 struct]
 
ContainerBytes:
2
 
ContainerBits:
16
 
SamplesPerChannel:
169031
     
  >> info.SpeakerList  
     
 
'1.Front Left - FL'
    '2.Front Right - FR'
    '3.Front Center - FC'
  '4.Back Center - BC'
     
  >> info.ChannelMaskFormats  
     
 
decimal:
263
 
binary:
'100000111'
 
hex:
'107'

Top Of Page Table Of Contents Previous Page Next Page

Send Page To a Friend

home - news - products - store - support - site map - company info
© 2007 Sounds Logical. All rights reserved.
Sounds Logical
legal notice - privacy statement