Tone.ExternalInput
↳ EXTENDS Tone.SourceTone.ExternalInput is a WebRTC Audio Input. Check Media Stream API Support to see which browsers are supported. As of writing this, Chrome, Firefox, and Opera support Media Stream. Chrome allows enumeration of the sources, and access to device name over a secure (HTTPS) connection. See https://simpl.info vs http://simple.info on a Chrome browser for the difference.
CONSTRUCTOR
new Tone.ExternalInput ( [If multiple inputs are present, select the input number. Chrome only.
DEFAULTS
EXAMPLE
//select the third input
var motu = new Tone.ExternalInput(3);
//opening the input asks the user to activate their mic
motu.open(function(){
//opening is activates the microphone
//starting lets audio through
motu.start(10);
});Members
.state
↝ Tone.State READONLY #Returns the playback state of the source, either “started” or “stopped”.
.volume
↝ Decibels #The volume of the output in decibels.
EXAMPLE
source.volume.value = -6;Methods
.open ( )
#The callback function to execute when the stream is open
this
Open the media stream
.unsync ( )
#this
Unsync the source to the Transport. See Tone.Source.sync
.start ( )
#When the source should be started.
this
Start the source at the specified time. If no time is given, start the source now.
EXAMPLE
source.start("+0.5"); //starts the source 0.5 seconds from now.stop ( )
#When the source should be stopped.
this
Stop the source at the specified time. If no time is given, stop the source now.
EXAMPLE
source.stop(); // stops the source immediately.sync ( )
#Delay time before starting the source after the Transport has started.
this
Sync the source to the Transport so that when the transport is started, this source is started and when the transport is stopped or paused, so is the source.
EXAMPLE
//sync the source to start 1 measure after the transport starts
source.sync("1m");
//start the transport. the source will start 1 measure later.
Tone.Transport.start();Static Methods
.getSources ( )
#Callback to be executed after populating list
this
Populates the source list. Invokes the callback with an array of possible audio sources.
EXAMPLE
var soundflower = new Tone.ExternalInput();
Tone.ExternalInput.getSources(selectSoundflower);
function selectSoundflower(sources){
for(var i = 0; i < sources.length; i++){
if(sources[i].label === "soundflower"){
soundflower.inputNum = i;
soundflower.open(function(){
soundflower.start();
});
break;
}
}
};