Mercurial > pygame
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 |
| rev | line source |
|---|---|
| 627 | 1 |
| 2 <html> | |
| 3 <title>sndarray - Pygame Documentation</title> | |
| 4 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111> | |
| 5 | |
| 6 | |
| 651 | 7 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'> |
| 8 <tr> | |
| 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> | |
| 10 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center> | |
| 627 | 11 || |
| 12 <a href=http://www.pygame.org>Pygame Home</a> || | |
| 13 <a href=../index.html>Help Contents</a> || | |
| 14 <a href=index.html>Reference Index</a> || | |
| 15 <br> <br> | |
| 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> || |
| 974 | 18 <a href="cdrom.html">Cdrom</a> || |
| 1037 | 19 <a href="color.html">Color</a> || |
| 974 | 20 <a href="cursors.html">Cursors</a> || |
| 21 <a href="display.html">Display</a> || | |
| 22 <a href="draw.html">Draw</a> || | |
| 23 <a href="event.html">Event</a> || | |
|
1448
c496066bc336
add examples module document page
Lenard Lindstrom <len-l@telus.net>
parents:
1419
diff
changeset
|
24 <a href="examples.html">Examples</a> || |
| 974 | 25 <a href="font.html">Font</a> || |
| 1849 | 26 <a href="freetype.html">Freetype</a> || |
| 1781 | 27 <a href="gfxdraw.html">Gfxdraw</a> || |
| 974 | 28 <a href="image.html">Image</a> || |
| 29 <a href="joystick.html">Joystick</a> || | |
| 30 <a href="key.html">Key</a> || | |
|
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> || |
| 974 | 32 <a href="mask.html">Mask</a> || |
|
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> || |
| 974 | 34 <a href="mixer.html">Mixer</a> || |
| 35 <a href="mouse.html">Mouse</a> || | |
| 36 <a href="movie.html">Movie</a> || | |
| 37 <a href="music.html">Music</a> || | |
| 38 <a href="overlay.html">Overlay</a> || | |
| 39 <a href="pixelarray.html">Pixelarray</a> || | |
| 40 <a href="pygame.html">Pygame</a> || | |
| 41 <a href="rect.html">Rect</a> || | |
| 42 <a href="scrap.html">Scrap</a> || | |
| 43 <a href="sndarray.html">Sndarray</a> || | |
| 44 <a href="sprite.html">Sprite</a> || | |
| 45 <a href="surface.html">Surface</a> || | |
| 46 <a href="surfarray.html">Surfarray</a> || | |
|
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> || |
| 974 | 48 <a href="time.html">Time</a> || |
| 49 <a href="transform.html">Transform</a> | |
| 651 | 50 </td></tr></table> |
| 627 | 51 <br> |
| 52 | |
| 53 | |
| 54 <a name="pygame.sndarray"> | |
| 55 <big><b>pygame.sndarray</big></b><br><ul> | |
| 56 <i>pygame module for accessing sound sample data</i><br> | |
| 57 <ul><small><table> | |
| 651 | 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> |
| 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> | |
| 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 | 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 | 64 </table></small></ul> |
| 902 | 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 | 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> |
| 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 | 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 | 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> |
| 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--> <br> |
| 627 | 76 |
| 77 | |
| 78 <a name="pygame.sndarray.array"> | |
| 79 <big><b>pygame.sndarray.array</big></b><br><ul> | |
| 80 <i>copy Sound samples into an array</i><br> | |
| 81 <tt>pygame.sndarray.array(Sound): return array</tt><br> | |
| 902 | 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--> <br> |
| 627 | 84 <br></ul> |
| 85 | |
| 86 | |
| 87 <a name="pygame.sndarray.samples"> | |
| 88 <big><b>pygame.sndarray.samples</big></b><br><ul> | |
| 89 <i>reference Sound samples into an array</i><br> | |
| 90 <tt>pygame.sndarray.samples(Sound): return array</tt><br> | |
| 902 | 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--> <br> |
| 627 | 93 <br></ul> |
| 94 | |
| 95 | |
| 96 <a name="pygame.sndarray.make_sound"> | |
| 97 <big><b>pygame.sndarray.make_sound</big></b><br><ul> | |
| 98 <i>convert an array into a Sound object</i><br> | |
| 99 <tt>pygame.sndarray.make_sound(array): return Sound</tt><br> | |
| 902 | 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--> <br> |
| 627 | 102 <br></ul> |
| 902 | 103 |
| 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 | 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 | 109 <p>Uses the requested array type for the module functions. Currently supported array types are: </p> |
| 110 <pre> numeric | |
| 111 numpy | |
| 112 </pre><p>If the requested type is not available, a ValueError will be raised. </p> | |
| 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--> <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--> <br> |
| 902 | 125 <br></ul> |
| 126 | |
| 127 | |
| 128 <a name="pygame.sndarray.get_arraytypes"> | |
| 129 <big><b>pygame.sndarray.get_arraytypes</big></b><br><ul> | |
| 130 <i>Gets the array system types currently supported.</i><br> | |
| 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 | 133 <p>New in pygame <tt>1.8</tt>. </p> |
| 134 <!--COMMENTS:pygame.sndarray.get_arraytypes--> <br> | |
| 135 <br></ul> | |
| 627 | 136 <br></ul> |
| 137 | |
| 138 </body></html> |
