Skip to content

Commit 2e7ae05

Browse files
Add set_rate and get_rate to audio doc, tweaks
1 parent 422a4df commit 2e7ae05

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lang/en/typeshed/stdlib/microbit/audio.pyi

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ class AudioRecording:
179179
:param rate: The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function.
180180
"""
181181

182+
def set_rate(self, sample_rate: int) -> None:
183+
"""Configure the sampling rate associated with the data in the
184+
``AudioRecording`` instance.
185+
186+
Example: ``my_recording.set_rate(22_000)``
187+
188+
:param sample_rate: The sample rate to set.
189+
"""
190+
191+
def get_rate(self) -> int:
192+
"""Get the sampling rate associated with the data in the
193+
``AudioRecording`` instance.
194+
195+
Example: ``current_rate = my_recording.get_rate()``
196+
197+
:return: The configured sample rate.
198+
"""
199+
182200
def copy(self) -> None:
183201
"""Create a copy of the ``AudioRecording``.
184202
@@ -247,7 +265,6 @@ class AudioTrack:
247265
"""Configure the sampling rate associated with the data in the
248266
``AudioTrack`` instance.
249267
250-
251268
Changes to an ``AudioTrack`` rate won't affect the original source rate,
252269
so multiple instances pointing to the same buffer can have different
253270
rates and the original buffer rate would stay unmodified.

lang/en/typeshed/stdlib/microbit/microphone.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ def set_sensitivity(gain: float) -> None:
156156
157157
The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.
158158
159-
:param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.
159+
:param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, which all correspond to a number, or a value between these levels.
160160
"""
161161
...

0 commit comments

Comments
 (0)