mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
moving shim to it's own file
This commit is contained in:
parent
7f148b5c34
commit
eb162526bb
2 changed files with 20 additions and 17 deletions
|
@ -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
19
Tone/shim/AnalyserNode.js
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue