File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const moduleSources = [
5
5
require ( 'raw-loader!./amplitudeProcessor' ) . default ,
6
6
] ;
7
7
const ac = p5sound . audiocontext ;
8
+ let initializedAudioWorklets = false ;
8
9
9
10
function loadAudioWorkletModules ( ) {
10
11
return Promise . all (
@@ -17,6 +18,7 @@ function loadAudioWorkletModules() {
17
18
}
18
19
19
20
p5 . prototype . registerMethod ( 'init' , function ( ) {
21
+ if ( initializedAudioWorklets ) return ;
20
22
// ensure that a preload function exists so that p5 will wait for preloads to finish
21
23
if ( ! this . preload && ! window . preload ) {
22
24
this . preload = function ( ) { } ;
@@ -25,6 +27,7 @@ p5.prototype.registerMethod('init', function () {
25
27
// use p5's preload system to load necessary AudioWorklet modules before setup()
26
28
this . _incrementPreload ( ) ;
27
29
const onWorkletModulesLoad = function ( ) {
30
+ initializedAudioWorklets = true ;
28
31
this . _decrementPreload ( ) ;
29
32
} . bind ( this ) ;
30
33
loadAudioWorkletModules ( ) . then ( onWorkletModulesLoad ) ;
You can’t perform that action at this time.
0 commit comments