mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
moving shim to another file
This commit is contained in:
parent
305fdc02da
commit
7f148b5c34
2 changed files with 28 additions and 23 deletions
|
@ -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";
|
"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
|
* @class Buffer loading and storage. Tone.Buffer is used internally by all
|
||||||
* classes that make requests for audio files such as Tone.Player,
|
* classes that make requests for audio files such as Tone.Player,
|
||||||
|
@ -371,7 +350,7 @@ define(["Tone/core/Tone", "Tone/core/Emitter", "Tone/type/Type"], function(Tone)
|
||||||
|
|
||||||
//statically inherits Emitter methods
|
//statically inherits Emitter methods
|
||||||
Tone.Emitter.mixin(Tone.Buffer);
|
Tone.Emitter.mixin(Tone.Buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the static queue for all of the xhr requests
|
* the static queue for all of the xhr requests
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
|
|
26
Tone/shim/AudioBuffer.js
Normal file
26
Tone/shim/AudioBuffer.js
Normal 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];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in a new issue