-
Notifications
You must be signed in to change notification settings - Fork 288
Docs: Speaker update #695
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
Merged
microbit-carlos
merged 19 commits into
bbcmicrobit:v2-docs
from
microbit-mark:speaker-update
Dec 18, 2020
Merged
Docs: Speaker update #695
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
55d4ae0
speaker pin changes
microbit-mark ed582a1
Docs: update speaker pin info
microbit-mark 3cc91cf
Add speaker page
microbit-mark 8be36c4
grammar
microbit-mark 6049106
Link to speaker page
microbit-mark 51341cd
add speaker to navigation
microbit-mark 10d8199
add speaker example
microbit-mark 788075b
Update docs/speaker.rst
microbit-mark 4d8cb26
Update docs/speaker.rst
microbit-mark dc6a1dd
Update docs/music.rst
microbit-mark 885647c
Docs: Update speaker pin
microbit-mark e46dfcf
remove build
microbit-mark 81f37d9
gitignore _build directory
microbit-mark 05c8b16
update music
microbit-mark 8c0b208
Update docs/music.rst
microbit-carlos 07dcded
Update docs/speech.rst
microbit-carlos 910ab02
Update docs/speech.rst
microbit-carlos 142342c
Update docs/speech.rst
microbit-carlos 0408cc1
Update docs/music.rst
microbit-carlos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.yotta.json | ||
build/* | ||
_build/* | ||
yotta_modules/* | ||
yotta_targets/* | ||
*.swp | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,5 +77,6 @@ Modules | |
display.rst | ||
i2c.rst | ||
microphone.rst | ||
speaker.rst | ||
spi.rst | ||
uart.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Speaker **V2** | ||
************** | ||
|
||
.. py:module:: microbit.speaker | ||
|
||
The micro:bit **V2** has a built-in speaker located on the rear of the board. | ||
|
||
.. image:: speaker.png | ||
:width: 300px | ||
:align: center | ||
:height: 240px | ||
:alt: speaker on rear of micro:bit V2 | ||
|
||
By default sound output will be via the edge connector on pin 0 and the | ||
built-in speaker **V2**. You can connect wired headphones or a speaker to | ||
pin 0 and GND on the edge connector to hear the sounds. | ||
|
||
The speaker can be turned off or on using the functions listed here. | ||
|
||
Functions | ||
microbit-carlos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
========= | ||
|
||
.. py:function:: off() | ||
|
||
Use off() to turn off the speaker. This does not disable sound output, so | ||
you will still hear sound on Pin 0 if you have headphones or a speaker | ||
connected to that pin. | ||
|
||
.. py:function:: on() | ||
|
||
Use ``on()`` to turn on the speaker. | ||
|
||
.. py:function:: is_on() | ||
|
||
Returns ``True`` if the speaker is on, otherwise returns ``False``. | ||
|
||
Example | ||
======= | ||
|
||
An example that runs through some of the functions of the speaker API. :: | ||
|
||
from microbit import * | ||
import audio | ||
|
||
# Check that the speaker is on | ||
print(speaker.is_on()) | ||
# Play a sound | ||
audio.play(Sound.HELLO) | ||
sleep(2000) | ||
# Disable the speaker | ||
speaker.off() | ||
# Check that the speaker is off | ||
print(speaker.is_on()) | ||
# Play a sound. This will not be heard on the speaker, but will be heard | ||
# on Pin 0 if you have headphones or a speaker connected. | ||
audio.play(Sound.HELLO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ Speech | |
|
||
This module makes the micro:bit talk, sing and make other speech like sounds. | ||
By default sound output will be via the edge connector on pin 0 and the | ||
built-in speaker **V2**. You can connect a wired headphones or a speaker to | ||
pin 0 and GND on the edge connector to hear the sound: | ||
:doc:`built-in speaker <speaker>` **V2**. You can connect wired headphones or | ||
a speaker to pin 0 and GND on the edge connector to hear the sound: | ||
|
||
.. image:: speech.png | ||
|
||
|
@@ -46,32 +46,27 @@ Functions | |
emphasis. | ||
|
||
.. py:function:: pronounce(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128) | ||
pronounce(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128, pin=(pin_speaker, pin0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The speech module will still have the pin argument in V2, it's just the default that changes. |
||
pronounce(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) | ||
|
||
Pronounce the phonemes in the string ``phonemes``. See below for details of | ||
how to use phonemes to finely control the output of the speech synthesiser. | ||
Override the optional pitch, speed, mouth and throat settings to change the | ||
timbre (quality) of the voice. | ||
|
||
As with the music module, you can use an optional argument to specify the | ||
output pin can be used to override the default of ``microbit.pin0``. | ||
If you have the latest micro:bit **V2**, you can use | ||
``microbit.pin_speaker``. | ||
|
||
The pin argument can also take a tuple of two pins, for example | ||
``pin=(pin_speaker, pin0)`` which would output sound on the built-in | ||
speaker and pin 0. | ||
For micro:bit **V2** an optional argument to specify the output pin can be | ||
used to override the default of ``pin0``. If we do not want any sound to | ||
play out of the pins can use ``pin=None``. | ||
|
||
.. py:function:: say(words, \*, pitch=64, speed=72, mouth=128, throat=128) | ||
microbit-carlos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
say(words, \*, pitch=64, speed=72, mouth=128, throat=128, pin=(pin_speaker, pin0)) | ||
say(words, \*, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) | ||
|
||
Say the English words in the string ``words``. The result is semi-accurate | ||
for English. Override the optional pitch, speed, mouth and throat | ||
settings to change the timbre (quality) of the voice. This is a short-hand | ||
equivalent of: ``speech.pronounce(speech.translate(words))`` | ||
|
||
.. py:function:: sing(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128) | ||
microbit-carlos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sing(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128, pin=(pin_speaker, pin0)) | ||
sing(phonemes, \*, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) | ||
|
||
Sing the phonemes contained in the string ``phonemes``. Changing the pitch | ||
and duration of the note is described below. Override the optional pitch, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.