moving shim to it's own file

This commit is contained in:
Yotam Mann 2017-10-25 23:01:42 -04:00
parent 7f148b5c34
commit eb162526bb
2 changed files with 20 additions and 17 deletions

View file

@ -1,23 +1,7 @@
define(["Tone/core/Tone", "Tone/core/AudioNode"], function (Tone) {
define(["Tone/core/Tone", "Tone/core/AudioNode", "Tone/shim/AnalyserNode"], function (Tone) {
"use strict";
/**
* AnalyserNode.getFloatTimeDomainData polyfill
* @private
*/
if (window.AnalyserNode && !AnalyserNode.prototype.getFloatTimeDomainData){
//referenced https://github.com/mohayonao/get-float-time-domain-data
AnalyserNode.prototype.getFloatTimeDomainData = function(array){
var uint8 = new Uint8Array(array.length);
this.getByteTimeDomainData(uint8);
for (var i = 0; i < uint8.length; i++){
array[i] = (uint8[i] - 128) / 128;
}
};
}
/**
* @class Wrapper around the native Web Audio's
* [AnalyserNode](http://webaudio.github.io/web-audio-api/#idl-def-AnalyserNode).

19
Tone/shim/AnalyserNode.js Normal file
View file

@ -0,0 +1,19 @@
define(["Tone/core/Tone", "Tone/shim/AudioContext"], function(Tone){
/**
* AnalyserNode.getFloatTimeDomainData polyfill
* @private
*/
if (Tone.supported){
if (!AnalyserNode.prototype.getFloatTimeDomainData){
//referenced https://github.com/mohayonao/get-float-time-domain-data
AnalyserNode.prototype.getFloatTimeDomainData = function(array){
var uint8 = new Uint8Array(array.length);
this.getByteTimeDomainData(uint8);
for (var i = 0; i < uint8.length; i++){
array[i] = (uint8[i] - 128) / 128;
}
};
}
}
});