Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacement of es5 functions to es6 class def feat P5.AudioIn and audiocontext #508

Merged
merged 6 commits into from
Aug 9, 2020
11 changes: 9 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'audioworklet-polyfill';
import './shims';
import './audiocontext';

import { getAudioContext, userStartAudio } from './audiocontext';
p5.prototype.getAudioContext = getAudioContext;
p5.prototype.userStartAudio = userStartAudio;

import './master';
import './helpers';
import './errorHandler';
Expand All @@ -19,7 +23,10 @@ import './oscillator';
import './envelope';
import './pulse';
import './noise';
import './audioin';

import AudioIn from './audioin';
p5.AudioIn = AudioIn;

import './filter';
import './eq';
import './panner3d';
Expand Down
8 changes: 4 additions & 4 deletions src/audiocontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Tone.setContext(audiocontext);
*
* </div></code>
*/
p5.prototype.getAudioContext = function () {
export function getAudioContext() {
return audiocontext;
};
}

/**
* <p>It is not only a good practice to give users control over starting
Expand Down Expand Up @@ -102,7 +102,7 @@ p5.prototype.getAudioContext = function () {
* }
* </code></div>
*/
p5.prototype.userStartAudio = function (elements, callback) {
export function userStartAudio(elements, callback) {
var elt = elements;
if (elements instanceof p5.Element) {
elt = elements.elt;
Expand All @@ -112,6 +112,6 @@ p5.prototype.userStartAudio = function (elements, callback) {
});
}
return StartAudioContext(audiocontext, elt, callback);
};
}

export default audiocontext;
Loading