Skip to content

Accessing input signal in AudioContext of Audio Device Client #6

Open
@chrisguttandin

Description

@chrisguttandin

I wonder how one would access the signal of the input device inside an associated AudioContext.

It would be possible with the current API but I think it's not very elegant. The following would, for example, apply a simple gain to the input:

// inputDeviceId is a variable with holds the device id of the desired input device.
const client = await navigator.mediaDevices.getAudioDeviceClient({ inputDeviceId });
const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: inputDeviceId } } });
const context = client.getContext();
const mediaStreamSourceNode = new MediaStreamSourceNode(context, { mediaStream });
const gainNode = new GainNode(context, { gain: 0.5 });

mediaStreamSourceNode
    .connect(gainNode)
    .connect(context.destination);

Metadata

Metadata

Assignees

No one assigned

    Labels

    AudioDeviceClientProject label for AudioDeviceClient

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions