From: Thomas Fillon Date: Thu, 6 Mar 2014 08:47:53 +0000 (+0100) Subject: gstutils: use reshape((-1,chan)) to reshape buffer automatically with the right shape X-Git-Tag: 0.5.5~3^2^2~26 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=88274f4fe7e8e0381dfb584ee013186a8485d643;p=timeside.git gstutils: use reshape((-1,chan)) to reshape buffer automatically with the right shape --- diff --git a/timeside/tools/gstutils.py b/timeside/tools/gstutils.py index 67e09c6..960a8db 100644 --- a/timeside/tools/gstutils.py +++ b/timeside/tools/gstutils.py @@ -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