From 5a4fe91ce1b78392678ceba294467c885891a046 Mon Sep 17 00:00:00 2001 From: hackEns Date: Thu, 5 Dec 2013 18:01:27 +0100 Subject: [PATCH] Bug correction in sound4python when one doesn't have numpy installed --- Chorizo player/sound4python.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Chorizo player/sound4python.py b/Chorizo player/sound4python.py index 57f9112..fff9450 100644 --- a/Chorizo player/sound4python.py +++ b/Chorizo player/sound4python.py @@ -52,7 +52,12 @@ def sound(itr,samprate=16000,autoscale=True,output=False): wroteFrames=True if( not wroteFrames and not foundNumpy ): #python w/o np doesn't have "short"/"int16", "@h" is "native,aligned short" - waveWrite.writeframes( struct.pack(len(itr)*"@h",[int(mult*itm) for itm in itr]) ) + # BAD : waveWrite.writeframes( struct.pack(len(itr)*"@h",[int(mult*itm) for itm in itr]) ) + writeValues = [] + for itm in itr: + packed_value = struct.pack('h', int(mult*itm)) + waveWrite.writeframes(packed_value) + wroteFrames=True if( not wroteFrames ):