Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VectorFloat params incorrectly converted on Typescript before passed to WASM #136

Open
2 of 9 tasks
jmarcosfer opened this issue Feb 28, 2024 · 0 comments
Open
2 of 9 tasks
Assignees
Labels
bug Something isn't working

Comments

@jmarcosfer
Copy link
Collaborator

What is the issue about?

  • Bug
  • Feature request
  • Usage question
  • Documentation
  • Contributing / Development

What part(s) of Essentia.js is involved?

  • essentia.js-core (vanilla algorithms)
  • essentia.js-model (machine learning algorithms)
  • essentia.js-plot (plotting utility module)
  • essentia.js-extractor (typical algorithm combinations utility)

Description

Algorithms with vector_real parameter types have these parameters converted to VectorFloat on the TypeScript wrapper using the following code pattern:

let veconsets = new this.module.VectorFloat();
for (var i=0; i<veconsets.size(); i++) {
  veconsets.push_back(onsets[i]);
}

This produces an uncaught exception on the WASM side, since VectorFloat is initialized empty by default, so the loop never runs and the parameter is passed to the C++ empty.
The affected algorithms are:

  • AudioOnsetsMarker
  • BPF
  • BeatsLoudness
  • CubicSpline
  • FrequencyBands
  • IIR
  • NoveltyCurve
  • RhythmExtractor
  • SingleBeatLoudness
  • Slicer
  • Spline
  • TempoScaleBands
  • TempoTap
  • TriangularBands

Steps to reproduce / Code snippets / Screenshots

Here is a quick browser test of the algorithms FrequencyBands and BPF.
This test also includes a proposed solution using one of these options:

// use the Array -> VectorFloat conversion utility function built into essentia.js
let veconsets = this.module.arrayToVector(onsets);
let veconsets = new this.module.VectorFloat();
let i = 0;
while (veconsets.size() < onsets.length) {
   veconsets.push_back(onsets[i]);
   i++;
}

This will be addressed and solved in the PR for issue #64, with revised generated code for core_api.ts.

System info

Hardware: Dell Inc. Vostro 5490; 8,0 GiB RAM; Intel Core i7-10510U CPU @ 1.80GHz × 8
OS: Ubuntu 22.04.2 LTS, 64-bit
Browser: Chrome 115.0.5790.110 (Official Build) (64-bit)
essentia.js 0.1.3

@jmarcosfer jmarcosfer added the bug Something isn't working label Feb 28, 2024
@jmarcosfer jmarcosfer self-assigned this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To do
Development

No branches or pull requests

1 participant