Skip to content

Commit

Permalink
Export malloc function and es6 wrapper flags (#11)
Browse files Browse the repository at this point in the history
* Export malloc function and es6 wrapper flags
* Remove redundant commands
  • Loading branch information
kmturley authored Aug 8, 2023
1 parent 02ce7e9 commit e29620b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
working-directory: ${{runner.workspace}}/sfizz-webaudio/build
run: |
cmake --build . --config "$BUILD_TYPE" -j 2
echo "export default Module;" >> sfizz.wasm.js
- name: Inspect directory
working-directory: ${{runner.workspace}}/sfizz-webaudio
run: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_executable(sfizz-webaudio)
target_sources(sfizz-webaudio PRIVATE sfizz_webaudio.cpp)
target_link_libraries(sfizz-webaudio PRIVATE sfizz::sfizz)
set_target_properties(sfizz-webaudio PROPERTIES
LINK_FLAGS "--bind -s ENVIRONMENT=web -s ALLOW_MEMORY_GROWTH=1 -s SINGLE_FILE=1 -s WASM=1 -s WASM_ASYNC_COMPILATION=0"
LINK_FLAGS "--bind -s ENVIRONMENT=web -s ALLOW_MEMORY_GROWTH=1 -s SINGLE_FILE=1 -s WASM=1 -s WASM_ASYNC_COMPILATION=0 -s EXPORTED_FUNCTIONS=\"['_malloc']\" -s EXPORT_ES6=1"
OUTPUT_NAME sfizz.wasm
)

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
make -j
echo "export default Module;" >> sfizz.wasm.js
```

From the `build` directory, you may then host the result on `localhost:8000` using python as
Expand Down
8 changes: 5 additions & 3 deletions sfizz-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import Module from './build/sfizz.wasm.js';
import WASMAudioBuffer from './util/WASMAudioBuffer.js';

const SfizzModule = new Module();

// Web Audio API's render block size
const NUM_FRAMES = 128;

Expand All @@ -29,9 +31,9 @@ class SfizzProcessor extends AudioWorkletProcessor {
super();
// Create an instance of Synthesizer and WASM memory helper. Then set up an
// event handler for MIDI data from the main thread.
this._synth = new Module.SfizzWrapper(sampleRate);
this._leftBuffer = new WASMAudioBuffer(Module, NUM_FRAMES, 1, 1);
this._rightBuffer = new WASMAudioBuffer(Module, NUM_FRAMES, 1, 1);
this._synth = new SfizzModule.SfizzWrapper(sampleRate);
this._leftBuffer = new WASMAudioBuffer(SfizzModule, NUM_FRAMES, 1, 1);
this._rightBuffer = new WASMAudioBuffer(SfizzModule, NUM_FRAMES, 1, 1);
this._activeVoices = 0;
this.port.onmessage = this._handleMessage.bind(this);
}
Expand Down

0 comments on commit e29620b

Please sign in to comment.