|
1 |
| -# Csound for Emscripten and WebAssembly |
| 1 | +# Csound for WebAssembly |
2 | 2 |
|
3 |
| -Authors: Edward Costello, Steven Yi, Henri Manson |
| 3 | +Authors: Edward Costello, Steven Yi, Henri Manson, Michael Gogins |
4 | 4 |
|
5 | 5 | ## Introduction
|
6 | 6 |
|
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. |
12 | 19 |
|
13 | 20 | ## Requirements
|
14 | 21 |
|
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/). |
22 | 23 | Building the toolchain is compute and memory intensive. If the build does not
|
23 | 24 | complete or produces a zero size clang file, run the build step using only
|
24 | 25 | one thread: `./emsdk install sdk-incoming-64bit binaryen-master-64bit -j1`.
|
25 | 26 |
|
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 |
| - |
49 | 27 | ## Build Instructions for WebAssembly
|
50 | 28 |
|
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 |
52 | 34 | `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 |
57 | 36 | `libsndfile-wasm.a` in `deps/libsndfile-1.0.25`.
|
58 | 37 | 2. Run the `build-wasm.sh` script using `sh build-wasm.sh`. This will create a
|
59 | 38 | build folder, run cmake from there with the Csound source,
|
60 | 39 | then compile Csound with Emscripten for WASM. The script will copy
|
61 | 40 | 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. |
64 | 41 |
|
65 | 42 | ### Release Instructions
|
66 | 43 |
|
|
0 commit comments