File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ def readframes(self, nframes):
305305 self ._data_seek_needed = 0
306306 if nframes == 0 :
307307 return ''
308- if self ._sampwidth > 1 :
308+ if self ._sampwidth > 1 and big_endian :
309309 # unfortunately the fromfile() method does not take
310310 # something that only looks like a file object, so
311311 # we have to reach into the innards of the chunk object
@@ -316,8 +316,7 @@ def readframes(self, nframes):
316316 nitems = (self ._data_chunk .chunksize - self ._data_chunk .size_read ) / self ._sampwidth
317317 data .fromfile (self ._data_chunk .file , nitems )
318318 self ._data_chunk .size_read = self ._data_chunk .size_read + nitems * self ._sampwidth
319- if big_endian :
320- data .byteswap ()
319+ data .byteswap ()
321320 data = data .tostring ()
322321 else :
323322 data = self ._data_chunk .read (nframes * self ._framesize )
@@ -487,11 +486,10 @@ def writeframesraw(self, data):
487486 nframes = len (data ) / (self ._sampwidth * self ._nchannels )
488487 if self ._convert :
489488 data = self ._convert (data )
490- if self ._sampwidth > 1 :
489+ if self ._sampwidth > 1 and big_endian :
491490 import array
492491 data = array .array (_array_fmts [self ._sampwidth ], data )
493- if big_endian :
494- data .byteswap ()
492+ data .byteswap ()
495493 data .tofile (self ._file )
496494 self ._datawritten = self ._datawritten + len (data ) * self ._sampwidth
497495 else :
You can’t perform that action at this time.
0 commit comments