You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
28
29
//|
29
30
//| :param Union[str, typing.BinaryIO] file: The name of a mp3 file (preferred) or an already opened mp3 file
30
-
//| :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.
31
32
//|
32
33
//| Playback of mp3 audio is CPU intensive, and the
33
34
//| exact limit depends on many factors such as the particular
34
-
//| microcontroller, SD card or flash performance, and other
35
-
//| code in use such as displayio. If playback is garbled,
36
-
//| 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:
37
38
//|
38
39
//| * Use constant bit rate (CBR) not VBR or ABR (variable or average bit rate) when encoding your mp3 file
39
40
//| * Use a lower sample rate (e.g., 11.025kHz instead of 48kHz)
@@ -63,21 +64,31 @@
63
64
//| while a.playing:
64
65
//| pass
65
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.
0 commit comments