2017-10-26 03:01:26 +00:00
|
|
|
define(["Tone/core/Tone"], function(Tone){
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AudioBuffer.copyTo/FromChannel polyfill
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
if (Tone.supported){
|
2018-01-02 15:37:27 +00:00
|
|
|
if (!AudioBuffer.prototype.copyToChannel){
|
2017-10-26 03:01:26 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|