|
40 | 40 | //| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
|
41 | 41 | //| an internal buffer, which can prevent memory fragmentation."""
|
42 | 42 | //|
|
43 |
| -//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer) -> None: |
| 43 | +//| def __init__(self, file: Union(typing.BinaryIO, str), buffer: WriteableBuffer) -> None: |
44 | 44 | //| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
|
45 | 45 | //|
|
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 |
47 | 47 | //| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer,
|
48 | 48 | //| that will be split in half and used for double-buffering of the data.
|
49 | 49 | //| The buffer must be 8 to 1024 bytes long.
|
50 | 50 | //| If not provided, two 256 byte buffers are initially allocated internally.
|
51 | 51 | //|
|
52 |
| -//| |
53 | 52 | //| Playing a wave file from flash::
|
54 | 53 | //|
|
55 | 54 | //| import board
|
|
61 | 60 | //| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
|
62 | 61 | //| speaker_enable.switch_to_output(value=True)
|
63 | 62 | //|
|
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")) |
66 | 65 | //| a = audioio.AudioOut(board.A0)
|
67 | 66 | //|
|
68 | 67 | //| print("playing")
|
69 | 68 | //| a.play(wav)
|
70 | 69 | //| while a.playing:
|
71 | 70 | //| pass
|
72 | 71 | //| print("stopped")
|
73 |
| -//| |
74 |
| -//| Support was added for taking a filename as parameter, instead of an opened file, |
75 |
| -//| and opening the file internally. |
76 | 72 | //| """
|
77 | 73 | //| ...
|
78 | 74 | //|
|
|
0 commit comments