ctx.mic
Their microphone, live, while your app is open — a voice over a beat, a voice memo, a tuner. Fave1 asks them first and never keeps the sound.
Calls
const mic = await ctx.mic.open(); // speakers on: echo cancelling, noise and gain control const rec = new MediaRecorder(mic.stream); // or feed it to Web Audio rec.start(); // … rec.stop(); mic.stop(); // or ctx.mic.close() — every mic your app opened
MediaRecorder or createMediaStreamSourceMediaStream0 when it doesn’t saynumberctx.mic.active tells you if any is still onfunctionSound only. Need mic in your manifest — it is a separate permission from camera, with its own switch. Without it, or with the switch off in Fave1 settings, open() rejects with denied.
What the person sees
The first open() each time your app opens shows Fave1’s line in your panel: Let <your app> use your microphone? When they tap Allow, their browser asks for that site. While a mic is on, a red dot sits in your panel’s header. Close your app, close Fave1, or call stop(), and the mic goes off.
Call open() from a button they pressed — “Record” — not at launch, and turn it off as soon as the take is done. Nothing is played back through the speakers unless you do it yourself.
Recording over your own sound
To record a voice over music you play with Web Audio, send both to one MediaStreamDestination and record that. Keep the mic out of the speakers, or it feeds back.
const ac = new AudioContext(); const out = ac.createMediaStreamDestination(); // what gets recorded const music = ac.createGain(); // your beat goes in here music.connect(ac.destination); // …to the speakers const earphones = true; // ask them — off means the mic hears your speakers too const mic = await ctx.mic.open({ echo: !earphones, noise: !earphones, gain: !earphones }); const voice = ac.createMediaStreamSource(mic.stream); voice.connect(out); // voice → the recording only // The person hears the beat late (output delay) and the mic hears them late (input delay), // so the voice lands behind the beat. Delay the music by the same amount — in the recording only. const late = ac.createDelay(1); late.delayTime.value = (ac.outputLatency || 0) + (ac.baseLatency || 0) + mic.latency; music.connect(late).connect(out); const rec = new MediaRecorder(out.stream);
Wired earphones and built-in speakers are a few hundredths of a second. Bluetooth earphones can be a quarter of a second and browsers don’t always report it — give people a slider to nudge it.
When it doesn’t work
reason not-now · browser). closed if open() lands after your app closednoreason site). Offer the same thing in app mode, at <your-app>.fave1.appnoreason none) or the page isn’t https (insecure)noThe rule
ctx.files, a download), say so in your listing if it ever leaves, and never identify people by their voice. An app that calls navigator.mediaDevices.getUserMedia itself, listens without a tap, or keeps the mic on after the feature is done gets sent back in review.