Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1be9e87
docs: Update the docs to include the V2 API (#692)
microbit-mark Dec 3, 2020
71d5eef
Docs: update for V2 neopixel module (#694)
microbit-mark Dec 18, 2020
353e6e1
Docs: Speaker update and play() pin arguments (#695)
microbit-mark Dec 18, 2020
5357b8e
V2 docs: Remove is_on() from speaker. (#696)
microbit-carlos Dec 21, 2020
f9a37b4
V2 docs: Add pin set_touch_mode() (#701)
microbit-mark Jan 8, 2021
070e590
docs: Update Memory layout, Partial Flashing, Building for V2, BLE (#…
microbit-sam Feb 3, 2021
5774623
docs: Include V2 features in tutorials (#709)
microbit-mark Feb 24, 2021
c967053
docs: dev guide updates (#711)
microbit-mark Mar 16, 2021
eab72dd
docs: Indicate pin_speaker is only for PWM (#715)
microbit-mark Apr 7, 2021
79aced6
docs: Fix typo in neopixel, mumber -> number (#727)
microbit-matt-hillsdon Sep 23, 2021
8bc1fe8
docs: Add V2 microbit.set_volume() info. (#742)
microbit-carlos Apr 25, 2022
a870ff4
docs: Add note about possible 250kbit/sec radio rate in V2. (#744)
microbit-carlos Apr 29, 2022
8007c9e
docs: Add data logging API (#720)
microbit-mark Sep 5, 2022
8c107e9
docs: Add Power Management documentation. (#754)
microbit-carlos Sep 5, 2022
1e4265a
docs: Add Sound Effects documentation. (#753)
microbit-carlos Sep 6, 2022
44c2c1a
docs: Add missing `days` parameter to `microbit.run_every`. (#767)
microbit-carlos Sep 12, 2022
0d6f5b7
docs: Rename wave->waveform from SoundEffect. (#765)
microbit-carlos Sep 21, 2022
a538cb8
docs: Update Power Mgm to change run_every behaviour. (#769)
microbit-carlos Oct 24, 2022
202fab2
docs: Overwrite configued version always be '2' for v2-docs.
microbit-carlos Nov 15, 2022
8c42897
docs: Update URL to download arm-none-eabi-gcc. (#787)
microbit-carlos Dec 6, 2022
905577a
docs: Improve microphone description, add more info for `set_threshol…
microbit-carlos Apr 12, 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
docs: Rename wave->waveform from SoundEffect. (#765)
  • Loading branch information
microbit-carlos committed Sep 16, 2024
commit 0d6f5b74e8a8d805b9a5530a4bd0fc8744511073
19 changes: 10 additions & 9 deletions docs/audio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Sound Effects **V2**
====================

.. py:class::
SoundEffect(freq_start=500, freq_end=2500, duration=500, vol_start=255, vol_end=0, wave=WAVE_SQUARE, fx=FX_NONE, shape=SHAPE_LOG)
SoundEffect(freq_start=500, freq_end=2500, duration=500, vol_start=255, vol_end=0, waveform=WAVEFORM_SQUARE, fx=FX_NONE, shape=SHAPE_LOG)

An ``SoundEffect`` instance represents a sound effect, composed by a set of
parameters configured via the constructor or attributes.
Expand All @@ -129,9 +129,10 @@ Sound Effects **V2**
:param duration: Duration of the sound (ms), default: ``500``
:param vol_start: Start volume value, range 0-255, default: ``255``
:param vol_end: End volume value, range 0-255, default: ``0``
:param wave: Type of wave shape, one of these values: ``WAVE_SINE``,
``WAVE_SAWTOOTH``, ``WAVE_TRIANGLE``, ``WAVE_SQUARE``,
``WAVE_NOISE`` (randomly generated noise). Default: ``WAVE_SQUARE``
:param waveform: Type of waveform shape, one of these values:
``WAVEFORM_SINE``, ``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``,
``WAVEFORM_SQUARE``, ``WAVEFORM_NOISE`` (randomly generated noise).
Default: ``WAVEFORM_SQUARE``
:param fx: Effect to add on the sound, one of the following values:
``FX_TREMOLO``, ``FX_VIBRATO``, ``FX_WARBLE``, or ``FX_NONE``.
Default: ``FX_NONE``
Expand Down Expand Up @@ -165,11 +166,11 @@ Sound Effects **V2**

End volume value, a number between ``0`` and ``255``.

.. py:attribute:: wave
.. py:attribute:: waveform

Type of wave shape, one of these values: ``WAVE_SINE``,
``WAVE_SAWTOOTH``, ``WAVE_TRIANGLE``, ``WAVE_SQUARE``,
``WAVE_NOISE`` (randomly generated noise).
Type of waveform shape, one of these values: ``WAVEFORM_SINE``,
``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``, ``WAVEFORM_SQUARE``,
``WAVEFORM_NOISE`` (randomly generated noise).

.. py:attribute:: fx

Expand All @@ -193,7 +194,7 @@ For example, with the :doc:`REPL </devguide/repl>` you can inspect the
default SoundEffects::

>>> print(audio.SoundEffect())
SoundEffect(freq_start=500, freq_end=2500, duration=500, vol_start=255, vol_end=0, wave=WAVE_SQUARE, fx=FX_NONE, shape=SHAPE_LOG)
SoundEffect(freq_start=500, freq_end=2500, duration=500, vol_start=255, vol_end=0, waveform=WAVE_SQUARE, fx=FX_NONE, shape=SHAPE_LOG)

This format is "human readable", which means it is easy for us to read,
and it looks very similar to the code needed to create that SoundEffect,
Expand Down
8 changes: 4 additions & 4 deletions examples/soundeffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
duration=500,
vol_start=100,
vol_end=255,
wave=audio.SoundEffect.WAVE_TRIANGLE,
waveform=audio.SoundEffect.WAVEFORM_TRIANGLE,
fx=audio.SoundEffect.FX_VIBRATO,
shape=audio.SoundEffect.SHAPE_LOG
))
Expand All @@ -27,13 +27,13 @@
# You can also create a new effect based on an existing one, and modify
# any of its characteristics via arguments
my_modified_effect = my_effect.copy()
my_modified_effect.wave = audio.SoundEffect.WAVE_NOISE
my_modified_effect.waveform = audio.SoundEffect.WAVEFORM_NOISE
audio.play(my_modified_effect)

# Use sensor data to modify and play an existing Sound Effect instance
my_effect.duration = 600
while True:
# int() might be temporarily neededhttps://github.com/microbit-foundation/micropython-microbit-v2/issues/121
# int() might be temporarily needed: https://github.com/microbit-foundation/micropython-microbit-v2/issues/121
my_effect.freq_start = int(scale(accelerometer.get_x(), from_=(-2000, 2000), to=(0, 9999)))
my_effect.freq_end = int(scale(accelerometer.get_y(), from_=(-2000, 2000), to=(0, 9999)))
audio.play(my_effect)
Expand All @@ -44,7 +44,7 @@
display.show(Image("09090:00000:00900:09990:00900"))
sleep(500)
elif button_b.is_pressed():
# On button B re-enable speaker & play an effect while showing an image
# Button B re-enables the speaker & plays an effect while showing an image
speaker.on()
audio.play(audio.SoundEffect(), wait=False)
display.show(Image.MUSIC_QUAVER)
Expand Down