chromaprint.js
chromaprint.js copied to clipboard
How does one use this library in the browser?
Hello there, and thanks for your great implementation! I'm having a little trouble in getting started with it though.
I've included the package via npm, and end up with the following hierarchy of files:
chromaprint.js/
├── bin
│ └── fpcalc
├── lib
│ ├── algorithms.coffee
│ ├── calculator.coffee
│ ├── chroma.coffee
│ ├── fpcalc.coffee
│ ├── README.md
│ └── silenceRemover.coffee
├── LICENSE
├── package.json
└── README.md
My question is how exactly does one go about using this in the context of a browser?
The README has the following:
<!-- attaches a chromaprint object to window -->
<script src="path/to/chromaprint.js"><script>
<script>
// Assuming loadAudio gets a decoded audio stream.
loadAudio(url, function(stream) {
chromaprint.calculateFingerprint(stream, console.log);
});
</script>
But where exactly is this chromaprint.js
file? Should it be generated from the .coffee
files somewhere?
Hoping to clear up just a little confusion. Thanks.
@anoadragon453 Good point; the project contains a Cakefile with a task to build index.js (cake build
), which you can then rename to 'chromaprint.js'. If you're using a recent version of Node, you might get an error (TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value "w" is invalid for option "encoding"
); if so, edit the Cakefile on line 43 and remove the 'w'. I'll fix that as soon as I get time.
Alright, so I've built index.js
, (without errors on nodejs v8.9.4) renamed to chromaprint.js
and created a test index.html
:
<script src="chromaprint.js"></script>
<script>
...
console.log(chromaprint);
chromaprint.calculateFingerprint(audio, console.log);
</script>
following the example in the README.
However upon loading the page, calculateFingerprint
doesn't seem to be a function of chromaprint
:
Should a different function be used, or is this not expected?
Hi, I encounter a similar problem. I would like to calculate fingerprint from my input file when the form is submitted. But no matter which parameter I give to the calculate function it does not return anything. Can you explain how to achieve it please ?