Tone.UserMedia

↳ EXTENDS Tone.AudioNode

Tone.UserMedia uses MediaDevices.getUserMedia to open up and external microphone or audio input. Check MediaDevices API Support to see which browsers are supported. Access to an external input is limited to secure (HTTPS) connections.

CONSTRUCTOR

new Tone.UserMedia ( [
volume
] )
volume

The level of the input

optional

DEFAULTS

{
volume : 0 ,
mute : false
}

EXAMPLE

//list the inputs and open the third one
var motu = new Tone.UserMedia();

//opening the input asks the user to activate their mic
motu.open().then(function(){
	//opening is activates the microphone
	//starting lets audio through
	motu.start(10);
});

Members

.volume

Decibels #

The volume of the output in decibels.

EXAMPLE

input.volume.value = -6;
</>

.deviceId

String READONLY #

Returns an identifier for the represented device that is persisted across sessions. It is un-guessable by other applications and unique to the origin of the calling application. It is reset when the user clears cookies (for Private Browsing, a different identifier is used that is not persisted across sessions). Returns undefined when the device is not open.

</>

.groupId

String READONLY #

Returns a label describing this device (for example “Built-in Microphone”). Returns undefined when the device is not open or label is not available because of permissions.

</>

.groupId

String READONLY #

Returns a group identifier. Two devices have the same group identifier if they belong to the same physical device. Returns undefined when the device is not open.

</>

.mute

boolean #

Mute the output.

EXAMPLE

//mute the output
userMedia.mute = true;
</>

.state

Tone.State READONLY #

Returns the playback state of the source, “started” when the microphone is open and “stopped” when the mic is closed.

</>

.supported

Boolean READONLY #

If getUserMedia is supported by the browser.

</>
inherited from Tone.AudioNode

.context

Tone.Context READONLY #

Get the audio context belonging to this instance.

</>

Methods

.close ( )

#
↪ returns Tone.UserMedia

this

Close the media stream

</>

.dispose ( )

#
↪ returns Tone.UserMedia

this

Clean up.

</>

.open ( )

#
labelOrId

The label or id of the audio input media device. With no argument, the default stream is opened.

default: "default"
↪ returns Promise

The promise is resolved when the stream is open.

Open the media stream. If a string is passed in, it is assumed to be the label or id of the stream, if a number is passed in, it is the input number of the stream.

</>
inherited from Tone.AudioNode

.connect ( )

#
outputNum

optionally which output to connect from

type: number
default: 0
inputNum

optionally which input to connect to

type: number
default: 0
↪ returns Tone.AudioNode

this

connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode

</>
inherited from Tone.AudioNode

.disconnect ( )

#
output

Either the output index to disconnect if the output is an array, or the node to disconnect from.

↪ returns Tone.AudioNode

this

disconnect the output

</>
inherited from Tone.AudioNode

.toMaster ( )

#
↪ returns Tone.AudioNode

this

Connect ‘this’ to the master output. Shorthand for this.connect(Tone.Master)

EXAMPLE

//connect an oscillator to the master output
var osc = new Tone.Oscillator().toMaster();
</>

Static Methods

.enumerateDevices ( )

#
↪ returns Promise

The promise that is resolved with the devices

Returns a promise which resolves with the list of audio input devices available.

EXAMPLE

Tone.UserMedia.enumerateDevices().then(function(devices){
	console.log(devices)
})
</>
docs generated Sep 15 2019