@libraz/libsonare 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -22
- package/README.npm.md +47 -22
- package/dist/sonare.js +50 -46
- package/dist/sonare.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,26 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/libraz/libsonare/actions)
|
|
4
4
|
[](https://www.npmjs.com/package/@libraz/libsonare)
|
|
5
|
-
[](https://pypi.org/project/libsonare/)
|
|
6
6
|
[](https://github.com/libraz/libsonare/blob/main/LICENSE)
|
|
7
|
-
[](https://en.cppreference.com/w/cpp/17)
|
|
8
7
|
|
|
9
|
-
Fast, dependency-free audio analysis library for browser and Node.js via WebAssembly. A librosa-like API for music information retrieval.
|
|
8
|
+
Fast, dependency-free audio analysis library for browser and Node.js via WebAssembly. A librosa-like API for music information retrieval -- **tens of times faster** than Python.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @libraz/libsonare
|
|
14
|
+
```
|
|
10
15
|
|
|
11
16
|
## Usage
|
|
12
17
|
|
|
13
18
|
```typescript
|
|
14
|
-
import { init, detectBpm, detectKey, analyze } from '@libraz/libsonare';
|
|
19
|
+
import { init, detectBpm, detectKey, analyze, Audio } from '@libraz/libsonare';
|
|
15
20
|
|
|
16
21
|
await init();
|
|
17
22
|
|
|
18
|
-
//
|
|
19
|
-
const
|
|
20
|
-
|
|
23
|
+
// Function API
|
|
24
|
+
const bpm = detectBpm(samples, sampleRate);
|
|
25
|
+
const key = detectKey(samples, sampleRate);
|
|
26
|
+
const result = analyze(samples, sampleRate);
|
|
27
|
+
console.log(`BPM: ${result.bpm}, Key: ${result.key.name}`);
|
|
21
28
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
|
|
29
|
+
// Audio class API
|
|
30
|
+
const audio = Audio.fromBuffer(samples, sampleRate);
|
|
31
|
+
console.log(`BPM: ${audio.detectBpm()}`);
|
|
32
|
+
console.log(`Key: ${audio.detectKey().name}`);
|
|
25
33
|
```
|
|
26
34
|
|
|
27
35
|
### Browser (CDN)
|
|
@@ -35,7 +43,7 @@ const key = detectKey(audioBuffer, sampleRate);
|
|
|
35
43
|
</script>
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
### Bundlers (
|
|
46
|
+
### Bundlers (Vite, webpack, Next.js, etc.)
|
|
39
47
|
|
|
40
48
|
If your bundler doesn't automatically resolve the `.wasm` file, specify its path:
|
|
41
49
|
|
|
@@ -46,19 +54,36 @@ import { init } from '@libraz/libsonare';
|
|
|
46
54
|
await init({ wasmPath: wasmUrl });
|
|
47
55
|
```
|
|
48
56
|
|
|
57
|
+
### Real-time Streaming
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { init, StreamAnalyzer } from '@libraz/libsonare';
|
|
61
|
+
|
|
62
|
+
await init();
|
|
63
|
+
|
|
64
|
+
const analyzer = new StreamAnalyzer({ sampleRate: 44100 });
|
|
65
|
+
|
|
66
|
+
// In audio processing callback
|
|
67
|
+
analyzer.process(audioChunk);
|
|
68
|
+
|
|
69
|
+
const stats = analyzer.stats();
|
|
70
|
+
console.log(`BPM: ${stats.estimate.bpm}, Key: ${stats.estimate.key}`);
|
|
71
|
+
```
|
|
72
|
+
|
|
49
73
|
## Features
|
|
50
74
|
|
|
51
|
-
- BPM
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
- **Detection**: BPM, key, beats, onsets, chords, sections
|
|
76
|
+
- **Effects**: HPSS, time stretch, pitch shift, normalize, trim
|
|
77
|
+
- **Features**: STFT, mel spectrogram, MFCC, chroma, CQT/VQT, spectral features
|
|
78
|
+
- **Pitch**: YIN, pYIN algorithms
|
|
79
|
+
- **Streaming**: Real-time analysis with progressive estimates
|
|
80
|
+
- **Conversions**: Hz/mel/MIDI/note, frames/time, resample
|
|
81
|
+
|
|
82
|
+
## Also available
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install libsonare # Python bindings with CLI
|
|
86
|
+
```
|
|
62
87
|
|
|
63
88
|
## License
|
|
64
89
|
|
package/README.npm.md
CHANGED
|
@@ -2,26 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/libraz/libsonare/actions)
|
|
4
4
|
[](https://www.npmjs.com/package/@libraz/libsonare)
|
|
5
|
-
[](https://pypi.org/project/libsonare/)
|
|
6
6
|
[](https://github.com/libraz/libsonare/blob/main/LICENSE)
|
|
7
|
-
[](https://en.cppreference.com/w/cpp/17)
|
|
8
7
|
|
|
9
|
-
Fast, dependency-free audio analysis library for browser and Node.js via WebAssembly. A librosa-like API for music information retrieval.
|
|
8
|
+
Fast, dependency-free audio analysis library for browser and Node.js via WebAssembly. A librosa-like API for music information retrieval -- **tens of times faster** than Python.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @libraz/libsonare
|
|
14
|
+
```
|
|
10
15
|
|
|
11
16
|
## Usage
|
|
12
17
|
|
|
13
18
|
```typescript
|
|
14
|
-
import { init, detectBpm, detectKey, analyze } from '@libraz/libsonare';
|
|
19
|
+
import { init, detectBpm, detectKey, analyze, Audio } from '@libraz/libsonare';
|
|
15
20
|
|
|
16
21
|
await init();
|
|
17
22
|
|
|
18
|
-
//
|
|
19
|
-
const
|
|
20
|
-
|
|
23
|
+
// Function API
|
|
24
|
+
const bpm = detectBpm(samples, sampleRate);
|
|
25
|
+
const key = detectKey(samples, sampleRate);
|
|
26
|
+
const result = analyze(samples, sampleRate);
|
|
27
|
+
console.log(`BPM: ${result.bpm}, Key: ${result.key.name}`);
|
|
21
28
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
|
|
29
|
+
// Audio class API
|
|
30
|
+
const audio = Audio.fromBuffer(samples, sampleRate);
|
|
31
|
+
console.log(`BPM: ${audio.detectBpm()}`);
|
|
32
|
+
console.log(`Key: ${audio.detectKey().name}`);
|
|
25
33
|
```
|
|
26
34
|
|
|
27
35
|
### Browser (CDN)
|
|
@@ -35,7 +43,7 @@ const key = detectKey(audioBuffer, sampleRate);
|
|
|
35
43
|
</script>
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
### Bundlers (
|
|
46
|
+
### Bundlers (Vite, webpack, Next.js, etc.)
|
|
39
47
|
|
|
40
48
|
If your bundler doesn't automatically resolve the `.wasm` file, specify its path:
|
|
41
49
|
|
|
@@ -46,19 +54,36 @@ import { init } from '@libraz/libsonare';
|
|
|
46
54
|
await init({ wasmPath: wasmUrl });
|
|
47
55
|
```
|
|
48
56
|
|
|
57
|
+
### Real-time Streaming
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { init, StreamAnalyzer } from '@libraz/libsonare';
|
|
61
|
+
|
|
62
|
+
await init();
|
|
63
|
+
|
|
64
|
+
const analyzer = new StreamAnalyzer({ sampleRate: 44100 });
|
|
65
|
+
|
|
66
|
+
// In audio processing callback
|
|
67
|
+
analyzer.process(audioChunk);
|
|
68
|
+
|
|
69
|
+
const stats = analyzer.stats();
|
|
70
|
+
console.log(`BPM: ${stats.estimate.bpm}, Key: ${stats.estimate.key}`);
|
|
71
|
+
```
|
|
72
|
+
|
|
49
73
|
## Features
|
|
50
74
|
|
|
51
|
-
- BPM
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
- **Detection**: BPM, key, beats, onsets, chords, sections
|
|
76
|
+
- **Effects**: HPSS, time stretch, pitch shift, normalize, trim
|
|
77
|
+
- **Features**: STFT, mel spectrogram, MFCC, chroma, CQT/VQT, spectral features
|
|
78
|
+
- **Pitch**: YIN, pYIN algorithms
|
|
79
|
+
- **Streaming**: Real-time analysis with progressive estimates
|
|
80
|
+
- **Conversions**: Hz/mel/MIDI/note, frames/time, resample
|
|
81
|
+
|
|
82
|
+
## Also available
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install libsonare # Python bindings with CLI
|
|
86
|
+
```
|
|
62
87
|
|
|
63
88
|
## License
|
|
64
89
|
|
package/dist/sonare.js
CHANGED
|
@@ -409,31 +409,6 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
409
409
|
var readyPromiseResolve, readyPromiseReject;
|
|
410
410
|
|
|
411
411
|
// Memory management
|
|
412
|
-
var
|
|
413
|
-
/** @type {!Int8Array} */
|
|
414
|
-
HEAP8,
|
|
415
|
-
/** @type {!Uint8Array} */
|
|
416
|
-
HEAPU8,
|
|
417
|
-
/** @type {!Int16Array} */
|
|
418
|
-
HEAP16,
|
|
419
|
-
/** @type {!Uint16Array} */
|
|
420
|
-
HEAPU16,
|
|
421
|
-
/** @type {!Int32Array} */
|
|
422
|
-
HEAP32,
|
|
423
|
-
/** @type {!Uint32Array} */
|
|
424
|
-
HEAPU32,
|
|
425
|
-
/** @type {!Float32Array} */
|
|
426
|
-
HEAPF32,
|
|
427
|
-
/** @type {!Float64Array} */
|
|
428
|
-
HEAPF64;
|
|
429
|
-
|
|
430
|
-
// BigInt64Array type is not correctly defined in closure
|
|
431
|
-
var
|
|
432
|
-
/** not-@type {!BigInt64Array} */
|
|
433
|
-
HEAP64,
|
|
434
|
-
/* BigUint64Array type is not correctly defined in closure
|
|
435
|
-
/** not-@type {!BigUint64Array} */
|
|
436
|
-
HEAPU64;
|
|
437
412
|
|
|
438
413
|
var runtimeInitialized = false;
|
|
439
414
|
|
|
@@ -730,6 +705,36 @@ async function createWasm() {
|
|
|
730
705
|
}
|
|
731
706
|
}
|
|
732
707
|
|
|
708
|
+
/** @type {!Int16Array} */
|
|
709
|
+
var HEAP16;
|
|
710
|
+
|
|
711
|
+
/** @type {!Int32Array} */
|
|
712
|
+
var HEAP32;
|
|
713
|
+
|
|
714
|
+
/** not-@type {!BigInt64Array} */
|
|
715
|
+
var HEAP64;
|
|
716
|
+
|
|
717
|
+
/** @type {!Int8Array} */
|
|
718
|
+
var HEAP8;
|
|
719
|
+
|
|
720
|
+
/** @type {!Float32Array} */
|
|
721
|
+
var HEAPF32;
|
|
722
|
+
|
|
723
|
+
/** @type {!Float64Array} */
|
|
724
|
+
var HEAPF64;
|
|
725
|
+
|
|
726
|
+
/** @type {!Uint16Array} */
|
|
727
|
+
var HEAPU16;
|
|
728
|
+
|
|
729
|
+
/** @type {!Uint32Array} */
|
|
730
|
+
var HEAPU32;
|
|
731
|
+
|
|
732
|
+
/** not-@type {!BigUint64Array} */
|
|
733
|
+
var HEAPU64;
|
|
734
|
+
|
|
735
|
+
/** @type {!Uint8Array} */
|
|
736
|
+
var HEAPU8;
|
|
737
|
+
|
|
733
738
|
var callRuntimeCallbacks = (callbacks) => {
|
|
734
739
|
while (callbacks.length > 0) {
|
|
735
740
|
// Pass the module as the first argument.
|
|
@@ -765,12 +770,12 @@ async function createWasm() {
|
|
|
765
770
|
|
|
766
771
|
var noExitRuntime = true;
|
|
767
772
|
|
|
768
|
-
|
|
773
|
+
function ptrToString(ptr) {
|
|
769
774
|
assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
|
|
770
775
|
// Convert to 32-bit unsigned value
|
|
771
776
|
ptr >>>= 0;
|
|
772
777
|
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
773
|
-
}
|
|
778
|
+
}
|
|
774
779
|
|
|
775
780
|
|
|
776
781
|
/**
|
|
@@ -3427,6 +3432,7 @@ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
|
3427
3432
|
'FS_preloadFile',
|
|
3428
3433
|
'FS_modeStringToFlags',
|
|
3429
3434
|
'FS_getMode',
|
|
3435
|
+
'FS_fileDataToTypedArray',
|
|
3430
3436
|
'FS_stdin_getChar',
|
|
3431
3437
|
'FS_mkdirTree',
|
|
3432
3438
|
'_setNetworkCallback',
|
|
@@ -3483,21 +3489,21 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3483
3489
|
'callMain',
|
|
3484
3490
|
'abort',
|
|
3485
3491
|
'wasmExports',
|
|
3486
|
-
'
|
|
3487
|
-
'
|
|
3492
|
+
'writeStackCookie',
|
|
3493
|
+
'checkStackCookie',
|
|
3494
|
+
'INT53_MAX',
|
|
3495
|
+
'INT53_MIN',
|
|
3496
|
+
'bigintToI53Checked',
|
|
3488
3497
|
'HEAP8',
|
|
3489
3498
|
'HEAPU8',
|
|
3490
3499
|
'HEAP16',
|
|
3491
3500
|
'HEAPU16',
|
|
3492
3501
|
'HEAP32',
|
|
3493
3502
|
'HEAPU32',
|
|
3503
|
+
'HEAPF32',
|
|
3504
|
+
'HEAPF64',
|
|
3494
3505
|
'HEAP64',
|
|
3495
3506
|
'HEAPU64',
|
|
3496
|
-
'writeStackCookie',
|
|
3497
|
-
'checkStackCookie',
|
|
3498
|
-
'INT53_MAX',
|
|
3499
|
-
'INT53_MIN',
|
|
3500
|
-
'bigintToI53Checked',
|
|
3501
3507
|
'stackSave',
|
|
3502
3508
|
'stackRestore',
|
|
3503
3509
|
'createNamedFunction',
|
|
@@ -3680,12 +3686,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
3680
3686
|
'FS_createDataFile',
|
|
3681
3687
|
'FS_forceLoadFile',
|
|
3682
3688
|
'FS_createLazyFile',
|
|
3683
|
-
'FS_absolutePath',
|
|
3684
|
-
'FS_createFolder',
|
|
3685
|
-
'FS_createLink',
|
|
3686
|
-
'FS_joinPath',
|
|
3687
|
-
'FS_mmapAlloc',
|
|
3688
|
-
'FS_standardizePath',
|
|
3689
3689
|
'MEMFS',
|
|
3690
3690
|
'TTY',
|
|
3691
3691
|
'PIPEFS',
|
|
@@ -3793,6 +3793,10 @@ function checkIncomingModuleAPI() {
|
|
|
3793
3793
|
ignoredModuleProp('fetchSettings');
|
|
3794
3794
|
ignoredModuleProp('logReadFiles');
|
|
3795
3795
|
ignoredModuleProp('loadSplitModule');
|
|
3796
|
+
ignoredModuleProp('onMalloc');
|
|
3797
|
+
ignoredModuleProp('onRealloc');
|
|
3798
|
+
ignoredModuleProp('onFree');
|
|
3799
|
+
ignoredModuleProp('onSbrkGrow');
|
|
3796
3800
|
}
|
|
3797
3801
|
|
|
3798
3802
|
// Imports from the Wasm binary.
|
|
@@ -3800,11 +3804,11 @@ var ___getTypeName = makeInvalidEarlyAccess('___getTypeName');
|
|
|
3800
3804
|
var _malloc = makeInvalidEarlyAccess('_malloc');
|
|
3801
3805
|
var _free = makeInvalidEarlyAccess('_free');
|
|
3802
3806
|
var _fflush = makeInvalidEarlyAccess('_fflush');
|
|
3803
|
-
var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
|
|
3804
|
-
var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base');
|
|
3805
3807
|
var _strerror = makeInvalidEarlyAccess('_strerror');
|
|
3806
3808
|
var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init');
|
|
3807
3809
|
var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free');
|
|
3810
|
+
var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base');
|
|
3811
|
+
var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
|
|
3808
3812
|
var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore');
|
|
3809
3813
|
var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc');
|
|
3810
3814
|
var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current');
|
|
@@ -3818,11 +3822,11 @@ function assignWasmExports(wasmExports) {
|
|
|
3818
3822
|
assert(typeof wasmExports['malloc'] != 'undefined', 'missing Wasm export: malloc');
|
|
3819
3823
|
assert(typeof wasmExports['free'] != 'undefined', 'missing Wasm export: free');
|
|
3820
3824
|
assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush');
|
|
3821
|
-
assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end');
|
|
3822
|
-
assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base');
|
|
3823
3825
|
assert(typeof wasmExports['strerror'] != 'undefined', 'missing Wasm export: strerror');
|
|
3824
3826
|
assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init');
|
|
3825
3827
|
assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free');
|
|
3828
|
+
assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base');
|
|
3829
|
+
assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end');
|
|
3826
3830
|
assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore');
|
|
3827
3831
|
assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc');
|
|
3828
3832
|
assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current');
|
|
@@ -3832,11 +3836,11 @@ function assignWasmExports(wasmExports) {
|
|
|
3832
3836
|
_malloc = createExportWrapper('malloc', 1);
|
|
3833
3837
|
_free = createExportWrapper('free', 1);
|
|
3834
3838
|
_fflush = createExportWrapper('fflush', 1);
|
|
3835
|
-
_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
|
|
3836
|
-
_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
|
|
3837
3839
|
_strerror = createExportWrapper('strerror', 1);
|
|
3838
3840
|
_emscripten_stack_init = wasmExports['emscripten_stack_init'];
|
|
3839
3841
|
_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'];
|
|
3842
|
+
_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
|
|
3843
|
+
_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
|
|
3840
3844
|
__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'];
|
|
3841
3845
|
__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'];
|
|
3842
3846
|
_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'];
|
package/dist/sonare.wasm
CHANGED
|
Binary file
|