Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit 5c66046

Browse files
committed
Updating WebAssembly build and instructions (#11).
1 parent 0d0d050 commit 5c66046

File tree

11 files changed

+27
-111
lines changed

11 files changed

+27
-111
lines changed

WebAssembly/README.md

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,43 @@
1-
# Csound for Emscripten and WebAssembly
1+
# Csound for WebAssembly
22

3-
Authors: Edward Costello, Steven Yi, Henri Manson
3+
Authors: Edward Costello, Steven Yi, Henri Manson, Michael Gogins
44

55
## Introduction
66

7-
These are the sources for Web-based Csound. They were first developed to use
8-
the emscripten compiler toolchain to produce a pure JavaScript version of
9-
Csound through asm.js. With the introduction of WebAssembly (WASM), we are now
10-
able to produce a version of this build targetting that API. WASM code runs
11-
roughly twice as fast as pure JavaScript or half as fast as native code.
7+
THis directory builds, packages, and tests Csound for WebAssembly. This build
8+
is based upon the core Csound build for WebAssembly by Edward Costello, Steven
9+
Yi, Victor Lazzarini, and Henri Manson. To this have been added:
10+
11+
* A number of C++ opcodes (here, statically linked).
12+
13+
* A new JavaScript interface to Csound that follows, as exactly as possible,
14+
the interface defined by CsoundThreaded in `csound_threaded.cpp` and also
15+
implemented in CsoundOboe in `csound_oboe.hpp` for the Csound for Android
16+
app, and in csound.node.
17+
18+
* A complete build of CsoundAC for WebAssembly will also be added.
1219

1320
## Requirements
1421

15-
* [Emscripten SDK/toolchain](https://github.com/kripken/emscripten): install
16-
the Emscripten tools using these \
17-
[instructions](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html)
18-
thoroughly. Make sure all steps are followed to ensure a correct
19-
installation of the toolchain.
20-
* If you are primarily using WebAssembly you can install the toolchain
21-
from source [using these instructions](http://webassembly.org/getting-started/developers-guide/).
22+
* Install the toolchain from source [using these instructions](http://webassembly.org/getting-started/developers-guide/).
2223
Building the toolchain is compute and memory intensive. If the build does not
2324
complete or produces a zero size clang file, run the build step using only
2425
one thread: `./emsdk install sdk-incoming-64bit binaryen-master-64bit -j1`.
2526

26-
## Build Instructions for asm.js
27-
28-
1. First you will need to build libsndfile. Use the
29-
`download_and_build_libsndfile.sh` script. In the emscripten folder, run
30-
`sh ./download_and_build_libsndfile.sh`. This will create a deps folder,
31-
download libsndfile 1.0.25, unarchive the tarball, and then compile libsndfile
32-
with Emscripten.
33-
2. Run the build.sh script using `sh ./build.sh`. This will create a build
34-
folder; run cmake from there with the Csound source, then compile Csound
35-
with Emscripten. The script will then link the output with libsndfile and
36-
generate a libcsound.js script file. Finally, the script will copy the
37-
libcsound.js and src/CsoundObj.js files into a dist folder.
38-
39-
At this point, the two .js files in the dist folder are all that are necessary to run Csound in a
40-
Web browser that supports WebAudio.
41-
42-
### Release Instructions
43-
44-
1. Run `sh build.sh`
45-
2. Run `sh update_example_libs_from_dist.sh`
46-
3. Update CS_VERSION in build.sh if necessary
47-
4. Run `sh release.sh`
48-
4927
## Build Instructions for WebAssembly
5028

51-
1. In the `emsdk` directory run `source emsdk_env.sh` and
29+
In the `WebAssembly` directory, run `sh build-all.sh`. This will perform the
30+
following steps, which may also be executed individually:
31+
32+
1. Update the Emscripten toolchain for WebAssembly.
33+
2. Run `source emsdk_env.sh` in the `~/emsdk` directory which executes
5234
`export EMSCRIPTEN_ROOT=$EMSCRIPTEN`.
53-
2. Change to the `csound/emscripten` directory.
54-
3. First you will need to build libsndfile. Use the
55-
`download_and_build_libsndfile_wasm.sh` script. In the emscripten
56-
folder, type `sh download_and_build_libsndfile_wasm.sh`. This will compile
35+
3. Run `sh download_and_build_libsndfile_wasm.sh`. This will compile
5736
`libsndfile-wasm.a` in `deps/libsndfile-1.0.25`.
5837
2. Run the `build-wasm.sh` script using `sh build-wasm.sh`. This will create a
5938
build folder, run cmake from there with the Csound source,
6039
then compile Csound with Emscripten for WASM. The script will copy
6140
the required files into a dist-wasm folder for distribution.
62-
3. The WASM build works generally as a drop-in replacement for the
63-
asm.js version, but uses different files.
6441

6542
### Release Instructions
6643

File renamed without changes.

WebAssembly/build-wasm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "Using EMSCRIPTEN_ROOT: $EMSCRIPTEN_ROOT"
1212
mkdir -p build-wasm
1313
cd build-wasm
1414

15-
cmake -DUSE_COMPILER_OPTIMIZATIONS=0 -DWASM=1 -DINIT_STATIC_MODULES=0 -DUSE_DOUBLE=NO -DBUILD_MULTI_CORE=0 -DBUILD_JACK_OPCODES=0 -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN_ROOT/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_MODULE_PATH=$EMSCRIPTEN_ROOT/cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DHAVE_BIG_ENDIAN=0 -DCMAKE_16BIT_TYPE="unsigned short" -DHAVE_STRTOD_L=0 -DBUILD_STATIC_LIBRARY=YES -DHAVE_ATOMIC_BUILTIN=0 -DHAVE_SPRINTF_L=NO -DUSE_GETTEXT=NO -DLIBSNDFILE_LIBRARY=../deps/libsndfile-1.0.25/libsndfile-wasm.a -DSNDFILE_H_PATH=../deps/libsndfile-1.0.25/src ../..
15+
cmake -DUSE_COMPILER_OPTIMIZATIONS=0 -DWASM=1 -DINIT_STATIC_MODULES=0 -DUSE_DOUBLE=NO -DBUILD_MULTI_CORE=0 -DBUILD_JACK_OPCODES=0 -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN_ROOT/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_MODULE_PATH=$EMSCRIPTEN_ROOT/cmake -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DHAVE_BIG_ENDIAN=0 -DCMAKE_16BIT_TYPE="unsigned short" -DHAVE_STRTOD_L=0 -DBUILD_STATIC_LIBRARY=YES -DHAVE_ATOMIC_BUILTIN=0 -DHAVE_SPRINTF_L=NO -DUSE_GETTEXT=NO -DLIBSNDFILE_LIBRARY=../deps/libsndfile-1.0.25/libsndfile-wasm.a -DSNDFILE_H_PATH=../deps/libsndfile-1.0.25/src ../dependencies/csound
1616

1717
emmake make csound-static -j6
1818

WebAssembly/build.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

WebAssembly/download_and_build_libsndfile.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

WebAssembly/release.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

WebAssembly/update_example_libs_from_dist.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

dependencies/eigen

Submodule eigen updated from d58f734 to 1ae2849

dependencies/update-dependency-packages.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
echo "Updating all Debian packages required for csound-extended..."
33
echo
4+
sudo apt-get update
5+
sudo apt-get upgrade
46
echo "Updating build-essential..."
57
sudo apt-get install build-essential
68
echo "Updating automake..."

0 commit comments

Comments
 (0)