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

Help running example #5

Closed
willm opened this issue Dec 7, 2019 · 4 comments
Closed

Help running example #5

willm opened this issue Dec 7, 2019 · 4 comments

Comments

@willm
Copy link

willm commented Dec 7, 2019

I'm trying to run the example from the html provided in the readme. Here are the steps I took:

  1. Create an index.html in the essentia.js directory.
  2. Ranpython -m SimpleHTTPServer in the essentia.js directory
  3. Open http://localhost:8000 in chrome

I get the following in the console:

Screenshot from 2019-12-07 09-32-37

I tried defining an empty audio buffer by adding the following lines before getting the channel data:

var audioCtx = new AudioContext();
var audioBuffer = audioCtx.createBuffer(1, 22050, 22050);

However then I get a complaint that typedFloat32ArrayVec is not defined. I suspect something has not loaded correctly (This is my first venture into using wasm). I'm also not sure about these errors to stdio.html, is there a dependency I'm missing?

@ljoglar
Copy link

ljoglar commented Dec 7, 2019

Hi Will,
Sorry I may not be of a lot of help right now (I'm sitting in my plane back from WAC waiting to depart...)
About the complain that typedFloat32Array2Vec doesn't exist, did you include the following function in your code?

typedFloat32Array2Vec = function(typedArray) { var vec = new Module.VectorFloat(); for (var i=0; i<typedArray.length; i++) { if (typeof typedArray[i] === 'undefined') { vec.push_back(0); } else { vec.push_back(typedArray[i]); } } return vec; }

@willm
Copy link
Author

willm commented Dec 7, 2019

Hi, I think I've got past that problem, the html in the readme defines a function called typedFloat32Array2Vec but tries to use it as typedFloat32ArrayVec (note the missing 2). So if I create an audio buffer and fix the typo, I get a bit further, but now I get:

Screenshot from 2019-12-07 10-23-42

The missing function it seems from the C++ is a string called windowType, do you know what values this is expecting? I tried 'hann' and a few others in https://github.com/MTG/essentia/blob/96531284a35ef6142c6e6ed80cad8b82a9751e2e/src/algorithms/standard/windowing.cpp#L49 but it seems I now get this message Compiled code throwing an exception, 5959664,18536,11

@ljoglar
Copy link

ljoglar commented Dec 10, 2019

Hi Will, I'll look into it.
Thanks.

@albincorreya
Copy link
Member

albincorreya commented Dec 28, 2019

Hey @willm, thanks for the feedback. The above-exception was due to the outdated wasm builds. Made a couple of changes as well. Now it should work as expected. Let me know if not.

The existing essentiamin-0.0.1.wasm builds in the repo is compiled with --emrun linker flags to capture stdout and stderr streams (which is useful for debugging). For dev purposes, you can use emrun tool from emscripten to launch the html page on the browser.

Or if you use the python http server for launching, add the mime type for wasm. Check this mdn/webassembly-examples#5 out. Try this example to add your mime type https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants