Skip to content

Commit ad7e00f

Browse files
docs: Add more info to microphone.set_threshold().
1 parent d805b37 commit ad7e00f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/microphone.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Functions
3333

3434
.. py:function:: current_event()
3535
36-
Get the last recorded sound event
36+
Get the last recorded sound event.
3737

3838
:return: The event, ``SoundEvent('loud')`` or ``SoundEvent('quiet')``.
3939

@@ -44,7 +44,7 @@ Functions
4444
This call clears the sound history before returning.
4545

4646
:param event: The event to check for, such as ``SoundEvent.LOUD`` or
47-
``SoundEvent.QUIET``
47+
``SoundEvent.QUIET``.
4848
:return: ``True`` if sound was heard at least once since the last call,
4949
otherwise ``False``.
5050

@@ -70,12 +70,20 @@ Functions
7070
7171
Set the threshold for a sound event.
7272

73-
A high threshold means the event will only trigger if the sound is
74-
very loud (>= 250 in the example).
73+
The ``SoundEvent.LOUD`` event will be triggered when the sound level
74+
crosses this threshold upwards (from "quiet" to "loud"),
75+
and ``SoundEvent.QUIET`` event is triggered when crossing the threshold
76+
downwards (from "loud" to "quiet").
77+
78+
If the ``SoundEvent.LOUD`` value set is lower than ``SoundEvent.QUIET``,
79+
then "quiet" threshold will be decreased to one unit below the "loud"
80+
threshold. If the ``SoundEvent.QUIET`` value is set higher than
81+
``SoundEvent.LOUD``, then the "loud" threshold will be set one unit above.
7582

7683
:param event: A sound event, such as ``SoundEvent.LOUD`` or
7784
``SoundEvent.QUIET``.
78-
:param value: The threshold level in the range 0-255.
85+
:param value: The threshold level in the range 0-255. Values outside this
86+
range will be clamped.
7987

8088
.. py:function:: sound_level()
8189

0 commit comments

Comments
 (0)