Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-wave.html" /> | |
13 | <link rel="prev" href="module-aifc.html" /> | |
14 | <link rel="parent" href="mmedia.html" /> | |
15 | <link rel="next" href="au-read-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>14.4 sunau -- Read and write Sun AU files</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="14.3 aifc " | |
25 | href="module-aifc.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="14. Multimedia Services" | |
28 | href="mmedia.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="14.4.1 AU_read Objects" | |
31 | href="au-read-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-aifc.html">14.3 aifc </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="mmedia.html">14. Multimedia Services</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="au-read-objects.html">14.4.1 AU_read Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION0016400000000000000000"> | |
56 | 14.4 <tt class="module">sunau</tt> -- | |
57 | Read and write Sun AU files</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-sunau"></A> | |
62 | ||
63 | <P> | |
64 | The <tt class="module">sunau</tt> module provides a convenient interface to the Sun | |
65 | AU sound format. Note that this module is interface-compatible with | |
66 | the modules <tt class="module"><a href="module-aifc.html">aifc</a></tt> and <tt class="module"><a href="module-wave.html">wave</a></tt>. | |
67 | ||
68 | <P> | |
69 | An audio file consists of a header followed by the data. The fields | |
70 | of the header are: | |
71 | ||
72 | <P> | |
73 | <div class="center"><table class="realtable"> | |
74 | <thead> | |
75 | <tr> | |
76 | <th class="left" >Field</th> | |
77 | <th class="left" >Contents</th> | |
78 | </tr> | |
79 | </thead> | |
80 | <tbody> | |
81 | <tr><td class="left" valign="baseline">magic word</td> | |
82 | <td class="left" >The four bytes "<tt class="samp">.snd</tt>".</td></tr> | |
83 | <tr><td class="left" valign="baseline">header size</td> | |
84 | <td class="left" >Size of the header, including info, in bytes.</td></tr> | |
85 | <tr><td class="left" valign="baseline">data size</td> | |
86 | <td class="left" >Physical size of the data, in bytes.</td></tr> | |
87 | <tr><td class="left" valign="baseline">encoding</td> | |
88 | <td class="left" >Indicates how the audio samples are encoded.</td></tr> | |
89 | <tr><td class="left" valign="baseline">sample rate</td> | |
90 | <td class="left" >The sampling rate.</td></tr> | |
91 | <tr><td class="left" valign="baseline"># of channels</td> | |
92 | <td class="left" >The number of channels in the samples.</td></tr> | |
93 | <tr><td class="left" valign="baseline">info</td> | |
94 | <td class="left" >ASCII string giving a description of the audio | |
95 | file (padded with null bytes).</td></tr></tbody> | |
96 | </table></div> | |
97 | ||
98 | <P> | |
99 | Apart from the info field, all header fields are 4 bytes in size. | |
100 | They are all 32-bit unsigned integers encoded in big-endian byte | |
101 | order. | |
102 | ||
103 | <P> | |
104 | The <tt class="module">sunau</tt> module defines the following functions: | |
105 | ||
106 | <P> | |
107 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
108 | <td><nobr><b><tt id='l2h-4667' xml:id='l2h-4667' class="function">open</tt></b>(</nobr></td> | |
109 | <td><var>file, mode</var>)</td></tr></table></dt> | |
110 | <dd> | |
111 | If <var>file</var> is a string, open the file by that name, otherwise treat it | |
112 | as a seekable file-like object. <var>mode</var> can be any of | |
113 | <DL> | |
114 | <DT><STRONG><code>'r'</code></STRONG></DT> | |
115 | <DD>Read only mode. | |
116 | ||
117 | </DD> | |
118 | <DT><STRONG><code>'w'</code></STRONG></DT> | |
119 | <DD>Write only mode. | |
120 | </DD> | |
121 | </DL> | |
122 | Note that it does not allow read/write files. | |
123 | ||
124 | <P> | |
125 | A <var>mode</var> of <code>'r'</code> returns a <tt class="class">AU_read</tt> | |
126 | object, while a <var>mode</var> of <code>'w'</code> or <code>'wb'</code> returns | |
127 | a <tt class="class">AU_write</tt> object. | |
128 | </dl> | |
129 | ||
130 | <P> | |
131 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
132 | <td><nobr><b><tt id='l2h-4668' xml:id='l2h-4668' class="function">openfp</tt></b>(</nobr></td> | |
133 | <td><var>file, mode</var>)</td></tr></table></dt> | |
134 | <dd> | |
135 | A synonym for <tt class="function">open</tt>, maintained for backwards compatibility. | |
136 | </dl> | |
137 | ||
138 | <P> | |
139 | The <tt class="module">sunau</tt> module defines the following exception: | |
140 | ||
141 | <P> | |
142 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-4669' xml:id='l2h-4669' class="exception">Error</tt></b></dt> | |
143 | <dd> | |
144 | An error raised when something is impossible because of Sun AU specs or | |
145 | implementation deficiency. | |
146 | </dd></dl> | |
147 | ||
148 | <P> | |
149 | The <tt class="module">sunau</tt> module defines the following data items: | |
150 | ||
151 | <P> | |
152 | <dl><dt><b><tt id='l2h-4670' xml:id='l2h-4670'>AUDIO_FILE_MAGIC</tt></b></dt> | |
153 | <dd> | |
154 | An integer every valid Sun AU file begins with, stored in big-endian | |
155 | form. This is the string "<tt class="samp">.snd</tt>" interpreted as an integer. | |
156 | </dd></dl> | |
157 | ||
158 | <P> | |
159 | <dl><dt><b><tt id='l2h-4671' xml:id='l2h-4671'>AUDIO_FILE_ENCODING_MULAW_8</tt></b></dt> | |
160 | <dd> | |
161 | <dt><b><tt id='l2h-4673' xml:id='l2h-4673'>AUDIO_FILE_ENCODING_LINEAR_8</tt></b></dt><dd> | |
162 | <dt><b><tt id='l2h-4674' xml:id='l2h-4674'>AUDIO_FILE_ENCODING_LINEAR_16</tt></b></dt><dd> | |
163 | <dt><b><tt id='l2h-4675' xml:id='l2h-4675'>AUDIO_FILE_ENCODING_LINEAR_24</tt></b></dt><dd> | |
164 | <dt><b><tt id='l2h-4676' xml:id='l2h-4676'>AUDIO_FILE_ENCODING_LINEAR_32</tt></b></dt><dd> | |
165 | <dt><b><tt id='l2h-4677' xml:id='l2h-4677'>AUDIO_FILE_ENCODING_ALAW_8</tt></b></dt><dd> | |
166 | Values of the encoding field from the AU header which are supported by | |
167 | this module. | |
168 | </dd></dl> | |
169 | ||
170 | <P> | |
171 | <dl><dt><b><tt id='l2h-4672' xml:id='l2h-4672'>AUDIO_FILE_ENCODING_FLOAT</tt></b></dt> | |
172 | <dd> | |
173 | <dt><b><tt id='l2h-4678' xml:id='l2h-4678'>AUDIO_FILE_ENCODING_DOUBLE</tt></b></dt><dd> | |
174 | <dt><b><tt id='l2h-4679' xml:id='l2h-4679'>AUDIO_FILE_ENCODING_ADPCM_G721</tt></b></dt><dd> | |
175 | <dt><b><tt id='l2h-4680' xml:id='l2h-4680'>AUDIO_FILE_ENCODING_ADPCM_G722</tt></b></dt><dd> | |
176 | <dt><b><tt id='l2h-4681' xml:id='l2h-4681'>AUDIO_FILE_ENCODING_ADPCM_G723_3</tt></b></dt><dd> | |
177 | <dt><b><tt id='l2h-4682' xml:id='l2h-4682'>AUDIO_FILE_ENCODING_ADPCM_G723_5</tt></b></dt><dd> | |
178 | Additional known values of the encoding field from the AU header, but | |
179 | which are not supported by this module. | |
180 | </dd></dl> | |
181 | ||
182 | <P> | |
183 | ||
184 | <p><br /></p><hr class='online-navigation' /> | |
185 | <div class='online-navigation'> | |
186 | <!--Table of Child-Links--> | |
187 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
188 | ||
189 | <UL CLASS="ChildLinks"> | |
190 | <LI><A href="au-read-objects.html">14.4.1 AU_read Objects</a> | |
191 | <LI><A href="au-write-objects.html">14.4.2 AU_write Objects</a> | |
192 | </ul> | |
193 | <!--End of Table of Child-Links--> | |
194 | </div> | |
195 | ||
196 | <DIV CLASS="navigation"> | |
197 | <div class='online-navigation'> | |
198 | <p></p><hr /> | |
199 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
200 | <tr> | |
201 | <td class='online-navigation'><a rel="prev" title="14.3 aifc " | |
202 | href="module-aifc.html"><img src='../icons/previous.png' | |
203 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
204 | <td class='online-navigation'><a rel="parent" title="14. Multimedia Services" | |
205 | href="mmedia.html"><img src='../icons/up.png' | |
206 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
207 | <td class='online-navigation'><a rel="next" title="14.4.1 AU_read Objects" | |
208 | href="au-read-objects.html"><img src='../icons/next.png' | |
209 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
210 | <td align="center" width="100%">Python Library Reference</td> | |
211 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
212 | href="contents.html"><img src='../icons/contents.png' | |
213 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
214 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
215 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
216 | <td class='online-navigation'><a rel="index" title="Index" | |
217 | href="genindex.html"><img src='../icons/index.png' | |
218 | border='0' height='32' alt='Index' width='32' /></A></td> | |
219 | </tr></table> | |
220 | <div class='online-navigation'> | |
221 | <b class="navlabel">Previous:</b> | |
222 | <a class="sectref" rel="prev" href="module-aifc.html">14.3 aifc </A> | |
223 | <b class="navlabel">Up:</b> | |
224 | <a class="sectref" rel="parent" href="mmedia.html">14. Multimedia Services</A> | |
225 | <b class="navlabel">Next:</b> | |
226 | <a class="sectref" rel="next" href="au-read-objects.html">14.4.1 AU_read Objects</A> | |
227 | </div> | |
228 | </div> | |
229 | <hr /> | |
230 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
231 | </DIV> | |
232 | <!--End of Navigation Panel--> | |
233 | <ADDRESS> | |
234 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
235 | </ADDRESS> | |
236 | </BODY> | |
237 | </HTML> |