@libraz/libsonare 1.6.0 → 1.7.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 (47) hide show
  1. package/README.md +2 -2
  2. package/dist/analysis.d.ts +88 -9
  3. package/dist/analysis.js +152 -42
  4. package/dist/analysis.js.map +1 -1
  5. package/dist/index.d.ts +129 -24
  6. package/dist/index.js +455 -140
  7. package/dist/index.js.map +1 -1
  8. package/dist/schemas/realtime-voice-changer-preset.schema.json +2 -2
  9. package/dist/sonare-analysis.js +1 -1
  10. package/dist/sonare-analysis.wasm +0 -0
  11. package/dist/sonare.js +1 -1
  12. package/dist/sonare.wasm +0 -0
  13. package/dist/worker.js +56 -29
  14. package/dist/worker.js.map +1 -1
  15. package/dist/worklet.d.ts +62 -10
  16. package/dist/worklet.js +193 -42
  17. package/dist/worklet.js.map +1 -1
  18. package/package.json +3 -3
  19. package/src/analysis_helpers.ts +34 -29
  20. package/src/audio.ts +7 -2
  21. package/src/codes.ts +47 -11
  22. package/src/effects_transform.ts +179 -10
  23. package/src/feature_music.ts +8 -1
  24. package/src/feature_spectral.ts +64 -2
  25. package/src/feature_spectrogram.ts +44 -3
  26. package/src/index.ts +21 -3
  27. package/src/mixer.ts +3 -3
  28. package/src/project.ts +6 -0
  29. package/src/project_class.ts +143 -16
  30. package/src/project_internal.ts +14 -5
  31. package/src/project_types.ts +45 -1
  32. package/src/public_types_mixing.ts +16 -0
  33. package/src/public_types_realtime.ts +23 -5
  34. package/src/quick_analysis.ts +21 -3
  35. package/src/realtime_engine.ts +14 -3
  36. package/src/sonare.js.d.ts +64 -0
  37. package/src/stream_analyzer.ts +6 -1
  38. package/src/web_midi.ts +10 -7
  39. package/src/worklet/engine-node.ts +54 -19
  40. package/src/worklet/engine-parameter-facade.ts +30 -1
  41. package/src/worklet/engine-processor.ts +52 -20
  42. package/src/worklet/engine-register.ts +1 -1
  43. package/src/worklet/engine-strips.ts +2 -2
  44. package/src/worklet/engine.ts +10 -0
  45. package/src/worklet/guards.ts +99 -7
  46. package/src/worklet/messages.ts +41 -1
  47. package/src/worklet/protocol.ts +4 -0
package/dist/worker.js CHANGED
@@ -284,6 +284,36 @@ function masterAudioStereo(left, right = void 0, sampleRate = 22050, presetName
284
284
  );
285
285
  }
286
286
 
287
+ // src/codes.ts
288
+ function resolveOrdinalInRange(value, min, max, enumName) {
289
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max) {
290
+ throw new RangeError(`Invalid ${enumName}: ${String(value)}`);
291
+ }
292
+ return value;
293
+ }
294
+ function resolveEnumOrdinal(value, values, enumName) {
295
+ if (typeof value === "number") {
296
+ const ordinals = Object.values(values);
297
+ const ordinal = resolveOrdinalInRange(
298
+ value,
299
+ Math.min(...ordinals),
300
+ Math.max(...ordinals),
301
+ enumName
302
+ );
303
+ if (!ordinals.includes(ordinal)) {
304
+ throw new RangeError(`Invalid ${enumName}: ${String(value)}`);
305
+ }
306
+ return ordinal;
307
+ }
308
+ if (typeof value === "string") {
309
+ const ordinal = values[value];
310
+ if (ordinal !== void 0) {
311
+ return ordinal;
312
+ }
313
+ }
314
+ throw new RangeError(`Invalid ${enumName}: ${String(value)}`);
315
+ }
316
+
287
317
  // src/public_types_music.ts
288
318
  var PitchClass = {
289
319
  C: 0,
@@ -336,6 +366,30 @@ var PITCH_CLASS_NAMES = [
336
366
  function pitchClassName(value) {
337
367
  return PITCH_CLASS_NAMES[value] ?? "C";
338
368
  }
369
+ var KEY_MODE_VALUES = {
370
+ major: Mode.Major,
371
+ minor: Mode.Minor,
372
+ dorian: Mode.Dorian,
373
+ phrygian: Mode.Phrygian,
374
+ lydian: Mode.Lydian,
375
+ mixolydian: Mode.Mixolydian,
376
+ locrian: Mode.Locrian
377
+ };
378
+ var KEY_PROFILE_VALUES = {
379
+ ks: KeyProfile.KrumhanslSchmuckler,
380
+ krumhansl: KeyProfile.KrumhanslSchmuckler,
381
+ temperley: KeyProfile.Temperley,
382
+ shaath: KeyProfile.Shaath,
383
+ keyfinder: KeyProfile.Shaath,
384
+ "faraldo-edmt": KeyProfile.FaraldoEDMT,
385
+ edmt: KeyProfile.FaraldoEDMT,
386
+ "faraldo-edma": KeyProfile.FaraldoEDMA,
387
+ edma: KeyProfile.FaraldoEDMA,
388
+ "faraldo-edmm": KeyProfile.FaraldoEDMM,
389
+ edmm: KeyProfile.FaraldoEDMM,
390
+ "bellman-budge": KeyProfile.BellmanBudge,
391
+ bellman: KeyProfile.BellmanBudge
392
+ };
339
393
  function keyModeValues(modes) {
340
394
  if (!modes) {
341
395
  return [];
@@ -354,40 +408,13 @@ function keyModeValues(modes) {
354
408
  Mode.Locrian
355
409
  ];
356
410
  }
357
- const names = {
358
- major: Mode.Major,
359
- minor: Mode.Minor,
360
- dorian: Mode.Dorian,
361
- phrygian: Mode.Phrygian,
362
- lydian: Mode.Lydian,
363
- mixolydian: Mode.Mixolydian,
364
- locrian: Mode.Locrian
365
- };
366
- return modes.map((mode) => typeof mode === "number" ? mode : names[mode]);
411
+ return modes.map((mode) => resolveEnumOrdinal(mode, KEY_MODE_VALUES, "key mode"));
367
412
  }
368
413
  function keyProfileValue(profile) {
369
414
  if (profile === void 0) {
370
415
  return -1;
371
416
  }
372
- if (typeof profile === "number") {
373
- return profile;
374
- }
375
- const names = {
376
- ks: KeyProfile.KrumhanslSchmuckler,
377
- krumhansl: KeyProfile.KrumhanslSchmuckler,
378
- temperley: KeyProfile.Temperley,
379
- shaath: KeyProfile.Shaath,
380
- keyfinder: KeyProfile.Shaath,
381
- "faraldo-edmt": KeyProfile.FaraldoEDMT,
382
- edmt: KeyProfile.FaraldoEDMT,
383
- "faraldo-edma": KeyProfile.FaraldoEDMA,
384
- edma: KeyProfile.FaraldoEDMA,
385
- "faraldo-edmm": KeyProfile.FaraldoEDMM,
386
- edmm: KeyProfile.FaraldoEDMM,
387
- "bellman-budge": KeyProfile.BellmanBudge,
388
- bellman: KeyProfile.BellmanBudge
389
- };
390
- return names[profile];
417
+ return resolveEnumOrdinal(profile, KEY_PROFILE_VALUES, "key profile");
391
418
  }
392
419
  function convertChordAnalysisResult(wasm) {
393
420
  return {