Skip to content

Commit 129c5de

Browse files
committed
Made requested changes in the documentation
1 parent 21551a8 commit 129c5de

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

shared-bindings/audiocore/WaveFile.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@
4040
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
4141
//| an internal buffer, which can prevent memory fragmentation."""
4242
//|
43-
//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer) -> None:
43+
//| def __init__(self, file: Union(typing.BinaryIO, str), buffer: WriteableBuffer) -> None:
4444
//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
4545
//|
46-
//| :param typing.BinaryIO file: Already opened wave file
46+
//| :param Union(typing.BinaryIO, str) file: The name of a wave file (preferred) or an already opened wave file
4747
//| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer,
4848
//| that will be split in half and used for double-buffering of the data.
4949
//| The buffer must be 8 to 1024 bytes long.
5050
//| If not provided, two 256 byte buffers are initially allocated internally.
5151
//|
52-
//|
5352
//| Playing a wave file from flash::
5453
//|
5554
//| import board
@@ -61,18 +60,15 @@
6160
//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
6261
//| speaker_enable.switch_to_output(value=True)
6362
//|
64-
//| data = open("cplay-5.1-16bit-16khz.wav", "rb")
65-
//| wav = audiocore.WaveFile(data)
63+
//| wav = audiocore.WaveFile("cplay-5.1-16bit-16khz.wav") # preferred use
64+
//| # wav = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb"))
6665
//| a = audioio.AudioOut(board.A0)
6766
//|
6867
//| print("playing")
6968
//| a.play(wav)
7069
//| while a.playing:
7170
//| pass
7271
//| print("stopped")
73-
//|
74-
//| Support was added for taking a filename as parameter, instead of an opened file,
75-
//| and opening the file internally.
7672
//| """
7773
//| ...
7874
//|

shared-bindings/audiomp3/MP3Decoder.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
//| https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/reducing-memory-fragmentation
4545
//| """
4646
//|
47-
//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer) -> None:
47+
//| def __init__(self, file: Union(typing.BinaryIO, str), buffer: WriteableBuffer) -> None:
4848
//|
4949
//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
5050
//|
51-
//| :param typing.BinaryIO file: Already opened mp3 file
51+
//| :param Union(typing.BinaryIO, str) file: The name of a mp3 file (preferred) or an already opened mp3 file
5252
//| :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.
5353
//|
5454
//| Playback of mp3 audio is CPU intensive, and the
@@ -77,18 +77,15 @@
7777
//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
7878
//| speaker_enable.switch_to_output(value=True)
7979
//|
80-
//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb")
81-
//| mp3 = audiomp3.MP3Decoder(data)
80+
//| mp3 = audiomp3.MP3Decoder("cplay-16bit-16khz-64kbps.mp3") # preferred use
81+
//| # mp3 = audiomp3.MP3Decoder(open("cplay-16bit-16khz-64kbps.mp3", "rb"))
8282
//| a = audioio.AudioOut(board.A0)
8383
//|
8484
//| print("playing")
8585
//| a.play(mp3)
8686
//| while a.playing:
8787
//| pass
8888
//| print("stopped")
89-
//|
90-
//| Support was added for taking a filename as parameter, instead of an opened file,
91-
//| and opening the file internally.
9289
//| """
9390
//| ...
9491
//|

0 commit comments

Comments
 (0)