Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Access User Input Media Stream #1099

Closed paulyorde closed 1 year ago

paulyorde commented 2 years ago

UserMedia.open( stream => _stream = stream )

Currently UserMedia marks the stream as private _stream. Ideally, I would like to capture the stream, create a mediaStreamSource and connect it to an Analyzer. This is to visualize and or assess the input coming in.

Maybe you have something that does this is already?

I have accessed it by typescript using stream['_stream'];

https://github.com/Tonejs/Tone.js/blob/dev/Tone/source/UserMedia.ts

tambien commented 2 years ago

Wrapping the media stream into a mediaStreamSource is exactly what the class currently does. Could you connect the UserMedia directly to an Analyser? something like this:

const um = new UserMedia();
const analyser = new Analyser();
um.connect(analyser);
await um.open()