Debian Codegraph @

cpython27/Doc/library/sndhdr.rst

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