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
[DO NOT MERGE] Sim changes for forthcoming beta MicroPython release #113
base: main
Are you sure you want to change the base?
Conversation
On the basis that's as close as we can get to the beta for now. Still has HAL issues. One local change to MicroPython was needed to include mphal.h in modspeech - need to review how this works for the non-sim build as it seems like it should be included.
Preview build will be at |
✅ Deploy Preview for distracted-dubinsky-fd8a42 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Audio format needs some investigation - MediaRecorder might not be the right approach.
We'll still need to resample them and write them to the buffer.
Closes #101
Needs testing but likely closes #110
Edge cases need checking. Requires a higher AUDIO_CHUNK_SIZE which has other consequences but 4ms is too short.
// TODO: consider AudioWorklet - worth it? Browser support? | ||
// consider alternative resampling approaches | ||
// what sample rates are actually supported this way? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScriptProcessorNode support vs AudioWorklet support so we'd lose early Safari 14.x and Safari 13 (for 13 I think limited support is OK).
See also the techniques used in this project.
@@ -9,6 +9,8 @@ | |||
|
|||
extern ringbuf_t stdin_ringbuf; | |||
|
|||
#define mp_hal_ticks_cpu() (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to understand this / investigate new time API.
We need to do the stubs for that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some discussion on the stubs PR too
- Fix missing typescript types - Use Safari 13 compatible OfflineAudioContext constructor - this may prove pointless due to lack of < 44100 sample rate support, but is an easier starting point to try things out.
Having used this a little, I've noticed the microphone LED isn't coming on when using the computer mic. |
by stopping micStream tracks
Passing this.microphone.microphoneOn/Off functions as BoardAudio constructors in board/index.ts didn't work for some reasons. The microphone element was flagged as being undefined. So instead I passed the element directly into the BoardAudio constructor, which worked.
Deploying micropython-microbit-v2-simulator with Cloudflare Pages
|
Enable a larger audio buffer
Closes microbit-foundation/python-editor-v3#1082
Closes #110
Closes #101
Audio buffer size issue
See microbit-foundation/micropython-microbit-v2#163 (comment)
Browser support issues
Firefox
Seems that Firefox just doesn't support using web audio to resample. We've also found you can't ask media recorder for arbitrary sample rates. So that leaves us with manually resampling, at least for Firefox. We could use something like https://github.com/rochars/wave-resampler (or at least the same techniques, not clear how maintained that is).
Safari
Misc quality issues
Work to do if/when implemented in MicroPython
4da3f33
microphone.sound_level_db()
function. bbcmicrobit/micropython#803 (stubs too, what about the sim?) Stub WIP [DO NOT MERGE] Update for forthcoming beta MicroPython micropython-microbit-stubs#97 (comment)SoundEvent.CLAP
. bbcmicrobit/micropython#793 (stubs, how do you trigger in the sim? current UX is loud/quiet oriented)