@libraz/libsonare 1.2.3 → 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.
Files changed (43) hide show
  1. package/README.md +38 -1
  2. package/dist/index.d.ts +1 -2842
  3. package/dist/index.js +3602 -1934
  4. package/dist/index.js.map +1 -1
  5. package/dist/sonare-rt-module.js +1 -1
  6. package/dist/sonare-rt.js +1 -1
  7. package/dist/sonare-rt.wasm +0 -0
  8. package/dist/sonare.js +1 -1
  9. package/dist/sonare.wasm +0 -0
  10. package/dist/worklet.d.ts +4816 -483
  11. package/dist/worklet.js +747 -440
  12. package/dist/worklet.js.map +1 -1
  13. package/package.json +2 -1
  14. package/src/analysis_helpers.ts +152 -0
  15. package/src/audio.ts +493 -0
  16. package/src/codes.ts +56 -0
  17. package/src/effects_mastering.ts +964 -0
  18. package/src/feature_core.ts +248 -0
  19. package/src/feature_music.ts +419 -0
  20. package/src/feature_pitch.ts +80 -0
  21. package/src/feature_resample.ts +21 -0
  22. package/src/feature_spectral.ts +330 -0
  23. package/src/feature_spectrogram.ts +454 -0
  24. package/src/features.ts +84 -0
  25. package/src/index.ts +341 -4963
  26. package/src/live_audio.ts +45 -0
  27. package/src/metering.ts +380 -0
  28. package/src/mixer.ts +523 -0
  29. package/src/module_state.ts +14 -0
  30. package/src/opfs_clip_pages.ts +188 -0
  31. package/src/project.ts +1614 -0
  32. package/src/public_types.ts +177 -2
  33. package/src/quick_analysis.ts +508 -0
  34. package/src/realtime_engine.ts +667 -0
  35. package/src/realtime_voice_changer.ts +275 -0
  36. package/src/scale.ts +42 -0
  37. package/src/sonare.js.d.ts +302 -4
  38. package/src/stream_analyzer.ts +275 -0
  39. package/src/stream_types.ts +26 -1
  40. package/src/streaming_mixing.ts +18 -0
  41. package/src/streaming_processors.ts +335 -0
  42. package/src/validation.ts +82 -0
  43. package/src/web_midi.ts +367 -0
@@ -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
 
@@ -426,7 +550,20 @@ export interface RoomGeometryOptions {
426
550
  lengthM?: number;
427
551
  widthM?: number;
428
552
  heightM?: number;
553
+ /** Uniform wall absorption, clamped to [0, 0.999] (the back-compat scalar). */
429
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;
430
567
  sourceX?: number;
431
568
  sourceY?: number;
432
569
  sourceZ?: number;
@@ -482,6 +619,15 @@ export interface RoomEstimateResult {
482
619
  export interface RoomMorphOptions extends RoomGeometryOptions {
483
620
  wet?: number;
484
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;
485
631
  }
486
632
 
487
633
  /**
@@ -714,6 +860,35 @@ export interface MasteringChainConfig {
714
860
  };
715
861
  }
716
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
+
717
892
  export interface MasteringChainResult extends MasteringResult {
718
893
  stages: string[];
719
894
  }