Source

pygame / lib / _numpysndarray.py

Diff from to

lib/_numpysndarray.py

 import pygame.mixer as mixer 
 import numpy
 
-def array (sound):
-    """pygame._numpysndarray.array(Sound): return array
-
-    Copy Sound samples into an 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().
-    """
+def _array_samples(sound, raw):
     # Info is a (freq, format, stereo) tuple
     info = mixer.get_init ()
     if not info:
         raise pygame.error, "Mixer not initialized"
     fmtbytes = (abs (info[1]) & 0xff) >> 3
-    channels = mixer.get_num_channels ()
-    data = sound.get_buffer ().raw
+    channels = info[2]
+    if raw:
+        data = sound.get_buffer ().raw
+    else:
+        data = sound.get_buffer ()
 
     shape = (len (data) / channels * fmtbytes, )
     if channels > 1:
     array.shape = shape
     return array
 
+def array (sound):
+    """pygame._numpysndarray.array(Sound): return array
+
+    Copy Sound samples into an 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().
+    """
+    return _array_samples(sound, True)
+
 def samples (sound):
     """pygame._numpysndarray.samples(Sound): return array
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.