]> git.parisson.com Git - timeside.git/commitdiff
gstutils: use reshape((-1,chan)) to reshape buffer automatically with the right shape
authorThomas Fillon <thomas@parisson.com>
Thu, 6 Mar 2014 08:47:53 +0000 (09:47 +0100)
committerThomas Fillon <thomas@parisson.com>
Thu, 6 Mar 2014 08:50:18 +0000 (09:50 +0100)
timeside/tools/gstutils.py

index 67e09c64aac59703527c40ad81536fa456e400e6..960a8db818e5bacfca9b73a3529e4829d3ddcfbc 100644 (file)
@@ -21,8 +21,7 @@ def numpy_array_to_gst_buffer(frames, chunk_size, num_samples, sample_rate):
 
 def gst_buffer_to_numpy_array(buf, chan):
     """ gstreamer buffer to numpy array conversion """
-    samples = frombuffer(buf.data, dtype='float32')
-    samples.resize([len(samples)/chan, chan])
+    samples = frombuffer(buf.data, dtype='float32').reshape((-1, chan))
     return samples