Importing compiled ts file to AudioWorkletProcessor

98 views Asked by At

So i'm trying to use this library to apply an echo cancellation in browser in separate AudioWorkletProcessor. dtln_processor.js is as follows:

import './dtln/dtln_aec.js';

class DtlnProcessor extends AudioWorkletProcessor {
    ...
}

registerProcessor('dtln', DtlnProcessor);

./dtln/dtln_aec.js is compiled file from TypeScript (if i'm not mistaken, first time using TS).

While importing this file i get the next error in Google Chrome:

caught Error: Could not find a global object
    at getGlobalNamespace (dtln_aec.js:668:23)
    at getGlobalMap (dtln_aec.js:676:20)
    at getGlobal (dtln_aec.js:690:27)
    at dtln_aec.js:783:28
    at dtln_aec.js:12:80
    at dtln_aec.js:13:3

What's the problem with that importing? If i get it correctly it needs a global object like window but how to get it inside the AudioWorkletProcessor file? Also, i tried creating the needed object from the library in the main js file (which is working) but couldn't pass it to the worklet port because this object can not be serialized (it contains a function).

0

There are 0 answers