Closed microbit-carlos closed 5 months ago
I'm guessing this is because the default value for duration
in AudioFrame
is -1
:
https://github.com/microbit-foundation/micropython-microbit-v2/blob/c91ae4e83c5a1a82f647740277f7d4a462192160/src/codal_port/modaudio.c#L316-L319
Should that be set to None
and raise a ValueError
with any negative values?
'm guessing this is because the default value for
duration
inAudioFrame
is-1
Yes, correct.
Should that be set to
None
and raise aValueError
with any negative values?
I have now made this change.
microphone.record(0)
return a zero-length AudioFrame
That's also now fixed, as is the case of passing in a non-zero rate
.
Using the latest version (at the time of writing) of the recording & playback branch: https://github.com/microbit-foundation/micropython-microbit-v2/commit/0b06914c71c18533da90df85230ac198578669bf Hex: https://github.com/microbit-foundation/micropython-microbit-v2/actions/runs/8416237764?pr=163
An AudioFrame with 0 duration or rate raises a ValueError:
A negative rate also raises ValueError:
But negative value results in the default length
On the other hand,
microphone.record(0)
return a zero-length AudioFrame (which might be related to https://github.com/microbit-foundation/micropython-microbit-v2/issues/185):