|
2 | 2 | """
|
3 | 3 |
|
4 | 4 | from ..microbit import MicroBitDigitalPin, Sound, pin0
|
5 |
| -from typing import ClassVar, Iterable, Optional, Union |
| 5 | +from typing import ClassVar, Iterable, Optional, Union, overload |
6 | 6 |
|
7 | 7 | def play(
|
8 | 8 | source: Union[AudioFrame, Iterable[AudioFrame], Sound, SoundEffect],
|
@@ -262,10 +262,27 @@ class AudioTrack:
|
262 | 262 | :return: The configured sample rate.
|
263 | 263 | """
|
264 | 264 |
|
| 265 | + def copyfrom(self, other: Union[bytearray, AudioRecording, AudioTrack]) -> None: |
| 266 | + """Overwrite the data in this ``AudioTrack`` with the data from another |
| 267 | + ``AudioTrack``, ``AudioRecording``, or buffer-like object like a |
| 268 | + ``bytearray`` instance. |
| 269 | +
|
| 270 | + If the input buffer is smaller than the available space in this |
| 271 | + instance, the rest of the data is left untouched. |
| 272 | + If it is larger, it will stop copying once this instance is filled. |
| 273 | + |
| 274 | + :param other: Buffer-like instance from which to copy the data. |
| 275 | + """ |
265 | 276 |
|
266 | 277 | def __len__(self) -> int: ...
|
267 |
| - def __setitem__(self, key: int, value: int) -> None: ... |
268 |
| - def __getitem__(self, key: int) -> int: ... |
| 278 | + |
| 279 | + |
| 280 | + @overload |
| 281 | + def __getitem__(self, i: int) -> int: ... |
| 282 | + @overload |
| 283 | + def __getitem__(self, s: slice) -> AudioTrack: ... |
| 284 | + def __setitem__(self, i: int, x: int) -> None: ... |
| 285 | + |
269 | 286 | def __add__(self, v: AudioTrack) -> AudioTrack: ...
|
270 | 287 | def __iadd__(self, v: AudioTrack) -> AudioTrack: ...
|
271 | 288 | def __sub__(self, v: AudioTrack) -> AudioTrack: ...
|
|
0 commit comments