moving shim to another file

This commit is contained in:
Yotam Mann 2017-10-25 23:01:26 -04:00
parent 305fdc02da
commit 7f148b5c34
2 changed files with 28 additions and 23 deletions

View file

@ -1,28 +1,7 @@
define(["Tone/core/Tone", "Tone/core/Emitter", "Tone/type/Type"], function(Tone){
define(["Tone/core/Tone", "Tone/core/Emitter", "Tone/type/Type", "Tone/shim/AudioBuffer"], function(Tone){
"use strict";
/**
* AudioBuffer.copyToChannel polyfill
* @private
*/
if (window.AudioBuffer && !AudioBuffer.prototype.copyToChannel){
AudioBuffer.prototype.copyToChannel = function(src, chanNum, start){
var channel = this.getChannelData(chanNum);
start = start || 0;
for (var i = 0; i < channel.length; i++){
channel[i+start] = src[i];
}
};
AudioBuffer.prototype.copyFromChannel = function(dest, chanNum, start){
var channel = this.getChannelData(chanNum);
start = start || 0;
for (var i = 0; i < dest.length; i++){
dest[i] = channel[i+start];
}
};
}
/**
* @class Buffer loading and storage. Tone.Buffer is used internally by all
* classes that make requests for audio files such as Tone.Player,

26
Tone/shim/AudioBuffer.js Normal file
View file

@ -0,0 +1,26 @@
define(["Tone/core/Tone"], function(Tone){
/**
* AudioBuffer.copyTo/FromChannel polyfill
* @private
*/
if (Tone.supported){
if(!AudioBuffer.prototype.copyToChannel){
AudioBuffer.prototype.copyToChannel = function(src, chanNum, start){
var channel = this.getChannelData(chanNum);
start = start || 0;
for (var i = 0; i < channel.length; i++){
channel[i+start] = src[i];
}
};
AudioBuffer.prototype.copyFromChannel = function(dest, chanNum, start){
var channel = this.getChannelData(chanNum);
start = start || 0;
for (var i = 0; i < dest.length; i++){
dest[i] = channel[i+start];
}
};
}
}
});