mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-04 07:58:43 +00:00
ed71d8141b
no longer using AMD (require.js) style imports, and beginning to move to es6 "import/export" statements everywhere.
23 lines
741 B
JavaScript
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));
|
|
};
|
|
}
|
|
}
|
|
|