Most of the essentia algorithms use std::vector type as array input. This means we might need to convert to and from JS typed array and std::vector types.
Currently, we are achieving this using some helper functions in essentia.tools.js which does the conversion by copying its elements. This might be an overhead for doing efficient computation. Maybe a better way would be is to pass its pointer and directly accessing Emscripten heap.
Issue
Most of the essentia algorithms use
std::vector
type as array input. This means we might need to convert to and from JS typed array and std::vector types.Currently, we are achieving this using some helper functions in
essentia.tools.js
which does the conversion by copying its elements. This might be an overhead for doing efficient computation. Maybe a better way would be is to pass its pointer and directly accessing Emscripten heap.Proposed fix
There are some proposed fixes in this thread https://github.com/emscripten-core/emscripten/issues/5519#issuecomment-589702756.
Some initial benchmarks in this thread shows its potential for JS typed array to std::vector conversion from the C++ side.