@libraz/libsonare 1.7.1 → 1.7.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/dist/index.js CHANGED
@@ -4015,6 +4015,20 @@ function projectLoopModeValue(mode) {
4015
4015
  }
4016
4016
 
4017
4017
  // src/project_class.ts
4018
+ function normalizeMidiFxBakeRequest(clipIdOrRequest, configJson) {
4019
+ if (typeof clipIdOrRequest === "number") {
4020
+ return {
4021
+ clipId: clipIdOrRequest,
4022
+ configJson: configJson ?? "",
4023
+ withSourceIndex: false
4024
+ };
4025
+ }
4026
+ return {
4027
+ clipId: clipIdOrRequest.clipId,
4028
+ configJson: clipIdOrRequest.configJson,
4029
+ withSourceIndex: clipIdOrRequest.withSourceIndex ?? false
4030
+ };
4031
+ }
4018
4032
  function validateAssistSidecarUint32(value, field) {
4019
4033
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value > 4294967295) {
4020
4034
  throw new RangeError(`Project.setAssistSidecar: ${field} must be a uint32`);
@@ -4370,12 +4384,23 @@ var Project = class _Project {
4370
4384
  setProgramOnChannel(clipId, group, channel, program, bank = -1) {
4371
4385
  this.native.setProgramOnChannel(clipId, group, channel, program, bank);
4372
4386
  }
4387
+ bakeMidiFx(clipIdOrRequest, configJson) {
4388
+ const request = normalizeMidiFxBakeRequest(clipIdOrRequest, configJson);
4389
+ if (!request.withSourceIndex) {
4390
+ this.native.bakeMidiFx(request.clipId, request.configJson);
4391
+ return {};
4392
+ }
4393
+ return {
4394
+ sourceIndex: this.native.bakeMidiFxWithSourceIndex(request.clipId, request.configJson)
4395
+ };
4396
+ }
4373
4397
  /**
4374
- * Destructively bake a MIDI-FX chain into all stored events. Large clips are
4375
- * drained without truncation; failure leaves the original clip unchanged.
4398
+ * Count the events {@link bakeMidiFx} would produce for this clip and
4399
+ * configuration, without mutating the project. The transform is
4400
+ * deterministic, so the count matches what the bake goes on to produce.
4376
4401
  */
4377
- bakeMidiFx(clipId, configJson) {
4378
- this.native.bakeMidiFx(clipId, configJson);
4402
+ previewMidiFxCount(request) {
4403
+ return this.native.previewMidiFxCount(request.clipId, request.configJson);
4379
4404
  }
4380
4405
  /** Backward alias for {@link bakeMidiFx}. */
4381
4406
  setMidiFx(clipId, configJson) {
@@ -5333,6 +5358,15 @@ var RealtimeEngine = class {
5333
5358
  * Returns `-1` when the track, insert, or name is unknown. (The Python binding
5334
5359
  * raises a `SonareError` for an unknown id where Node/WASM return the `-1`
5335
5360
  * sentinel.)
5361
+ *
5362
+ * This trio is how a mastering processor gets time-varying automation: the
5363
+ * `eq.*`, `dynamics.*`, `saturation.*`, `spectral.*`, `stereo.*`,
5364
+ * `maximizer.*` and `multiband.*` processors are all available as strip
5365
+ * inserts, so placing one on a strip and resolving its parameter here drives
5366
+ * it at audio-block precision, live and offline alike. The whole-signal
5367
+ * stages of the offline mastering chain (`repair.*`, `loudness`, and the
5368
+ * match stages) have no insert form and no automation id: they buffer the
5369
+ * entire signal by construction and do not run on the realtime path.
5336
5370
  */
5337
5371
  resolveTrackInsertAutomationId(trackId, insertIndex, paramName) {
5338
5372
  return this.native.resolveTrackInsertAutomationId(trackId, insertIndex, paramName);
@@ -5460,6 +5494,33 @@ var RealtimeEngine = class {
5460
5494
  processPrepared(numFrames) {
5461
5495
  this.native.processPrepared(numFrames);
5462
5496
  }
5497
+ /**
5498
+ * Allocates the cue-bus counterpart of {@link prepareChannels}. Needed only
5499
+ * when PFL/AFL monitoring must reach a separate output: `processPrepared`
5500
+ * folds the cue bus into the program output, while
5501
+ * {@link processPreparedWithMonitor} keeps the two apart. Call once, off the
5502
+ * audio thread, with at least as many channels as `prepareChannels` got.
5503
+ */
5504
+ prepareMonitorChannels(numChannels, maxFrames) {
5505
+ this.native.prepareMonitorChannels(numChannels, maxFrames);
5506
+ }
5507
+ /**
5508
+ * Returns a Float32Array view onto the persistent cue-bus scratch for one
5509
+ * channel (valid for up to `numFrames`). Read it after
5510
+ * {@link processPreparedWithMonitor}. Re-acquire after WASM memory growth.
5511
+ */
5512
+ getMonitorChannelBuffer(channel, numFrames) {
5513
+ return this.native.getMonitorChannelBuffer(channel, numFrames);
5514
+ }
5515
+ /**
5516
+ * Runs the engine in place over the prepared scratch, writing the cue bus to
5517
+ * the monitor scratch instead of folding it into the program output.
5518
+ * Allocation-free: safe on the AudioWorklet render thread after
5519
+ * `prepareChannels` and `prepareMonitorChannels`.
5520
+ */
5521
+ processPreparedWithMonitor(numFrames) {
5522
+ this.native.processPreparedWithMonitor(numFrames);
5523
+ }
5463
5524
  processWithMonitor(channels) {
5464
5525
  return this.native.processWithMonitor(channels);
5465
5526
  }