essentia.js
essentia.js copied to clipboard
Float params accept JS string containing numeric characters
For reference when designing the tests in #66, and related to types like #27.
During manual testing of FrequencyBands
I've found the following behaviour regarding its parameter types:
- Passing it a JS
String
for itsfrequencyBands
parameter (which expects aVectorFloat
in C++) does NOT produce an error, as would be expected. This is after converting the givenfrequencyBands
array to aVectorFloat
through the existing utility functionarrayToVector
, which means the function can successfully copy a JSString
into a C++VectorFloat
. The result of the conversion for a 5-letterString
is a vector of 5NaN
s. Essentia then does not complain about thisVectorFloat
ofNaN
s. - Passing it a JS
String
for itsfloat
-typedsampleRate
parameter produces an error only if theString
contains text characters. However, it does not fail with aString
containing numeric characters (such as"16000"
, instead of the JSNumber
of16000
). This means there is probably some sort of string->number type casting attempted somewhere in Embind, but I couldn't find any verification (checked here, here, here, here, and here).
I've opened a discussion on Emscripten's GitHub repository.