| 351 | self._data_seek_needed = 1 |
| 352 | |
| 353 | def readframes(self, nframes): |
| 354 | if self._data_seek_needed: |
| 355 | self._data_chunk.seek(0, 0) |
| 356 | pos = self._soundpos * self._framesize |
| 357 | if pos: |
| 358 | self._data_chunk.seek(pos, 0) |
| 359 | self._data_seek_needed = 0 |
| 360 | if nframes == 0: |
| 361 | return b'' |
| 362 | data = self._data_chunk.read(nframes * self._framesize) |
| 363 | if self._sampwidth != 1 and sys.byteorder == 'big': |
| 364 | data = _byteswap(data, self._sampwidth) |
| 365 | if self._convert and data: |
| 366 | data = self._convert(data) |
| 367 | self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) |
| 368 | return data |
| 369 | |
| 370 | # |
| 371 | # Internal methods. |