Skip to content

Commit

Permalink
Fix esm
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Jul 12, 2022
1 parent a05fb2e commit e40d808
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
14 changes: 5 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ set(source_files
${PROJECT_SOURCE_DIR}/src/tempo.cc
${PROJECT_SOURCE_DIR}/src/pitch.cc)

add_definitions(-DHAVE_CONFIG_H)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-s MODULARIZE=1 \
-s EXPORT_ES6=1 \
-s SINGLE_FILE=1 \
-s EXPORT_NAME=aubio \
-Oz --closure 1 --bind")

include_directories(src)
include_directories(aubio/src)
add_definitions(-DHAVE_CONFIG_H)

add_executable(aubio ${source_files})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sMODULARIZE=1 -sEXPORT_NAME=aubio -Oz --bind")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
add_subdirectory(cmake/aubio)
add_subdirectory(cmake/aubio.esm)
2 changes: 2 additions & 0 deletions cmake/aubio.esm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sEXPORT_ES6=1")
add_executable(aubio.esm ${source_files})
1 change: 1 addition & 0 deletions cmake/aubio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_executable(aubio ${source_files})
4 changes: 2 additions & 2 deletions examples/pitch.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
crossorigin="anonymous"
controls
></audio>
<script src="../build/aubio.js"></script>
<script>
<script type="module">
import aubio from "../build/aubio.esm.js";
let audioSource, audioContext, scriptProcessor;
let count = 0;
const audio = document.querySelector("audio");
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"types": "index.d.ts",
"files": [
"index.d.ts",
"build/aubio.js"
"build/aubio.js",
"build/aubio.wasm",
"build/aubio.esm.js",
"build/aubio.esm.wasm"
],
"scripts": {
"build": "export EM_NODE_JS=node && emcmake cmake -Bbuild -H. && make -Cbuild -j",
Expand Down
2 changes: 1 addition & 1 deletion spec/aubio.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it("pitch detection", async () => {
it("tempo detection", async () => {
const { Tempo } = await aubio();
const [sampleRate, data] = await getAudioData(
"https://file-examples-com.github.io/uploads/2017/11/file_example_WAV_1MG.wav"
"https://file-examples.com/storage/fe64bbb60e62cc956a036bf/2017/11/file_example_WAV_1MG.wav"
);
const bufferSize = 1024;
const tempo = new Tempo(bufferSize, bufferSize / 8, sampleRate);
Expand Down

0 comments on commit e40d808

Please sign in to comment.