| 358 | self._data_seek_needed = 1 |
| 359 | |
| 360 | def readframes(self, nframes): |
| 361 | if self._data_seek_needed: |
| 362 | self._data_chunk.seek(0, 0) |
| 363 | pos = self._soundpos * self._framesize |
| 364 | if pos: |
| 365 | self._data_chunk.seek(pos, 0) |
| 366 | self._data_seek_needed = 0 |
| 367 | if nframes == 0: |
| 368 | return b'' |
| 369 | data = self._data_chunk.read(nframes * self._framesize) |
| 370 | if self._sampwidth != 1 and sys.byteorder == 'big': |
| 371 | data = _byteswap(data, self._sampwidth) |
| 372 | if self._convert and data: |
| 373 | data = self._convert(data) |
| 374 | self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) |
| 375 | return data |
| 376 | |
| 377 | # |
| 378 | # Internal methods. |