@libraz/libsonare 1.2.2 → 1.3.0
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 +38 -1
- package/dist/index.d.ts +1 -2722
- package/dist/index.js +3659 -1896
- package/dist/index.js.map +1 -1
- package/dist/sonare-rt-module.js +1 -1
- package/dist/sonare-rt.js +1 -1
- package/dist/sonare-rt.wasm +0 -0
- package/dist/sonare.js +1 -1
- package/dist/sonare.wasm +0 -0
- package/dist/worklet.d.ts +4827 -455
- package/dist/worklet.js +1076 -494
- package/dist/worklet.js.map +1 -1
- package/package.json +2 -1
- package/src/analysis_helpers.ts +152 -0
- package/src/audio.ts +493 -0
- package/src/codes.ts +56 -0
- package/src/effects_mastering.ts +964 -0
- package/src/feature_core.ts +248 -0
- package/src/feature_music.ts +419 -0
- package/src/feature_pitch.ts +80 -0
- package/src/feature_resample.ts +21 -0
- package/src/feature_spectral.ts +330 -0
- package/src/feature_spectrogram.ts +454 -0
- package/src/features.ts +84 -0
- package/src/index.ts +352 -4793
- package/src/live_audio.ts +45 -0
- package/src/metering.ts +380 -0
- package/src/mixer.ts +523 -0
- package/src/module_state.ts +14 -0
- package/src/opfs_clip_pages.ts +188 -0
- package/src/project.ts +1614 -0
- package/src/public_types.ts +244 -2
- package/src/quick_analysis.ts +508 -0
- package/src/realtime_engine.ts +667 -0
- package/src/realtime_voice_changer.ts +275 -0
- package/src/scale.ts +42 -0
- package/src/sonare.js.d.ts +386 -4
- package/src/stream_analyzer.ts +275 -0
- package/src/stream_types.ts +29 -1
- package/src/streaming_mixing.ts +18 -0
- package/src/streaming_processors.ts +335 -0
- package/src/validation.ts +82 -0
- package/src/web_midi.ts +367 -0
- package/src/worklet.ts +525 -81
package/src/public_types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ValidateOptions } from './validation';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Pitch class enum (C=0, C#=1, ..., B=11)
|
|
3
5
|
*/
|
|
@@ -172,6 +174,7 @@ export type SoloProcessor =
|
|
|
172
174
|
| 'saturation.exciter'
|
|
173
175
|
| 'saturation.hardClipper'
|
|
174
176
|
| 'saturation.multibandExciter'
|
|
177
|
+
| 'saturation.ampSim'
|
|
175
178
|
| 'saturation.softClipper'
|
|
176
179
|
| 'saturation.tape'
|
|
177
180
|
| 'saturation.transformer'
|
|
@@ -230,7 +233,7 @@ export interface Key {
|
|
|
230
233
|
shortName: string;
|
|
231
234
|
}
|
|
232
235
|
|
|
233
|
-
export interface KeyDetectionOptions {
|
|
236
|
+
export interface KeyDetectionOptions extends ValidateOptions {
|
|
234
237
|
nFft?: number;
|
|
235
238
|
hopLength?: number;
|
|
236
239
|
useHpss?: boolean;
|
|
@@ -251,7 +254,7 @@ export interface KeyCandidate {
|
|
|
251
254
|
correlation: number;
|
|
252
255
|
}
|
|
253
256
|
|
|
254
|
-
export interface ChordDetectionOptions {
|
|
257
|
+
export interface ChordDetectionOptions extends ValidateOptions {
|
|
255
258
|
minDuration?: number;
|
|
256
259
|
smoothingWindow?: number;
|
|
257
260
|
threshold?: number;
|
|
@@ -268,6 +271,102 @@ export interface ChordDetectionOptions {
|
|
|
268
271
|
chromaMethod?: 'stft' | 'nnls';
|
|
269
272
|
}
|
|
270
273
|
|
|
274
|
+
/** Options for `detectAcoustic`. All fields are optional. */
|
|
275
|
+
export interface AcousticOptions extends ValidateOptions {
|
|
276
|
+
/** Number of octave bands. Default 6. */
|
|
277
|
+
nOctaveBands?: number;
|
|
278
|
+
/** Number of 1/3-octave sub-bands. Default 24. */
|
|
279
|
+
nThirdOctaveSubbands?: number;
|
|
280
|
+
/** Minimum decay range (dB) for a valid RT60 fit. Default 30. */
|
|
281
|
+
minDecayDb?: number;
|
|
282
|
+
/** Margin (dB) above the noise floor for the decay fit. Default 10. */
|
|
283
|
+
noiseFloorMarginDb?: number;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Options for `analyzeBpm`. All fields are optional. */
|
|
287
|
+
export interface AnalyzeBpmOptions extends ValidateOptions {
|
|
288
|
+
/** Lowest BPM to consider. Default 30. */
|
|
289
|
+
bpmMin?: number;
|
|
290
|
+
/** Highest BPM to consider. Default 300. */
|
|
291
|
+
bpmMax?: number;
|
|
292
|
+
/** Tempo prior the tracker is biased toward. Default 120. */
|
|
293
|
+
startBpm?: number;
|
|
294
|
+
/** FFT size for the onset envelope. Default 2048. */
|
|
295
|
+
nFft?: number;
|
|
296
|
+
/** Hop length for the onset envelope. Default 512. */
|
|
297
|
+
hopLength?: number;
|
|
298
|
+
/** Number of tempo candidates to return. Default 5. */
|
|
299
|
+
maxCandidates?: number;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Options for `analyzeRhythm`. All fields are optional. */
|
|
303
|
+
export interface AnalyzeRhythmOptions extends ValidateOptions {
|
|
304
|
+
/** Lowest BPM to consider. Default 60. */
|
|
305
|
+
bpmMin?: number;
|
|
306
|
+
/** Highest BPM to consider. Default 200. */
|
|
307
|
+
bpmMax?: number;
|
|
308
|
+
/** Tempo prior the tracker is biased toward. Default 120. */
|
|
309
|
+
startBpm?: number;
|
|
310
|
+
/** FFT size for the onset envelope. Default 2048. */
|
|
311
|
+
nFft?: number;
|
|
312
|
+
/** Hop length for the onset envelope. Default 512. */
|
|
313
|
+
hopLength?: number;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Options for `analyzeDynamics`. All fields are optional. */
|
|
317
|
+
export interface AnalyzeDynamicsOptions extends ValidateOptions {
|
|
318
|
+
/** Loudness-curve window length in seconds. Default 0.4. */
|
|
319
|
+
windowSec?: number;
|
|
320
|
+
/** Hop length for the loudness curve. Default 512. */
|
|
321
|
+
hopLength?: number;
|
|
322
|
+
/** Crest-factor (dB) below which the signal is flagged as compressed. Default 6. */
|
|
323
|
+
compressionThreshold?: number;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Options for `analyzeTimbre`. All fields are optional. */
|
|
327
|
+
export interface AnalyzeTimbreOptions extends ValidateOptions {
|
|
328
|
+
/** FFT size. Default 2048. */
|
|
329
|
+
nFft?: number;
|
|
330
|
+
/** Hop length. Default 512. */
|
|
331
|
+
hopLength?: number;
|
|
332
|
+
/** Number of Mel bands. Default 128. */
|
|
333
|
+
nMels?: number;
|
|
334
|
+
/** Number of MFCCs. Default 13. */
|
|
335
|
+
nMfcc?: number;
|
|
336
|
+
/** Per-window analysis length in seconds. Default 0.5. */
|
|
337
|
+
windowSec?: number;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Options for `analyzeSections`. All fields are optional. */
|
|
341
|
+
export interface AnalyzeSectionsOptions {
|
|
342
|
+
/** FFT size. Default 2048. */
|
|
343
|
+
nFft?: number;
|
|
344
|
+
/** Hop length. Default 512. */
|
|
345
|
+
hopLength?: number;
|
|
346
|
+
/** Minimum section duration in seconds. Default 4. */
|
|
347
|
+
minSectionSec?: number;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** Options for `mastering`. All fields are optional. */
|
|
351
|
+
export interface MasteringOptions {
|
|
352
|
+
/** Target integrated LUFS. Default -14. */
|
|
353
|
+
targetLufs?: number;
|
|
354
|
+
/** True/sample peak ceiling in dBFS. Default -1. */
|
|
355
|
+
ceilingDb?: number;
|
|
356
|
+
/** Oversampling factor used for peak estimation. Default 4. */
|
|
357
|
+
truePeakOversample?: number;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Options for `noteStretch`. All fields are optional. */
|
|
361
|
+
export interface NoteStretchOptions {
|
|
362
|
+
/** Note onset position in samples (selects the region). Default 0. */
|
|
363
|
+
onsetSample?: number;
|
|
364
|
+
/** Note offset position in samples (selects the region). Default 0. */
|
|
365
|
+
offsetSample?: number;
|
|
366
|
+
/** Stretch ratio (0.5 = double duration, 2.0 = half duration). Default 1. */
|
|
367
|
+
stretchRatio?: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
271
370
|
/**
|
|
272
371
|
* Detected beat
|
|
273
372
|
*/
|
|
@@ -347,6 +446,15 @@ export interface CqtResult {
|
|
|
347
446
|
frequencies: Float32Array;
|
|
348
447
|
}
|
|
349
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Multi-band onset strength matrix result.
|
|
451
|
+
*/
|
|
452
|
+
export interface OnsetStrengthMultiResult {
|
|
453
|
+
nBands: number;
|
|
454
|
+
nFrames: number;
|
|
455
|
+
data: Float32Array;
|
|
456
|
+
}
|
|
457
|
+
|
|
350
458
|
/**
|
|
351
459
|
* Timbre characteristics
|
|
352
460
|
*/
|
|
@@ -363,6 +471,8 @@ export interface Timbre {
|
|
|
363
471
|
*/
|
|
364
472
|
export interface Dynamics {
|
|
365
473
|
dynamicRangeDb: number;
|
|
474
|
+
peakDb: number;
|
|
475
|
+
rmsDb: number;
|
|
366
476
|
loudnessRangeDb: number;
|
|
367
477
|
crestFactor: number;
|
|
368
478
|
isCompressed: boolean;
|
|
@@ -384,6 +494,19 @@ export interface RhythmFeatures {
|
|
|
384
494
|
syncopation: number;
|
|
385
495
|
grooveType: string;
|
|
386
496
|
patternRegularity: number;
|
|
497
|
+
tempoStability: number;
|
|
498
|
+
timeSignature: TimeSignature;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Melody contour from the unified analysis (pitch trajectory + summary stats).
|
|
503
|
+
*/
|
|
504
|
+
export interface MelodyContour {
|
|
505
|
+
pitchRangeOctaves: number;
|
|
506
|
+
pitchStability: number;
|
|
507
|
+
meanFrequency: number;
|
|
508
|
+
vibratoRate: number;
|
|
509
|
+
pitches: MelodyPoint[];
|
|
387
510
|
}
|
|
388
511
|
|
|
389
512
|
/**
|
|
@@ -401,6 +524,7 @@ export interface AnalysisResult {
|
|
|
401
524
|
timbre: Timbre;
|
|
402
525
|
dynamics: Dynamics;
|
|
403
526
|
rhythm: RhythmFeatures;
|
|
527
|
+
melody: MelodyContour;
|
|
404
528
|
form: string;
|
|
405
529
|
}
|
|
406
530
|
|
|
@@ -421,6 +545,91 @@ export interface AcousticResult {
|
|
|
421
545
|
isBlind: boolean;
|
|
422
546
|
}
|
|
423
547
|
|
|
548
|
+
/** Shoebox geometry + placement shared by RIR synthesis and the room morph. */
|
|
549
|
+
export interface RoomGeometryOptions {
|
|
550
|
+
lengthM?: number;
|
|
551
|
+
widthM?: number;
|
|
552
|
+
heightM?: number;
|
|
553
|
+
/** Uniform wall absorption, clamped to [0, 0.999] (the back-compat scalar). */
|
|
554
|
+
absorption?: number;
|
|
555
|
+
/**
|
|
556
|
+
* Optional per-octave-band wall absorption (125/250/500/1k/2k/4k.. Hz). When
|
|
557
|
+
* provided it overrides `absorption` unless `materialPreset` is set.
|
|
558
|
+
*/
|
|
559
|
+
bandAbsorption?: Float32Array | number[];
|
|
560
|
+
/** Optional per-band wall scattering; missing bands default to 0. */
|
|
561
|
+
bandScattering?: Float32Array | number[];
|
|
562
|
+
/**
|
|
563
|
+
* Named wall-material preset (0 none; 1 concrete, 2 wood, 3 curtain,
|
|
564
|
+
* 4 carpet, 5 glass). A non-zero preset wins over `bandAbsorption`/`absorption`.
|
|
565
|
+
*/
|
|
566
|
+
materialPreset?: number;
|
|
567
|
+
sourceX?: number;
|
|
568
|
+
sourceY?: number;
|
|
569
|
+
sourceZ?: number;
|
|
570
|
+
listenerX?: number;
|
|
571
|
+
listenerY?: number;
|
|
572
|
+
listenerZ?: number;
|
|
573
|
+
ismOrder?: number;
|
|
574
|
+
seed?: number;
|
|
575
|
+
maxSeconds?: number;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export interface RirSynthOptions extends RoomGeometryOptions {
|
|
579
|
+
sampleRate?: number;
|
|
580
|
+
/** Use the Eyring statistical late-tail model (default true); false = Sabine. */
|
|
581
|
+
preferEyring?: boolean;
|
|
582
|
+
/** Early/late crossover in ms (0 = auto, ~sqrt(V) ms). */
|
|
583
|
+
mixingTimeMs?: number;
|
|
584
|
+
/** Equal-power crossfade width around the mixing time in ms (0 = default). */
|
|
585
|
+
crossfadeMs?: number;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export interface RirResult {
|
|
589
|
+
rir: Float32Array;
|
|
590
|
+
sampleRate: number;
|
|
591
|
+
hasError: boolean;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export interface RoomEstimateOptions {
|
|
595
|
+
aspectHintLw?: number;
|
|
596
|
+
aspectHintLh?: number;
|
|
597
|
+
referenceAbsorption?: number;
|
|
598
|
+
preferEyring?: boolean;
|
|
599
|
+
nOctaveBands?: number;
|
|
600
|
+
/** Analyzer routing: 0 = auto, 1 = blind, 2 = impulse-response. */
|
|
601
|
+
mode?: number;
|
|
602
|
+
/** Analyzer decay-fit span in dB (0 = library default). */
|
|
603
|
+
minDecayDb?: number;
|
|
604
|
+
/** Analyzer noise-floor margin in dB (0 = library default). */
|
|
605
|
+
noiseFloorMarginDb?: number;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export interface RoomEstimateResult {
|
|
609
|
+
volume: number;
|
|
610
|
+
length: number;
|
|
611
|
+
width: number;
|
|
612
|
+
height: number;
|
|
613
|
+
drrDb: number;
|
|
614
|
+
confidence: number;
|
|
615
|
+
absorptionBands: Float32Array;
|
|
616
|
+
rt60Bands: Float32Array;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export interface RoomMorphOptions extends RoomGeometryOptions {
|
|
620
|
+
wet?: number;
|
|
621
|
+
sourceTailSuppression?: number;
|
|
622
|
+
/**
|
|
623
|
+
* Use the Eyring statistical late-tail model for the target room (default
|
|
624
|
+
* true); false = Sabine. Matches {@link RirSynthOptions.preferEyring}.
|
|
625
|
+
*/
|
|
626
|
+
preferEyring?: boolean;
|
|
627
|
+
/** Early/late crossover in ms (0 = auto, ~sqrt(V) ms). */
|
|
628
|
+
mixingTimeMs?: number;
|
|
629
|
+
/** Equal-power crossfade width around the mixing time in ms (0 = default). */
|
|
630
|
+
crossfadeMs?: number;
|
|
631
|
+
}
|
|
632
|
+
|
|
424
633
|
/**
|
|
425
634
|
* HPSS (Harmonic-Percussive Source Separation) result
|
|
426
635
|
*/
|
|
@@ -651,6 +860,35 @@ export interface MasteringChainConfig {
|
|
|
651
860
|
};
|
|
652
861
|
}
|
|
653
862
|
|
|
863
|
+
/**
|
|
864
|
+
* Configuration for the block-by-block {@link StreamingMasteringChain}.
|
|
865
|
+
*
|
|
866
|
+
* Extends {@link MasteringChainConfig} with optional precomputed loudness
|
|
867
|
+
* parameters. The streaming chain cannot measure whole-signal integrated LUFS,
|
|
868
|
+
* so an enabled `loudness` stage normally throws at construction. To let a
|
|
869
|
+
* preset's streaming preview match its offline render, the caller may
|
|
870
|
+
* precompute the loudness normalization gain offline (e.g.
|
|
871
|
+
* `targetLufs - measuredIntegratedLufs`) and supply it here.
|
|
872
|
+
*/
|
|
873
|
+
export interface StreamingMasteringChainConfig extends MasteringChainConfig {
|
|
874
|
+
/**
|
|
875
|
+
* Precomputed static loudness gain in dB. When omitted (the default), an
|
|
876
|
+
* enabled `loudness` stage still throws. When provided and `loudness.enabled`
|
|
877
|
+
* is set, the chain applies this fixed gain per block before the loudness
|
|
878
|
+
* stage's true-peak limiter instead of throwing.
|
|
879
|
+
*/
|
|
880
|
+
loudnessStaticGainDb?: number;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Offline-measured true-peak (dBFS) of the source the static gain was
|
|
884
|
+
* computed for. When provided, the static gain is clamped to
|
|
885
|
+
* `loudness.ceilingDb - loudnessStaticGainPeakDb` so the streaming preview
|
|
886
|
+
* does not drive the loudness limiter harder than the offline chain. When
|
|
887
|
+
* omitted (the default) the static gain is applied verbatim.
|
|
888
|
+
*/
|
|
889
|
+
loudnessStaticGainPeakDb?: number;
|
|
890
|
+
}
|
|
891
|
+
|
|
654
892
|
export interface MasteringChainResult extends MasteringResult {
|
|
655
893
|
stages: string[];
|
|
656
894
|
}
|
|
@@ -914,6 +1152,10 @@ export interface RealtimeVoiceChangerPodConfig {
|
|
|
914
1152
|
reverb_seed: number;
|
|
915
1153
|
limiter_ceiling_db: number;
|
|
916
1154
|
limiter_release_ms: number;
|
|
1155
|
+
/** Non-zero enables the 4x-oversampled inter-sample-peak limiter (default enabled). */
|
|
1156
|
+
limiter_enable_isp_limiter: boolean;
|
|
1157
|
+
/** True-peak ceiling in dBTP applied by the ISP limiter (default -1.0). */
|
|
1158
|
+
limiter_isp_ceiling_dbtp: number;
|
|
917
1159
|
}
|
|
918
1160
|
|
|
919
1161
|
/** Options for {@link StreamingEqualizer.match}. */
|