annotate docs/ref/sndarray.html @ 1849:301bc61643a9 math_module

merged changes from trunk
author lorenz
date Mon, 16 Nov 2009 18:31:40 +0000
parents 1f6df4baebd5
children f51d9315c3e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
1
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
2 <html>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
3 <title>sndarray - Pygame Documentation</title>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
4 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
5
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
6
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
7 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
8 <tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
9 <td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
10 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
11 ||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
12 <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
13 <a href=../index.html>Help Contents</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
14 <a href=index.html>Reference Index</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
15 <br>&nbsp;<br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
16
1323
1ca45b50f8ea camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents: 1037
diff changeset
17 <a href="camera.html">Camera</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
18 <a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
1037
c4c38b97db3b Added Color class.
marcus
parents: 974
diff changeset
19 <a href="color.html">Color</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
20 <a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
21 <a href="display.html">Display</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
22 <a href="draw.html">Draw</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
23 <a href="event.html">Event</a>&nbsp;||&nbsp;
1448
c496066bc336 add examples module document page
Lenard Lindstrom <len-l@telus.net>
parents: 1419
diff changeset
24 <a href="examples.html">Examples</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
25 <a href="font.html">Font</a>&nbsp;||&nbsp;
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1781
diff changeset
26 <a href="freetype.html">Freetype</a>&nbsp;||&nbsp;
1781
1f6df4baebd5 add gfxdraw docs
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
27 <a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
28 <a href="image.html">Image</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
29 <a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
30 <a href="key.html">Key</a>&nbsp;||&nbsp;
1373
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1323
diff changeset
31 <a href="locals.html">Locals</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
32 <a href="mask.html">Mask</a>&nbsp;||&nbsp;
1548
9379bdac652e add event object comparison as per mailing list request
Lenard Lindstrom <len-l@telus.net>
parents: 1459
diff changeset
33 <a href="midi.html">Midi</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
34 <a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
35 <a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
36 <a href="movie.html">Movie</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
37 <a href="music.html">Music</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
38 <a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
39 <a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
40 <a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
41 <a href="rect.html">Rect</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
42 <a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
43 <a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
44 <a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
45 <a href="surface.html">Surface</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
46 <a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
1419
5f26c8759fa7 pygame.tests: added docs, go module and polished help messages
Lenard Lindstrom <len-l@telus.net>
parents: 1373
diff changeset
47 <a href="tests.html">Tests</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
48 <a href="time.html">Time</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 957
diff changeset
49 <a href="transform.html">Transform</a>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
50 </td></tr></table>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
51 <br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
52
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
53
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
54 <a name="pygame.sndarray">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
55 <big><b>pygame.sndarray</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
56 <i>pygame module for accessing sound sample data</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
57 <ul><small><table>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
58 <tr><td><a href="sndarray.html#pygame.sndarray.array">pygame.sndarray.array</a> - <font size=-1>copy Sound samples into an array</font></td><td>copy Sound samples into an array</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
59 <tr><td><a href="sndarray.html#pygame.sndarray.samples">pygame.sndarray.samples</a> - <font size=-1>reference Sound samples into an array</font></td><td>reference Sound samples into an array</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
60 <tr><td><a href="sndarray.html#pygame.sndarray.make_sound">pygame.sndarray.make_sound</a> - <font size=-1>convert an array into a Sound object</font></td><td>convert an array into a Sound object</td></tr>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
61 <tr><td><a href="sndarray.html#pygame.sndarray.use_arraytype">pygame.sndarray.use_arraytype</a> - <font size=-1>Sets the array system to be used for sound arrays</font></td><td>Sets the array system to be used for sound arrays</td></tr>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
62 <tr><td><a href="sndarray.html#pygame.sndarray.get_arraytype">pygame.sndarray.get_arraytype</a> - <font size=-1>Gets the currently active array type.</font></td><td>Gets the currently active array type.</td></tr>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
63 <tr><td><a href="sndarray.html#pygame.sndarray.get_arraytypes">pygame.sndarray.get_arraytypes</a> - <font size=-1>Gets the array system types currently supported.</font></td><td>Gets the array system types currently supported.</td></tr>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
64 </table></small></ul>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
65 <p>Functions to convert between Numeric or numpy arrays and Sound objects. This module will only be available when pygame can use the external numpy or Numeric package. </p>
711
48d403fff022 more doc updates from Dan Richter
pygame
parents: 678
diff changeset
66 <p>Sound data is made of thousands of samples per second, and each sample is the amplitude of the wave at a particular moment in time. For example, in 22-kHz format, element number 5 of the array is the amplitude of the wave after 5/22000 seconds. </p>
48d403fff022 more doc updates from Dan Richter
pygame
parents: 678
diff changeset
67 <p>Each sample is an 8-bit or 16-bit integer, depending on the data format. <tt>A</tt> stereo sound file has two values per sample, while a mono sound file only has one. </p>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
68 <p>Supported array systems are </p>
1459
ac7c93b62b1e numpy now takes priority over Numeric in sndarry and surfarray
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
69 <pre> numpy
ac7c93b62b1e numpy now takes priority over Numeric in sndarry and surfarray
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
70 numeric
ac7c93b62b1e numpy now takes priority over Numeric in sndarry and surfarray
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
71 </pre><p>The default will be numpy, if installed. Otherwise, Numeric will be set as default if installed. If neither numpy nor Numeric are installed, the module will raise an ImportError. </p>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
72 <p>The array type to use can be changed at runtime using the use_arraytype() method, which requires one of the above types as string. </p>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
73 <p>Note: numpy and Numeric are not completely compatible. Certain array manipulations, which work for one type, might behave differently or even completely break for the other. </p>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
74 <p>Additionally, in contrast to Numeric numpy can use unsigned 16-bit integers. Sounds with 16-bit data will be treated as unsigned integers, if the sound sample type requests this. Numeric instead always uses signed integers for the representation, which is important to keep in mind, if you use the module's functions and wonder about the values. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
75 <!--COMMENTS:pygame.sndarray--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
76
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
77
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
78 <a name="pygame.sndarray.array">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
79 <big><b>pygame.sndarray.array</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
80 <i>copy Sound samples into an array</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
81 <tt>pygame.sndarray.array(Sound): return array</tt><br>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
82 <p>Creates a new array for the sound data and copies the samples. The array will always be in the format returned from <tt><a href="mixer.html#pygame.mixer.get_init">pygame.mixer.get_init</a> - <font size=-1>test if the mixer is initialized</font></tt>. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
83 <!--COMMENTS:pygame.sndarray.array--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
84 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
85
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
86
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
87 <a name="pygame.sndarray.samples">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
88 <big><b>pygame.sndarray.samples</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
89 <i>reference Sound samples into an array</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
90 <tt>pygame.sndarray.samples(Sound): return array</tt><br>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
91 <p>Creates a new array that directly references the samples in a Sound object. Modifying the array will change the Sound. The array will always be in the format returned from <tt><a href="mixer.html#pygame.mixer.get_init">pygame.mixer.get_init</a> - <font size=-1>test if the mixer is initialized</font></tt>. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
92 <!--COMMENTS:pygame.sndarray.samples--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
93 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
94
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
95
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
96 <a name="pygame.sndarray.make_sound">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
97 <big><b>pygame.sndarray.make_sound</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
98 <i>convert an array into a Sound object</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
99 <tt>pygame.sndarray.make_sound(array): return Sound</tt><br>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
100 <p>Create a new playable Sound object from an array. The mixer module must be initialized and the array format must be similar to the mixer audio format. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
101 <!--COMMENTS:pygame.sndarray.make_sound--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
102 <br></ul>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
103
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
104
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
105 <a name="pygame.sndarray.use_arraytype">
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
106 <big><b>pygame.sndarray.use_arraytype</big></b><br><ul>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
107 <i>Sets the array system to be used for sound arrays</i><br>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
108 <tt>pygame.sndarray.use_arraytype (arraytype): return None</tt><br>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
109 <p>Uses the requested array type for the module functions. Currently supported array types are: </p>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
110 <pre> numeric
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
111 numpy
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
112 </pre><p>If the requested type is not available, a ValueError will be raised. </p>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
113 <p>New in pygame <tt>1.8</tt>. </p>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
114 <!--COMMENTS:pygame.sndarray.use_arraytype--> &nbsp;<br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
115 <br></ul>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
116
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
117
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
118 <a name="pygame.sndarray.get_arraytype">
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
119 <big><b>pygame.sndarray.get_arraytype</big></b><br><ul>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
120 <i>Gets the currently active array type.</i><br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
121 <tt>pygame.sndarray.get_arraytype (): return str</tt><br>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
122 <p>Returns the currently active array type. This will be a value of the get_arraytypes() tuple and indicates which type of array module is used for the array creation. </p>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
123 <p>New in pygame <tt>1.8</tt> </p>
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
124 <!--COMMENTS:pygame.sndarray.get_arraytype--> &nbsp;<br>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
125 <br></ul>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
126
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
127
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
128 <a name="pygame.sndarray.get_arraytypes">
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
129 <big><b>pygame.sndarray.get_arraytypes</big></b><br><ul>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
130 <i>Gets the array system types currently supported.</i><br>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
131 <tt>pygame.sndarray.get_arraytypes (): return tuple</tt><br>
957
a1b08375b132 Added display.set_mode() resolution enhancement as posted by Lorenz Quack.
marcus
parents: 902
diff changeset
132 <p>Checks, which array systems are available and returns them as a tuple of strings. The values of the tuple can be used directly in the <tt>pygame.sndarray.use_arraytype</tt> () method. If no supported array system could be found, None will be returned. </p>
902
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
133 <p>New in pygame <tt>1.8</tt>. </p>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
134 <!--COMMENTS:pygame.sndarray.get_arraytypes--> &nbsp;<br>
1a7ba62d41f6 Updated and fixed docs.
marcus
parents: 862
diff changeset
135 <br></ul>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
136 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
137
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
138 </body></html>