Tone.js/Tone/source/Microphone.js

33 lines
854 B
JavaScript
Raw Normal View History

define(["Tone/core/Tone", "Tone/source/ExternalInput"], function(Tone){
2014-04-06 00:47:59 +00:00
"use strict";
2014-06-19 05:40:16 +00:00
/**
* @class A simpler verision of Tone.ExternalInput that
* takes no arguments, connects only to the
* default source (typically the microphone),
* and does not require an onload function.
2014-06-19 05:40:16 +00:00
*
* @constructor
* @extends {Tone.ExternalInput}
* @example
* //mic will feedback if played through master
* var mic = new Tone.Microphone();
* mic.start();
2014-06-19 05:40:16 +00:00
*/
Tone.Microphone = function(){
Tone.ExternalInput.call(this);
2014-06-19 05:40:16 +00:00
};
Tone.extend(Tone.Microphone, Tone.ExternalInput);
2014-06-19 05:40:16 +00:00
/**
* start the stream
* @private
2014-06-19 05:40:16 +00:00
*/
2015-02-23 05:29:49 +00:00
Tone.Microphone.prototype._start = function(){
navigator.getUserMedia(this._constraints,
this._onStream.bind(this), this._onStreamError.bind(this));
2014-06-19 05:40:16 +00:00
};
2014-04-06 00:47:59 +00:00
return Tone.Microphone;
});