arrayToVector convertion stretches the audio (?)
thomasborgogno opened this issue · 2 comments
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
When I launch any BeatTracker I retrieve ticks that are after the audio is ended, for example with an audio of 30s i get some ticks at 31, 33 seconds.
I don't know if it's a problem of mine or an effective bug, but maybe the problem is in the convertion from array to vector?
Steps to reproduce / Code snippets / Screenshots
let audioData = await essentiaExtractor.getAudioChannelDataFromURL(audioURL, audioCtx, 0);
let signal = essentiaExtractor.arrayToVector(audioData);
let ticks = await essentiaExtractor.BeatTrackerMultiFeature(signal).ticks;
for(var i=0; i<ticks.size(); ++i){
console.log(ticks.get(i));
}
Thank you for your amazing work, I hope this is not a dumb request, and sorry for my bad english
I've been able to replicate your issue. This isn't a problem with the arrayToVector
conversion. This has to do with sample rate.
BeatTrackerMultiFeature
assumes a sample rate of 44100 hz. This isn't mentioned on our documentation (we will fix this when we update the docs), but it is mentioned in the upstream Essentia documentation.
What you've experienced is most likely due to your computer audio having a sample rate higher than 44100 hz (typically 48000 hz). In that case, each second will contain 48000 samples. But BeatTrackerMultiFeature
assumes there are only 44100 samples per second, so it will have extra samples at the end and will consider the audio file to be longer than it is. That's why it outputs time stamps apparently "after the audio is ended".
Simply try to ensure that your system audio is working at 44100 hz sampling rate. It's a pity that this can't be controlled from the browser (i.e. the BaseAudioContext.sampleRate
is read-only).
hope this helps!
Thank you very much for your kind reply, that was the problem!