// Prompt the user to use their microphone.
stream = await navigator.mediaDevices.getUserMedia({
audio: true,
});
const context = new AudioContext();
const source = context.createMediaStreamSource(stream);
// [ mic ] -- [ earbud ]
source.connect(context.destination);
NOTE:
1) if I comment this out, should the headset hear me rubbing the microphone?
2) if I open the webpage multiple times, should I get exclusive use of the microphone and earphone?
3) This page is useful to explore what happens if you open the page multiple times, and
4) mixing signals discusses mixing signals explores combining signals.
5) https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaStreamDestination - may be helpful
See MDN Web_Audio_API
Adapted from:-
https://mdn.github.io/webaudio-examples/audioworklet/
If you try audioworklet examples direct from the desktop it reports CORS error.
To get around CORS, use a local web server.
python -m http.server 8080
http://localhost:8080/m2eCopy.htm