File: sndarray.rst.txt

package info (click to toggle)
pygame 2.1.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,416 kB
  • sloc: ansic: 66,042; python: 46,176; javascript: 9,214; objc: 273; sh: 78; makefile: 56; cpp: 25
file content (95 lines) | stat: -rw-r--r-- 3,260 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.. include:: common.txt

:mod:`pygame.sndarray`
======================

.. module:: pygame.sndarray
   :synopsis: pygame module for accessing sound sample data

| :sl:`pygame module for accessing sound sample data`

Functions to convert between NumPy arrays and Sound objects. This
module will only be functional when pygame can use the external NumPy
package. If NumPy can't be imported, ``surfarray`` becomes a ``MissingModule``
object.

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.

The arrays are indexed by the ``X`` axis first, followed by the ``Y`` axis.
Each sample is an 8-bit or 16-bit integer, depending on the data format. A
stereo sound file has two values per sample, while a mono sound file only has
one.

.. function:: array

   | :sl:`copy Sound samples into an array`
   | :sg:`array(Sound) -> array`

   Creates a new array for the sound data and copies the samples. The array
   will always be in the format returned from ``pygame.mixer.get_init()``.

   .. ## pygame.sndarray.array ##

.. function:: samples

   | :sl:`reference Sound samples into an array`
   | :sg:`samples(Sound) -> array`

   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 ``pygame.mixer.get_init()``.

   .. ## pygame.sndarray.samples ##

.. function:: make_sound

   | :sl:`convert an array into a Sound object`
   | :sg:`make_sound(array) -> Sound`

   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.

   .. ## pygame.sndarray.make_sound ##

.. function:: use_arraytype

   | :sl:`Sets the array system to be used for sound arrays`
   | :sg:`use_arraytype (arraytype) -> None`

   DEPRECATED: Uses the requested array type for the module functions. The
   only supported arraytype is ``'numpy'``. Other values will raise ValueError.
   Using this function will raise a ``DeprecationWarning``.
   .. ## pygame.sndarray.use_arraytype ##

.. function:: get_arraytype

   | :sl:`Gets the currently active array type.`
   | :sg:`get_arraytype () -> str`

   DEPRECATED: 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. Using this function will raise a ``DeprecationWarning``.

   .. versionadded:: 1.8

   .. ## pygame.sndarray.get_arraytype ##

.. function:: get_arraytypes

   | :sl:`Gets the array system types currently supported.`
   | :sg:`get_arraytypes () -> tuple`

   DEPRECATED: 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
   :func:`pygame.sndarray.use_arraytype` () method. If no supported array
   system could be found, None will be returned.  Using this function will raise a
   ``DeprecationWarning``.

   .. versionadded:: 1.8

   .. ## pygame.sndarray.get_arraytypes ##

.. ## pygame.sndarray ##