Return the version in little endian

This commit is contained in:
Anton Liaposhchenko 2023-12-28 17:47:35 +02:00
parent 082e8b6596
commit f06461313e
3 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ await analyze("/path/to/track.mp3") // returns Uint8Array
```
## Return value
The output of `bliss-rs` consists of single-precision floats, currently 20 of them. This fork contains code to convert it into an array of 80 bytes in little endian order. An additional version (also comes from `bliss-rs`, currently equal to `1`) is prepended at the start as 16 bits in platform endianness. Therefore, the total output size is 82 bytes.
The output of `bliss-rs` consists of single-precision floats, currently 20 of them. This fork contains code to convert it into an array of 80 bytes in little endian order. An additional version (also comes from `bliss-rs`, currently equal to `1`) is prepended at the start (16-bit unsigned little-endian integer). Therefore, the total output size is 82 bytes.
### Usage
The output (without the version) is meant to be converted back into floats and used to calculate the [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance#Higher_dimensions) between two songs. Other distance algorithms are being worked on by the Bliss team.

View File

@ -1,6 +1,6 @@
{
"name": "@bliss-rs/bliss-rs",
"version": "0.0.2",
"version": "0.0.3",
"description": "A fork of the bliss-rs library with Node.js bindings",
"main": "index.js",
"types": "index.d.ts",

View File

@ -44,7 +44,7 @@ fn analyze_async(mut cx: FunctionContext) -> JsResult<JsPromise> {
Ok(promise)
}
/// Returns a Uint8Array, with the first 2 bytes being the version in platform endianness
/// Returns a Uint8Array, with the first 2 bytes being the version (16-bit unsigned little endian)
/// and the rest (currently 80 bytes) being the analysis data in little endian
fn analyze(mut cx: FunctionContext) -> JsResult<JsUint8Array> {
let path = cx.argument::<JsString>(0)?.value(&mut cx);
@ -65,7 +65,7 @@ fn analyze(mut cx: FunctionContext) -> JsResult<JsUint8Array> {
fn analyze_raw(path: &str) -> BlissResult<([u8; 2], [u8; 80])> {
let song = Song::from_path(path)?;
let version_bytes = song.features_version.to_ne_bytes();
let version_bytes = song.features_version.to_le_bytes();
let analysis_bytes = song.analysis.as_bytes();
Ok((version_bytes, analysis_bytes))
}