12 Aug 00:02
patch for io/wavfile.py
From: Jason Newton <nevion <at> gmail.com>
Subject: patch for io/wavfile.py
Newsgroups: gmane.comp.python.scientific.devel
Date: 2008-08-11 22:03:01 GMT
Subject: patch for io/wavfile.py
Newsgroups: gmane.comp.python.scientific.devel
Date: 2008-08-11 22:03:01 GMT
Hi, I was unfortunate to discover a bug in io.wavfile, it assumes long to be 4 bytes on all architectures and on my amd64 box I was getting errors reading simple wavs until I made the changes contained in the patch. Basically just swapped out int for long in all the struct pack and unpack calls where it made sense to.
--- wavfile.py 2007-09-22 00:56:31.000000000 -0700
+++ /usr/share/pyshared/scipy/io/wavfile.py 2008-08-07 13:05:12.819623113 -0700
@@ -4,7 +4,7 @@
# assumes file pointer is immediately
# after the 'fmt ' id
def _read_fmt_chunk(fid):
- res = struct.unpack('lhHLLHH',fid.read(20))
+ res = struct.unpack('ihHIIHH',fid.read(20))
size, comp, noc, rate, sbytes, ba, bits = res
if (comp != 1 or size > 16):
print "Warning: unfamiliar format bytes..."
@@ -15,7 +15,7 @@
# assumes file pointer is immediately
# after the 'data' id
def _read_data_chunk(fid, noc, bits):
- size = struct.unpack('l',fid.read(4))[0]
+ size = struct.unpack('i',fid.read(4))[0]
if bits == 8:
data = numpy.fromfile(fid, dtype=numpy.ubyte, count=size)
if noc > 1:
@@ -30,7 +30,7 @@
(Continue reading)
RSS Feed