sfztools / sfizz-webaudio

sfizz as a WebAudio library
MIT License
17 stars 4 forks source link

this._module._malloc is not a function #10

Closed kmturley closed 1 year ago

kmturley commented 1 year ago

When loading the site: https://sfz.tools/sfizz-webaudio/

I get a JavaScript console error:

Uncaught TypeError: this._module._malloc is not a function
    at WASMAudioBuffer._allocateHeap (WASMAudioBuffer.js:65:34)
    at new WASMAudioBuffer (WASMAudioBuffer.js:52:10)
    at new SfizzProcessor (sfizz-processor.js:33:24)

According to this GitHub issue: https://github.com/emscripten-core/emscripten/issues/6882#issuecomment-406745898

The solution is to add the flag:

-s EXPORTED_FUNCTIONS="['_malloc']"

I'm not an expert at CMAKE but believe that could be added to this line: https://github.com/sfztools/sfizz-webaudio/blob/main/CMakeLists.txt#L15

kmturley commented 1 year ago

In addition I think another flag could help:

-s EXPORT_ES6=1

Automatically puts the wrapper around javascript. Meaning that you can remove:

echo "export default Module;" >> sfizz.wasm.js

From the installation steps