Skip to content

Commit 9205fbd

Browse files
authored
Replacement of es5 functions to es6 classes feat p5.polySynth (#523)
1 parent b96e4a2 commit 9205fbd

File tree

3 files changed

+392
-386
lines changed

3 files changed

+392
-386
lines changed

src/app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ p5.prototype.getAudioContext = getAudioContext;
66
p5.prototype.userStartAudio = userStartAudio;
77

88
import './master';
9-
import './helpers';
9+
10+
import { freqToMidi } from './helpers';
11+
p5.prototype.freqToMidi = freqToMidi;
12+
1013
import './errorHandler';
1114
import './audioWorklet';
1215
import './panner';
@@ -66,4 +69,5 @@ p5.AudioVoice = AudioVoice;
6669
import MonoSynth from './monosynth';
6770
p5.MonoSynth = MonoSynth;
6871

69-
import './polysynth';
72+
import PolySynth from './polysynth';
73+
p5.PolySynth = PolySynth;

src/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ p5.prototype.sampleRate = function () {
2727
* above Middle C is 440Hz
2828
* @return {Number} MIDI note value
2929
*/
30-
p5.prototype.freqToMidi = function (f) {
30+
export const freqToMidi = function (f) {
3131
var mathlog2 = Math.log(f / 440) / Math.log(2);
3232
var m = Math.round(12 * mathlog2) + 69;
3333
return m;

0 commit comments

Comments
 (0)