blob: 90d71a9ef5eed284618739d1b674dcaefc2b7104 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001
2:mod:`sndhdr` --- Determine type of sound file
3==============================================
4
5.. module:: sndhdr
6 :synopsis: Determine type of a sound file.
7.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
8
9
10.. % Based on comments in the module source file.
11
12.. index::
13 single: A-LAW
14 single: u-LAW
15
16The :mod:`sndhdr` provides utility functions which attempt to determine the type
17of sound data which is in a file. When these functions are able to determine
18what type of sound data is stored in a file, they return a tuple ``(type,
19sampling_rate, channels, frames, bits_per_sample)``. The value for *type*
20indicates the data type and will be one of the strings ``'aifc'``, ``'aiff'``,
21``'au'``, ``'hcom'``, ``'sndr'``, ``'sndt'``, ``'voc'``, ``'wav'``, ``'8svx'``,
22``'sb'``, ``'ub'``, or ``'ul'``. The *sampling_rate* will be either the actual
23value or ``0`` if unknown or difficult to decode. Similarly, *channels* will be
24either the number of channels or ``0`` if it cannot be determined or if the
25value is difficult to decode. The value for *frames* will be either the number
26of frames or ``-1``. The last item in the tuple, *bits_per_sample*, will either
27be the sample size in bits or ``'A'`` for A-LAW or ``'U'`` for u-LAW.
28
29
30.. function:: what(filename)
31
32 Determines the type of sound data stored in the file *filename* using
33 :func:`whathdr`. If it succeeds, returns a tuple as described above, otherwise
34 ``None`` is returned.
35
36
37.. function:: whathdr(filename)
38
39 Determines the type of sound data stored in a file based on the file header.
40 The name of the file is given by *filename*. This function returns a tuple as
41 described above on success, or ``None``.
42