{"id":50888915,"url":"https://github.com/bsiever/pxt-micredirect","last_synced_at":"2026-06-15T20:00:28.095Z","repository":{"id":362372622,"uuid":"1258731342","full_name":"bsiever/pxt-micredirect","owner":"bsiever","description":"MakeCode Microphone Redirection","archived":false,"fork":false,"pushed_at":"2026-06-15T18:17:07.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-15T19:26:23.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsiever.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-03T21:36:18.000Z","updated_at":"2026-06-15T18:18:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bsiever/pxt-micredirect","commit_stats":null,"previous_names":["bsiever/pxt-micredirect"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bsiever/pxt-micredirect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fpxt-micredirect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fpxt-micredirect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fpxt-micredirect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fpxt-micredirect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsiever","download_url":"https://codeload.github.com/bsiever/pxt-micredirect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsiever%2Fpxt-micredirect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34377983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-15T20:00:15.651Z","updated_at":"2026-06-15T20:00:28.084Z","avatar_url":"https://github.com/bsiever.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microbit-mic\n\nA MakeCode extension for micro:bit v2 that redirects the audio pipeline to an\nexternal analog microphone on an edge connector pin. Other extensions that use\n`soundLevel()`, `onSound()`, or audio recording work transparently with the new\nmic — no changes required.\n\n## Hardware\n\nWire a standard analog electret mic module (e.g. MAX4466, MAX9814) to the micro:bit:\n\n| Mic module | micro:bit |\n|------------|-----------|\n| VCC        | 3V        |\n| GND        | GND       |\n| OUT        | P1 (or any ADC-capable pin) |\n\n**ADC-capable pins**: P0, P1, P2 (confirmed). P3, P4, P10 also work but may\nconflict with other hardware. Do not use button pins (P5, P11).\n\n## Usage\n\nPlace the setup block at the very start of your program, before any sound blocks:\n\n```blocks\nanalogMic.useAnalogMicOnPin(AnalogPin.P1)\n```\n\nAfter that, all standard sound blocks read from the analog mic:\n\n```blocks\nbasic.forever(function () {\n    basic.showNumber(input.soundLevel())\n})\n```\n\n```blocks\ninput.onSound(DetectedSound.Loud, function () {\n    basic.showIcon(IconNames.Heart)\n})\n```\n\n### Gain setting\n\nThe `gain` parameter (0–7) controls ADC hardware amplification. Default is 7,\nwhich matches the built-in mic. **If you have a module with onboard amplification\n(e.g. MAX4466 with gain pot), start with `gain=0`** to avoid clipping, then\nincrease if `soundLevel()` stays near zero.\n\n```blocks\nanalogMic.useAnalogMicOnPin(AnalogPin.P1, 0, 80)\n```\n\n### Normalisation factor\n\nThe `normFactor` parameter (0–1000) controls the `StreamNormalizer` gain in the\naudio pipeline. The value is divided by 1000 internally (`80` → `0.08`). Default\n`80` matches the built-in mic behaviour. Increase to boost quiet signals; decrease\nto reduce clipping on loud signals.\n\n### Deep sleep / power saving\n\nThe analog mic runs continuously by default. To stop ADC sampling during sleep:\n\n```blocks\nanalogMic.setAnalogMicEnabled(false)\n// ... sleep or low-power operations ...\nanalogMic.setAnalogMicEnabled(true)\n```\n\n## Limitations\n\n- **micro:bit v2 only** — requires the nRF52833 ADC and CODAL runtime.\n- **Call before audio blocks** — the swap must happen before any `soundLevel()`,\n  `onSound()`, or audio-recording blocks run. Behaviour is undefined if called after.\n- **One-way swap** — calling `useAnalogMicOnPin` more than once has no effect.\n  The swap cannot be reversed at runtime.\n- **Deep sleep** — the analog mic continues sampling during deep sleep unless\n  `setAnalogMicEnabled(false)` is called first.\n\n## How it works\n\nThe CODAL `MicroBitAudio` class exposes its pipeline components as public\npointers (`levelSPL`, `processor`, `splitter`, `rawSplitter`, `mic`). This\nextension builds a parallel pipeline for the specified analog pin and hot-swaps\nthose pointers at runtime. The built-in PDM mic is disabled via `deactivateMic()`.\nBecause `DEVICE_ID_SYSTEM_LEVEL_DETECTOR` is preserved, all pxt-microbit sound\nevent registrations fire from the new mic without modification.\n\nSee [design.md](design.md) for full architecture details and engineering review notes.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsiever%2Fpxt-micredirect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsiever%2Fpxt-micredirect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsiever%2Fpxt-micredirect/lists"}