-
Notifications
You must be signed in to change notification settings - Fork 594
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
Implement Microphone and Touch sensor of v2 in MakeCode #3423
Comments
@finneyj has been working on a sound pipeline that means a lot of the code in the extension around SondExpressions moves into the DAL and there's a 'virtual pin' for the 'legacy' audio playback (IE everything that uses setAnalogValue()) that's also mixed into the audio pipeline. I think for simplicity it makes most sense to keep things in the extension until that code hits, or we'll end up implementing things like how we disable the speaker and how we set volume on the pin and on the other audio system separately, and then have to do it again. |
So you don't want to "On-board speaker enable" block to be ported yet? |
Yea, the way we do it in the extension is not really the way to do it once the audio pipeline code goes in. @finneyj has done that now and so I think with the next CODAL release we're good to go |
Bringing this over from https://github.com/microbit-foundation/microbit-issues/issues/12 originally by @whaleygeek Proposal for microphone integration in editors Background/Current ExperienceA second order issue when porting code that works on an external mic board, to the inbuilt mic, is occurring. An external mic comes in on analog and gives a raw instantaneous unfiltered value in the range 0..1023 the new onboard mic is SPL filtered (bit laggy for high speed operations and filters out spikes that I want to capture) and returns a number in the range 0..255. For the non SPL use case, I have an experiment that measures the speed of sound that works perfectly with an external mic, but cannot get it to work reliably with the onboard mic. It samples the raw analog in a while true (fiber scheduler temporarily disabled) looking for a sharp peak in the instantaneous of above value 1000 - we get great timing accuracy with this and it works reliably. Can't get any sense out of the onboard mic, too much other stuff in the way. Speaker integration is beautiful, it feels like we are not there yet with Mic, it's not as beautiful. Proposed FeatureCreate a virtual pin called MIC, that if you read from it, you get 0..1023 unfiltered (no SPL). An advanced block that allows you to switch the virtual MIC pin to either be onboard mic, or P0 P1 P2. virtual MIC pin moves to P1 on a V1 microbit, defaults to onboard MIC on V2. MindsetThink of it like this: for pins they can be digital (on or off) which is like sound loud or quiet. For pins they can be analog debounced for touch (like SPL filtered mic), or analog raw unbounced (this would be like mic with SPL filtering completely disabled). Rather than adding a feature to turn SPL on and off, just make the virtual MIC read give a raw analog reading in range 0..1023, then it is super easy to port existing external mic programs onto a V2 device. Sensible defaults and universal hex foo then sort out making a hex file that works nicely on any device. AlternativesEventually, an advanced javascript only block to change the tuning parameters for the SPL model, would be useful. |
Ok we will port rest of the blocks other than this one. (All the blocks in the snapshot above). |
@abchatra The SoundExpressions is also going in DAL right now, so not those either. @microbit-matt-hillsdon are there other blocks you'd hold back on porting now given what's coming in DAL (@abchatra likely tomorrow, so really soon now) |
Sounds are in. We need .wav files. |
Microphone + Touch implemented. |
Built this extension natively:
https://github.com/microbit-foundation/pxt-microbit-v2-extension
The text was updated successfully, but these errors were encountered: