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(){
	//promise resolves when input is available
});

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 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.

</>

.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.

</>

.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

.channelCountMode

String READONLY #

channelCountMode determines how channels will be counted when up-mixing and down-mixing connections to any inputs to the node. The default value is “max”. This attribute has no effect for nodes with no inputs.

</>
inherited from Tone.AudioNode

.channelInterpretation

String READONLY #

channelInterpretation determines how individual channels will be treated when up-mixing and down-mixing connections to any inputs to the node. The default value is “speakers”.

</>
inherited from Tone.AudioNode

.context

Tone.Context READONLY #

Get the audio context belonging to this instance.

</>
inherited from Tone.AudioNode

.channelCount

Number READONLY #

channelCount is the number of channels used when up-mixing and down-mixing connections to any inputs to the node. The default value is 2 except for specific nodes where its value is specially determined.

</>
inherited from Tone.AudioNode

.numberOfInputs

Number READONLY #

The number of inputs feeding into the AudioNode. For source nodes, this will be 0.

</>
inherited from Tone.AudioNode

.numberOfOutputs

Number READONLY #

The number of outputs coming out of the AudioNode.

</>

Methods

.close ( )

#
↪ returns Tone.UserMedia

this

Close the media stream

</>

.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.

</>

.dispose ( )

#
↪ returns Tone.UserMedia

this

Clean up.

</>
inherited from Tone.AudioNode

.chain ( )

#
nodes
↪ returns Tone.AudioNode

this

Connect the output of this node to the rest of the nodes in series.

EXAMPLE

//connect a node to an effect, panVol and then to the master output
 node.chain(effect, panVol, Tone.Master);
 
</>
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();
</>
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

.fan ( )

#
nodes
↪ returns Tone.AudioNode

this

connect the output of this node to the rest of the nodes in parallel.

</>

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