summaryrefslogtreecommitdiffstats
path: root/Lib/wave.py
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-11-17 02:41:54 (GMT)
committerJesus Cea <jcea@jcea.es>2012-11-17 02:41:54 (GMT)
commite4b863982c93e7661edb682b258ca104f5c5f6d6 (patch)
treeeac1d534403ac092d23b05cd28aae1695d7a0e96 /Lib/wave.py
parent103f17ef918188ea2f50b01bb616953082d5f4e2 (diff)
downloadcpython-e4b863982c93e7661edb682b258ca104f5c5f6d6.zip
cpython-e4b863982c93e7661edb682b258ca104f5c5f6d6.tar.gz
cpython-e4b863982c93e7661edb682b258ca104f5c5f6d6.tar.bz2
Closes #16461: Wave library should be able to deal with 4GB wav files, and sample rate of 44100 Hz.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r--Lib/wave.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/wave.py b/Lib/wave.py
index 2877137..54f0302 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -261,9 +261,9 @@ class Wave_read:
#
def _read_fmt_chunk(self, chunk):
- wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<hhllh', chunk.read(14))
+ wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14))
if wFormatTag == WAVE_FORMAT_PCM:
- sampwidth = struct.unpack_from('<h', chunk.read(2))[0]
+ sampwidth = struct.unpack_from('<H', chunk.read(2))[0]
self._sampwidth = (sampwidth + 7) // 8
else:
raise Error('unknown format: %r' % (wFormatTag,))
@@ -466,14 +466,14 @@ class Wave_write:
self._nframes = initlength // (self._nchannels * self._sampwidth)
self._datalength = self._nframes * self._nchannels * self._sampwidth
self._form_length_pos = self._file.tell()
- self._file.write(struct.pack('<l4s4slhhllhh4s',
+ self._file.write(struct.pack('<L4s4sLHHLLHH4s',
36 + self._datalength, b'WAVE', b'fmt ', 16,
WAVE_FORMAT_PCM, self._nchannels, self._framerate,
self._nchannels * self._framerate * self._sampwidth,
self._nchannels * self._sampwidth,
self._sampwidth * 8, b'data'))
self._data_length_pos = self._file.tell()
- self._file.write(struct.pack('<l', self._datalength))
+ self._file.write(struct.pack('<L', self._datalength))
self._headerwritten = True
def _patchheader(self):
@@ -482,9 +482,9 @@ class Wave_write:
return
curpos = self._file.tell()
self._file.seek(self._form_length_pos, 0)
- self._file.write(struct.pack('<l', 36 + self._datawritten))
+ self._file.write(struct.pack('<L', 36 + self._datawritten))
self._file.seek(self._data_length_pos, 0)
- self._file.write(struct.pack('<l', self._datawritten))
+ self._file.write(struct.pack('<L', self._datawritten))
self._file.seek(curpos, 0)
self._datalength = self._datawritten