Closed albincorreya closed 4 years ago
This looks OK to me, I don't really know much about the emscripten stuff so I'm happy to follow your lead on this.
One important thing is that we shouldn't have any assets in git (.js file, .wasm files, etc). This is because each time you update them we'll end up with more items in the git history, causing it to grow larger and larger. We should use github's release file upload functionality, or else get it up on npm instead.
Thanks for the review @alastair.
While we will be uploading essentia-module.js
to npm, we still may need to provide the asynchronous wasm builds of essentia - essentia.js
(js glue code) and essentia.wasm
.
The main difference is that these async builds ables users to use it with standard HTML <script>
tag and also it doesn't support AudioWorklets and ES6 style import/export. In that case, we can also provide essentia.js
using CDN services like
https://www.jsdelivr.com/features beside the GitHub releases and npm. Or do you think we should have both of these versions in npm (ie, essentia.js
and essentia-module.js
) and provide both of these in the CDN service?
What are your thoughts about this?
This PR addresses the following changes,
Python scripts for generating cpp source code for embind to further generate JavaScript bindings. #9
Support ES6 style import/export #7
Support for AudioWorklet usage using
essentia-module.js
build. #8Added a few examples for using essentia.js as a realtime feature extractor along with WebAudioAPI. Either using the depreciated
ScriptNodeProcessor
or using the AudioWorklet design pattern. (AudioWorkletProcessor
andAudioWorkletNode
). #8Make recipes for various types of essentia.js builds.
Updated the docker image with python dependencies. Change base image to emscripten-slim.
Updated Travis CI build scripts and config.
Added initial version of the documentation (https://github.com/MTG/essentia.js/tree/module/docs).
Updated readme with the latest changes.
Added npm packaging configuration and
main.js
entrypoint.You can find pre-compiled builds here.
essentia.wasm
- Asynchronous WASM build of generic javascript bindings for essentia C++ library.essentia.js
- JS glue code for loadingessentia.wasm
(can be used with HTML<script>
tag).essentia-module.js
- Synchronous build of generic javascript bindings for essentia C++ library (ES6 import/export and AudioWorklet support).essentia.jstools.js
- Utility methods for converting JS typed arrays to and from essentia input types.Currently, the python code_generator.py script creates cpp source code and bindings for all the algos listed in included_algos.md. This list of included algorithms can be customised using the configure_bindings.py script.
On JavaScript end, the usage would be like,
For example in real use-cases, it will look like below,
As we can see in the above example, the user needs to specify all the required value for all the parameters. This can be irritating since a lot of essentia Algorithms has more than 10 parameters such as
PredominantPitchMelodia
,MultiPitchKlapuri
etc. The current way of binding the classEssentiaJS
using embind is not binding the default parameter values specified in the class.In order to add bindings for default parameter values in JS front of essentia, we need to do overload every method inside the class
EssentiaJS
as detailed in embind documentation. In order to deliver MVP build of essentia.js0.1.0
, this feature is currently ignored and will be addressed in the next version builds.TODO: Currently there are no detailed unit tests for the bindings besides some base tests. Ideally, this should be automated. We have to check on all of the possibilities for that.