|
28 | 28 | //| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. |
29 | 29 | //| |
30 | 30 | //| :param Union[str, typing.BinaryIO] file: The name of a mp3 file (preferred) or an already opened mp3 file |
31 | | -//| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. |
| 31 | +//| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split and used for buffering the data. The buffer is split into two parts for decoded data and the remainder is used for pre-decoded data. When playing from a socket, a larger buffer can help reduce playback glitches at the expense of increased memory usage. |
32 | 32 | //| |
33 | 33 | //| Playback of mp3 audio is CPU intensive, and the |
34 | 34 | //| exact limit depends on many factors such as the particular |
35 | | -//| microcontroller, SD card or flash performance, and other |
36 | | -//| code in use such as displayio. If playback is garbled, |
37 | | -//| skips, or plays as static, first try using a "simpler" mp3: |
| 35 | +//| microcontroller, SD card or flash performance, network performance, and |
| 36 | +//| other code in use such as displayio. If playback is garbled, skips, or plays as |
| 37 | +//| static, first try using a "simpler" mp3: |
38 | 38 | //| |
39 | 39 | //| * Use constant bit rate (CBR) not VBR or ABR (variable or average bit rate) when encoding your mp3 file |
40 | 40 | //| * Use a lower sample rate (e.g., 11.025kHz instead of 48kHz) |
|
64 | 64 | //| while a.playing: |
65 | 65 | //| pass |
66 | 66 | //| print("stopped") |
| 67 | +//| |
| 68 | +//| It is possible to seek within a file before playing it:: |
| 69 | +//| |
| 70 | +//| with open("/test.mp3", "rb") as stream: |
| 71 | +//| stream.seek(128000 * 30 // 8) # Seek about 30s into a 128kbit/s stream |
| 72 | +//| decoder.file = stream |
| 73 | +//| |
| 74 | +//| If the stream is played with ``loop = True``, the loop will start at the beginning. |
67 | 75 | //| """ |
68 | 76 | //| ... |
69 | 77 |
|
|
0 commit comments