Tone.js/Tone/shim/OfflineAudioContext.js
tambien ed71d8141b amd to es6 import/export
no longer using AMD (require.js) style imports, and beginning to move to es6 "import/export" statements everywhere.
2019-01-27 13:05:20 -05:00

23 lines
741 B
JavaScript

import Tone from "../core/Tone";
if (Tone.supported){
if (!Tone.global.hasOwnProperty("OfflineAudioContext") && Tone.global.hasOwnProperty("webkitOfflineAudioContext")){
Tone.global.OfflineAudioContext = Tone.global.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));
};
}
}