@libraz/libsonare 1.2.0 → 1.2.2

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  A dependency-free audio DSP toolkit for browser and Node.js via WebAssembly —
11
11
  librosa-compatible analysis plus broadcast-grade mastering, mixing, and editing.
12
- The same C++ processors run client-side in the browser: 77 named mastering DSP
12
+ The same C++ processors run client-side in the browser: 66 named mastering DSP
13
13
  processors implemented against published references (ITU-R BS.1770-4 true-peak
14
14
  limiting, Linkwitz-Riley crossovers, Vicanek matched-Z biquads, ADAA-antialiased
15
15
  saturation), with analysis defaults matching librosa — Apache-2.0, no Python,
@@ -56,6 +56,57 @@ console.log(`Key: ${audio.detectKey().name}`);
56
56
  const audioKeyWithOptions = audio.detectKey({ useHpss: true, highPassHz: 80 });
57
57
  ```
58
58
 
59
+ ### Pitch, timbre, and spectral APIs
60
+
61
+ Pitch tracking keeps unvoiced `f0` frames as `NaN` by default. Pass
62
+ `fillNa: true` when downstream code needs finite values and should treat
63
+ unvoiced frames as `0`. Timbre analysis returns aggregate metrics plus
64
+ `timbreOverTime`.
65
+
66
+ ```typescript
67
+ import {
68
+ analyzeTimbre,
69
+ decompose,
70
+ ebur128LoudnessRange,
71
+ estimateTuning,
72
+ hpssWithResidual,
73
+ init,
74
+ lufsInterleaved,
75
+ nnFilter,
76
+ phaseVocoder,
77
+ pitchPyin,
78
+ pitchTuning,
79
+ pitchYin,
80
+ polyFeatures,
81
+ remix,
82
+ spectralContrast,
83
+ zeroCrossings,
84
+ } from '@libraz/libsonare';
85
+
86
+ await init();
87
+
88
+ const yin = pitchYin(samples, sampleRate, 2048, 512, 65, 2093, 0.3, true);
89
+ const pyin = pitchPyin(samples, sampleRate, 2048, 512, 65, 2093, 0.3, true);
90
+
91
+ const timbre = analyzeTimbre(samples, sampleRate);
92
+ console.log(timbre.brightness, timbre.timbreOverTime[0]?.brightness);
93
+
94
+ const contrast = spectralContrast(samples, sampleRate); // Matrix2d result
95
+ const poly = polyFeatures(samples, sampleRate); // Matrix2d result
96
+ const crossings = zeroCrossings(samples); // Int32Array
97
+ const tuning = estimateTuning(samples, sampleRate);
98
+ const offset = pitchTuning(yin.f0);
99
+
100
+ const { w, h } = decompose(spectrogram, nFeatures, nFrames, 8);
101
+ const filtered = nnFilter(spectrogram, nFeatures, nFrames);
102
+ const remixed = remix(samples, Int32Array.from([0, sampleRate, sampleRate, 2 * sampleRate]));
103
+ const stretched = phaseVocoder(samples, 1.5, sampleRate);
104
+ const hpss = hpssWithResidual(samples, sampleRate);
105
+
106
+ const multi = lufsInterleaved(interleaved, 2, sampleRate);
107
+ const lra = ebur128LoudnessRange(samples, sampleRate);
108
+ ```
109
+
59
110
  ### Room acoustics
60
111
 
61
112
  Use `detectAcoustic` for blind RT60/EDT estimation from ordinary audio.
@@ -392,11 +443,12 @@ chain.delete(); // release WASM memory
392
443
  ## Features
393
444
 
394
445
  - **Detection**: BPM, key, beats, onsets, chords, sections
395
- - **Effects**: HPSS, time stretch, pitch shift, normalize, trim
446
+ - **Effects**: HPSS, HPSS with residual, time stretch, phase vocoder, pitch shift, normalize, trim, remix
396
447
  - **Mastering**: EQ, compressor, tape/exciter, air band, stereo imaging,
397
448
  true-peak limiting, loudness optimization
398
- - **Features**: STFT, mel spectrogram, MFCC, chroma, CQT/VQT, spectral features
399
- - **Pitch**: YIN, pYIN algorithms
449
+ - **Features**: STFT, mel spectrogram, MFCC, chroma, CQT/VQT, spectral contrast, poly features, zero crossings
450
+ - **Pitch**: YIN, pYIN algorithms with optional `fillNa`
451
+ - **Decomposition & loudness**: NMF decomposition, nearest-neighbour filtering, multichannel LUFS, EBU R128 LRA
400
452
  - **Streaming**: Real-time analysis with progressive estimates
401
453
  - **Conversions**: Hz/mel/MIDI/note, frames/time, resample
402
454