File tree Expand file tree Collapse file tree 3 files changed +32
-14
lines changed Expand file tree Collapse file tree 3 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ import * as Constants from './Constants';
3
3
import ISequencer from './ISequencer' ;
4
4
import ISynthesizer from './ISynthesizer' ;
5
5
import Synthesizer from './Synthesizer' ;
6
+ import waitForReady from './waitForReady' ;
6
7
import AudioWorkletNodeSynthesizer from './AudioWorkletNodeSynthesizer' ;
7
8
8
9
export {
9
10
Constants ,
10
11
ISequencer ,
11
12
ISynthesizer ,
12
13
Synthesizer ,
14
+ waitForReady ,
13
15
AudioWorkletNodeSynthesizer
14
16
} ;
Original file line number Diff line number Diff line change 1
1
2
2
import Synthesizer from './Synthesizer' ;
3
+ import waitForReady from './waitForReady' ;
3
4
4
5
import {
5
6
Constants ,
@@ -12,20 +13,7 @@ import {
12
13
ReturnMessageInstance
13
14
} from './MethodMessaging' ;
14
15
15
- const _module : any = AudioWorkletGlobalScope . wasmModule ;
16
- const promiseWasmInitialized = new Promise < void > ( ( resolve ) => {
17
- if ( _module . calledRun ) {
18
- resolve ( ) ;
19
- } else {
20
- const fn : ( ( ) => void ) | undefined = _module . onRuntimeInitialized ;
21
- _module . onRuntimeInitialized = ( ) => {
22
- resolve ( ) ;
23
- if ( fn ) {
24
- fn ( ) ;
25
- }
26
- } ;
27
- }
28
- } ) ;
16
+ const promiseWasmInitialized = waitForReady ( ) ;
29
17
30
18
/** Registers processor using Synthesizer for AudioWorklet. */
31
19
export default function registerAudioWorkletProcessor ( ) {
Original file line number Diff line number Diff line change
1
+
2
+ /** @internal */
3
+ declare global {
4
+ var Module : any ;
5
+ }
6
+
7
+ const _module : any = typeof AudioWorkletGlobalScope !== 'undefined' ?
8
+ AudioWorkletGlobalScope . wasmModule : Module ;
9
+ const promiseWasmInitialized = new Promise < void > ( ( resolve ) => {
10
+ if ( _module . calledRun ) {
11
+ resolve ( ) ;
12
+ } else {
13
+ const fn : ( ( ) => void ) | undefined = _module . onRuntimeInitialized ;
14
+ _module . onRuntimeInitialized = ( ) => {
15
+ resolve ( ) ;
16
+ if ( fn ) {
17
+ fn ( ) ;
18
+ }
19
+ } ;
20
+ }
21
+ } ) ;
22
+
23
+ /**
24
+ * Returns the Promise object which resolves when the synthesizer engine is ready.
25
+ */
26
+ export default function waitForReady ( ) : Promise < void > {
27
+ return promiseWasmInitialized ;
28
+ }
You can’t perform that action at this time.
0 commit comments