MTG / essentia.js

JavaScript library for music/audio analysis and processing powered by Essentia WebAssembly
https://essentia.upf.edu/essentiajs
GNU Affero General Public License v3.0
632 stars 41 forks source link

JS interface for algorithms that expects non-supported I/O types in Embind #27

Open albincorreya opened 4 years ago

albincorreya commented 4 years ago

Issue

The current JS bindings of Essentia WASM backend which generated using Emscripten Embind doesn't provide a factory template to map STL data types such as std::complex (see this issue)(vector_complex) and custom datatypes used in Essentia such as TNT::Array*(matrix_real)

The following algorithms expect either an input, parameter, or output variable of std::complex type.

['CartesianToPolar', 'PolarToCartesian', 'Magnitude', 'ConstantQ', 'NSGConstantQ', 'NSGIConstantQ', 'FFT', 'IFFT', 'FFTC', 'IFFTC', 'HarmonicMask', 'HarmonicModelAnal', 'SineModelAnal', 'SineModelSynth']

The following algorithms expect either an input, parameter, or output variable of TNT::Array* type.

['BpmHistogram', 'FadeDetection', 'HumDetector', 'Onsets', 'Panning', 'SBic', 'SingleGaussian']

There was a bug in the python code generator which included these algorithms in the current builds. All the above-listed algorithms will be excluded from the future essentia.js API until this issue was addressed and solved.

Currently, the most straight-forward way to use these algorithms in JS end will be to cross-compile a custom-written Essentia CPP extractor which abstracts these types with common JS supported data types such as JS object using emscripten::val.

In addition, the following algorithms expect a vector_stereosample type for either input or output variables.

['FalseStereoDetector', 'LoudnessEBUR128', 'StereoDemuxer', 'StereoMuxer', 'StereoTrimmer'].

OR

We could write some generic custom CPP wrappers which could expose a JS interface to these algorithms. Which requires a bit of work.

jmarcosfer commented 4 months ago

related issue on emscripten repo

jmarcosfer commented 4 months ago

Also possible newer methods to re-write current [conversion function]() arrayToVector: