Tone.js/Tone/shim/OfflineAudioContext.js
tambien 3d1202043a all modules are relative paths
simplifies deep references to individual files
2018-08-26 22:29:17 -04:00

23 lines
751 B
JavaScript

define(["../core/Tone"], function(Tone){
if (Tone.supported){
if (!window.hasOwnProperty("OfflineAudioContext") && window.hasOwnProperty("webkitOfflineAudioContext")){
window.OfflineAudioContext = window.webkitOfflineAudioContext;
}
//returns promise?
var context = new OfflineAudioContext(1, 1, 44100);
var ret = context.startRendering();
if (!(ret && Tone.isFunction(ret.then))){
OfflineAudioContext.prototype._native_startRendering = OfflineAudioContext.prototype.startRendering;
OfflineAudioContext.prototype.startRendering = function(){
return new Promise(function(done){
this.oncomplete = function(e){
done(e.renderedBuffer);
};
this._native_startRendering();
}.bind(this));
};
}
}
});