Skip to content

Microphone events and threshold inconsistency #160

Open
@davidtkaye

Description

@davidtkaye

I got frustrated with microphone.set_threshold seemingly to make no difference to a project, so decided to run some test code to see whether sound events were being triggered at different levels.

I got some very strange inconsistent results with loud/quiet events. It seems like the loud event only triggers above a much higher threshold than the one set, and the quiet event seems to be triggering whenever the loud event is not, making the threshold set for that irrelevant? I apologise if I am not correctly understanding how these events work.

Here's the code I used and some sample outputs

from microbit import *

microphone.set_threshold(SoundEvent.LOUD, 80)
microphone.set_threshold(SoundEvent.QUIET, 20)

for _ in range(10):
    if microphone.current_event() == SoundEvent.LOUD:
        print('loud event: {}'.format(microphone.sound_level()))
    elif microphone.current_event() == SoundEvent.QUIET:
        print('quiet event: {}'.format(microphone.sound_level()))
    sleep(1000)

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions