@libraz/libsonare 1.5.5 → 1.6.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 (75) hide show
  1. package/README.md +109 -20
  2. package/dist/analysis.d.ts +5730 -0
  3. package/dist/analysis.js +2464 -0
  4. package/dist/analysis.js.map +1 -0
  5. package/dist/index.d.ts +759 -35
  6. package/dist/index.js +904 -209
  7. package/dist/index.js.map +1 -1
  8. package/dist/schemas/realtime-voice-changer-preset-pack.schema.json +27 -0
  9. package/dist/schemas/realtime-voice-changer-preset.schema.json +140 -0
  10. package/dist/sonare-analysis.js +2 -0
  11. package/dist/sonare-analysis.wasm +0 -0
  12. package/dist/sonare.js +1 -1
  13. package/dist/sonare.wasm +0 -0
  14. package/dist/worker.d.ts +65 -0
  15. package/dist/worker.js +707 -0
  16. package/dist/worker.js.map +1 -0
  17. package/dist/worklet.d.ts +574 -86
  18. package/dist/worklet.js +1634 -235
  19. package/dist/worklet.js.map +1 -1
  20. package/package.json +23 -11
  21. package/src/_chain_config.ts +5 -3
  22. package/src/analysis.ts +137 -0
  23. package/src/analysis_helpers.ts +6 -0
  24. package/src/clip_page_streamer.ts +62 -8
  25. package/src/codes.ts +51 -64
  26. package/src/effects_mastering.ts +1 -0
  27. package/src/errors.ts +1 -0
  28. package/src/feature_core.ts +140 -2
  29. package/src/feature_music.ts +17 -2
  30. package/src/feature_pitch.ts +70 -1
  31. package/src/feature_spectral.ts +231 -5
  32. package/src/feature_spectrogram.ts +159 -0
  33. package/src/features.ts +16 -1
  34. package/src/index.ts +101 -7
  35. package/src/mastering_chain.ts +20 -8
  36. package/src/mastering_core.ts +5 -0
  37. package/src/mastering_dynamics.ts +7 -1
  38. package/src/metering.ts +6 -1
  39. package/src/opfs_clip_pages.ts +26 -1
  40. package/src/project.ts +7 -0
  41. package/src/project_class.ts +62 -8
  42. package/src/project_internal.ts +24 -29
  43. package/src/project_types.ts +69 -10
  44. package/src/public_types.ts +68 -0
  45. package/src/public_types_mastering.ts +22 -0
  46. package/src/public_types_mixing.ts +11 -2
  47. package/src/public_types_music.ts +9 -0
  48. package/src/public_types_spectral.ts +33 -0
  49. package/src/quick_analysis.ts +25 -7
  50. package/src/realtime_engine.ts +153 -3
  51. package/src/realtime_voice_changer.ts +51 -77
  52. package/src/sonare-analysis.js.d.ts +8 -0
  53. package/src/sonare.js.d.ts +276 -6
  54. package/src/streaming_processors.ts +15 -0
  55. package/src/web_midi.ts +36 -4
  56. package/src/worker.ts +196 -0
  57. package/src/worker_client.ts +352 -0
  58. package/src/worker_protocol.ts +59 -0
  59. package/src/worklet/engine-automation.ts +2 -1
  60. package/src/worklet/engine-capture-facade.ts +13 -4
  61. package/src/worklet/engine-clips.ts +12 -3
  62. package/src/worklet/engine-node.ts +212 -4
  63. package/src/worklet/engine-offline.ts +7 -2
  64. package/src/worklet/engine-parameter-facade.ts +26 -5
  65. package/src/worklet/engine-processor.ts +383 -42
  66. package/src/worklet/engine-register.ts +8 -0
  67. package/src/worklet/engine-strips.ts +17 -1
  68. package/src/worklet/engine-sync.ts +2 -6
  69. package/src/worklet/engine-tempo-facade.ts +8 -6
  70. package/src/worklet/engine.ts +380 -13
  71. package/src/worklet/guards.ts +22 -1
  72. package/src/worklet/messages.ts +125 -7
  73. package/src/worklet/protocol.ts +301 -17
  74. package/src/worklet/voice-changer-processor.ts +12 -15
  75. package/src/worklet.ts +20 -1
@@ -19,6 +19,7 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
19
19
  // audio-thread process() never crosses an allocation boundary.
20
20
  private monoInput: Float32Array;
21
21
  private monoOutput: Float32Array;
22
+ private bufferGeneration: number;
22
23
  // Planar heap-backed views (one Float32Array per channel) used by the
23
24
  // multi-channel path. AudioWorklet inputs/outputs are already planar
24
25
  // Float32Arrays, so this avoids the per-sample interleave/deinterleave
@@ -37,6 +38,7 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
37
38
  // process() than blockSize, we clamp (see ensure*Capacity).
38
39
  this.monoInput = this.changer.getMonoInputBuffer(this.blockSize);
39
40
  this.monoOutput = this.changer.getMonoOutputBuffer(this.blockSize);
41
+ this.bufferGeneration = this.changer.bufferGeneration();
40
42
  this.planarChannels = [];
41
43
  if (this.channelCount > 1) {
42
44
  for (let ch = 0; ch < this.channelCount; ch++) {
@@ -46,22 +48,16 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
46
48
  }
47
49
 
48
50
  /**
49
- * Handles a control-plane message from the main thread. Runs on the
50
- * AudioWorklet global scope but OUTSIDE of `process()` (i.e. outside the
51
- * realtime audio callback), so it is safe to perform JSON parsing and
52
- * DSP coefficient recomputation here. `setConfig` MUST NOT be deferred
53
- * into `process()` because that would block the audio thread for longer
54
- * than one render quantum (e.g. 128 samples / 44.1 kHz = ~2.9 ms).
51
+ * Handles a control-plane message from the main thread. AudioWorklet port
52
+ * handlers run on the same audio rendering thread as `process()`: this path
53
+ * therefore accepts only a pre-normalized POD and never parses JSON.
55
54
  */
56
55
  receiveMessage(message: SonareRealtimeVoiceChangerMessage): void {
57
56
  if (this.destroyed) {
58
57
  return;
59
58
  }
60
59
  if (message.type === 'setConfig') {
61
- // Apply synchronously on the message-handler thread. `setConfig` may
62
- // allocate and parse JSON internally; doing it here keeps `process()`
63
- // realtime-safe.
64
- this.changer.setConfig(message.preset);
60
+ this.changer.setPodConfig(message.config);
65
61
  } else if (message.type === 'reset') {
66
62
  this.changer.reset();
67
63
  } else if (message.type === 'destroy') {
@@ -79,7 +75,10 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
79
75
  // module is built ALLOW_MEMORY_GROWTH). Re-acquire them if detached
80
76
  // (byteLength === 0) before touching them; in the common no-growth case this
81
77
  // is a cheap branch with no allocation.
82
- if (this.monoInput.byteLength === 0) {
78
+ if (
79
+ this.bufferGeneration !== this.changer.bufferGeneration() ||
80
+ this.monoInput.byteLength === 0
81
+ ) {
83
82
  this.reacquireBuffers();
84
83
  }
85
84
 
@@ -100,10 +99,7 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
100
99
  } else {
101
100
  this.monoInput.fill(0, 0, frames);
102
101
  }
103
- this.changer.processMonoInto(
104
- this.monoInput.subarray(0, frames),
105
- this.monoOutput.subarray(0, frames),
106
- );
102
+ this.changer.processPreparedMono(frames);
107
103
  output[0].set(this.monoOutput.subarray(0, frames));
108
104
  return true;
109
105
  }
@@ -156,6 +152,7 @@ export class SonareRealtimeVoiceChangerWorkletProcessor {
156
152
  this.planarChannels[ch] = this.changer.getPlanarChannelBuffer(ch, this.blockSize);
157
153
  }
158
154
  }
155
+ this.bufferGeneration = this.changer.bufferGeneration();
159
156
  }
160
157
 
161
158
  /**
package/src/worklet.ts CHANGED
@@ -4,19 +4,21 @@
4
4
  // AudioWorkletGlobalScope cannot resolve sibling chunks), so the public surface
5
5
  // is unchanged.
6
6
 
7
+ export type { OpfsClipStream, OpfsClipStreamOptions } from './clip_page_streamer';
8
+ export { attachOpfsClipStream } from './clip_page_streamer';
7
9
  // With code-splitting disabled, the worklet bundle carries its own copy of the
8
10
  // module singleton. Re-export the lifecycle so that realm can initialize its
9
11
  // own wasm instance, independent of the main-thread `index` module.
10
12
  export { init, isInitialized } from './index';
11
13
  export { SonareEngine } from './worklet/engine';
12
14
  export { SonareRealtimeEngineNode } from './worklet/engine-node';
13
-
14
15
  export type { SonareEngineOptions } from './worklet/engine-options';
15
16
  export { SonareRealtimeEngineWorkletProcessor } from './worklet/engine-processor';
16
17
  export { registerSonareRealtimeEngineWorkletProcessor } from './worklet/engine-register';
17
18
  export type {
18
19
  SonareEngineCaptureRequestMessage,
19
20
  SonareEngineCaptureResponseMessage,
21
+ SonareEngineClipPageRequestMessage,
20
22
  SonareEngineSyncAutomationMessage,
21
23
  SonareEngineSyncBuiltinInstrumentMessage,
22
24
  SonareEngineSyncCaptureMessage,
@@ -61,8 +63,10 @@ export {
61
63
  SonareWorkletProcessor,
62
64
  } from './worklet/mixer-processor';
63
65
  export {
66
+ createSonareClipPageRequestRingBuffer,
64
67
  createSonareEngineCommandRingBuffer,
65
68
  createSonareEngineTelemetryRingBuffer,
69
+ createSonareExternalMidiRingBuffer,
66
70
  createSonareMeterRingBuffer,
67
71
  createSonareScopeRingBuffer,
68
72
  createSonareSpectrumRingBuffer,
@@ -70,18 +74,29 @@ export {
70
74
  encodeFrameHi,
71
75
  encodeFrameLo,
72
76
  popSonareEngineCommandRingBuffer,
77
+ pushSonareClipPageRequestRingBuffer,
73
78
  pushSonareEngineCommandRingBuffer,
79
+ pushSonareExternalMidiRingBuffer,
80
+ readSonareClipPageRequestRingBuffer,
74
81
  readSonareEngineTelemetryRingBuffer,
82
+ readSonareExternalMidiRingBuffer,
75
83
  readSonareMeterRingBuffer,
76
84
  readSonareScopeRingBuffer,
77
85
  readSonareSpectrumRingBuffer,
86
+ SONARE_CLIP_PAGE_REQUEST_RING_HEADER_INTS,
87
+ SONARE_CLIP_PAGE_REQUEST_RING_RECORD_UINT32S,
78
88
  SONARE_ENGINE_COMMAND_RECORD_BYTES,
79
89
  SONARE_ENGINE_RING_HEADER_INTS,
80
90
  SONARE_ENGINE_TELEMETRY_RECORD_BYTES,
91
+ SONARE_EXTERNAL_MIDI_RING_HEADER_INTS,
92
+ SONARE_EXTERNAL_MIDI_RING_RECORD_UINT32S,
81
93
  SONARE_METER_RING_HEADER_INTS,
82
94
  SONARE_METER_RING_RECORD_FLOATS,
83
95
  SONARE_SCOPE_RING_HEADER_INTS,
84
96
  SONARE_SPECTRUM_RING_HEADER_INTS,
97
+ type SonareClipPageRequest,
98
+ type SonareClipPageRequestRingBuffer,
99
+ type SonareClipPageRequestRingReadResult,
85
100
  type SonareEngineCommandRecord,
86
101
  type SonareEngineCommandRingBuffer,
87
102
  SonareEngineCommandType,
@@ -90,6 +105,8 @@ export {
90
105
  type SonareEngineTelemetryRingBuffer,
91
106
  type SonareEngineTelemetryRingReadResult,
92
107
  SonareEngineTelemetryType,
108
+ type SonareExternalMidiRingBuffer,
109
+ type SonareExternalMidiRingReadResult,
93
110
  type SonareMeterRingBuffer,
94
111
  type SonareMeterRingReadResult,
95
112
  type SonareScopeRingBuffer,
@@ -99,8 +116,10 @@ export {
99
116
  type SonareWorkletMeterSnapshot,
100
117
  type SonareWorkletScopeSnapshot,
101
118
  type SonareWorkletSpectrumSnapshot,
119
+ sonareClipPageRequestRingBufferByteLength,
102
120
  sonareEngineCommandRingBufferByteLength,
103
121
  sonareEngineTelemetryRingBufferByteLength,
122
+ sonareExternalMidiRingBufferByteLength,
104
123
  sonareMeterRingBufferByteLength,
105
124
  sonareScopeRingBufferByteLength,
106
125
  sonareSpectrumRingBufferByteLength,