Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Update for forthcoming beta MicroPython #97

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
791689a
Add was_touched
microbit-matt-hillsdon Mar 19, 2024
506c92f
Add `get_touches` method docs
microbit-grace Mar 20, 2024
9221520
WIP recording playback APIs
microbit-matt-hillsdon Mar 20, 2024
12a25f1
Change :returns: -> :return:
microbit-grace Mar 20, 2024
d9b3ffb
Add examples
microbit-grace Mar 20, 2024
44af467
Tweak
microbit-grace Mar 20, 2024
5ff1eb7
Update to deep_sleep doc
microbit-grace Mar 20, 2024
6190ec7
Update run_every microbit doc
microbit-grace Mar 20, 2024
9704523
Change the en/typeshed instead of welsh typeshed
microbit-grace Mar 20, 2024
e0a4593
Revert "Update to deep_sleep doc"
microbit-grace Mar 20, 2024
b7f91ec
Revert "Change the en/typeshed instead of welsh typeshed"
microbit-grace Mar 20, 2024
79b44b6
ticks_cpu doc
microbit-grace Apr 3, 2024
b90c486
Add WIP audio.sound_level stub
microbit-grace Apr 3, 2024
609444f
Add stubs for AudioFrame operations
microbit-matt-hillsdon Apr 3, 2024
7cb5277
Duration doesn't have a default in practice
microbit-matt-hillsdon Apr 3, 2024
f5ca4aa
Update set_threshold doc to copy micropython doc
microbit-grace Apr 12, 2024
936b172
Suggested ammendments for set_threshold doc
microbit-grace Apr 12, 2024
7057837
Update audio.sound_level doc
microbit-grace Apr 15, 2024
f4c9898
Add microphone sound_level_db doc
microbit-grace May 3, 2024
263b689
Initial stubs updates
microbit-matt-hillsdon Aug 20, 2024
3826bce
Corrections
microbit-matt-hillsdon Aug 21, 2024
6dcc5ab
Corrections
microbit-matt-hillsdon Aug 21, 2024
fc85377
Microphone stubs
microbit-matt-hillsdon Aug 21, 2024
69aaab7
Update play stubs
microbit-matt-hillsdon Aug 21, 2024
91eb337
Docs for audio.play
microbit-matt-hillsdon Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add examples
  • Loading branch information
microbit-grace committed Mar 20, 2024
commit d9b3ffb02020a4cfe63ee01e5b17154cabc7fef5
5 changes: 5 additions & 0 deletions lang/en/typeshed/stdlib/microbit/audio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ class AudioFrame:
"""Configure the sampling rate associated with the data in the
``AudioFrame`` instance (V2 only).

Example: ``my_frame.set_rate(7812)``

For recording from the microphone, increasing the sampling rate
increases the sound quality, but reduces the length of audio it
can store.

During playback, increasing the sampling rate speeds up the sound
and decreasing it slows it down.
"""
Expand All @@ -184,6 +187,8 @@ class AudioFrame:
"""Get the sampling rate associated with the data in the
``AudioFrame`` instance (V2 only).

Example: ``current_rate = my_frame.get_rate()``

:return: The configured sampling rate for this ``AudioFrame`` instance.
"""

Expand Down
13 changes: 11 additions & 2 deletions lang/en/typeshed/stdlib/microbit/microphone.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def record(duration: int = 3000, rate: int = 7812) -> AudioFrame:
"""Record sound into an ``AudioFrame`` for the amount of time indicated by
``duration`` at the sampling rate indicated by ``rate``.

Example: ``my_frame = microphone.record()``
microbit-matt-hillsdon marked this conversation as resolved.
Show resolved Hide resolved

The amount of memory consumed is directly related to the length of the
recording and the sampling rate. The higher these values, the more memory
it will use.
Expand All @@ -93,6 +95,8 @@ def record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None
"""Record sound into an existing ``AudioFrame`` until it is filled,
or the ``stop_recording()`` function is called.

Example: ``microphone.record_into()``

:param buffer: An ``AudioFrame`` to record sound.
:param rate: Number of samples to capture per second.
:param wait: When set to ``True`` it blocks until the recording is
Expand All @@ -103,13 +107,16 @@ def record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None
def is_recording() -> bool:
"""Checks whether the microphone is currently recording.

:return: ``True`` if the microphone is currently recording sound, or
``False`` otherwise.
Example: ``is_recording = microphone.is_recording()``

:return: ``True`` if the microphone is currently recording sound, otherwise returns ``False``.
"""
...

def stop_recording() -> None:
"""Stops a recording running in the background.

Example: ``microphone.stop_recording()``
"""
...

Expand All @@ -126,6 +133,8 @@ SENSITIVITY_HIGH: float;
def set_sensitivity(gain: float) -> None:
"""Configure the microphone sensitivity.

Example: ``microphone.set_sensitivity(microphone.SENSITIVITY_HIGH)``

The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.

:param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.
Expand Down
Loading