@libraz/libsonare 1.7.0 → 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/README.md +33 -0
- package/dist/analysis.d.ts +55 -3
- package/dist/analysis.js +10 -0
- package/dist/analysis.js.map +1 -1
- package/dist/index.d.ts +368 -199
- package/dist/index.js +111 -6
- package/dist/index.js.map +1 -1
- package/dist/sonare-analysis.js +1 -1
- package/dist/sonare-analysis.wasm +0 -0
- package/dist/sonare.js +1 -1
- package/dist/sonare.wasm +0 -0
- package/dist/worker.js.map +1 -1
- package/dist/worklet.d.ts +379 -9
- package/dist/worklet.js +174 -13
- package/dist/worklet.js.map +1 -1
- package/package.json +1 -1
- package/src/_chain_config.ts +6 -1
- package/src/effects_mastering.ts +5 -0
- package/src/effects_transform.ts +23 -12
- package/src/index.ts +10 -0
- package/src/mastering_core.ts +70 -0
- package/src/metering.ts +18 -0
- package/src/project.ts +3 -0
- package/src/project_class.ts +52 -2
- package/src/project_internal.ts +2 -0
- package/src/project_types.ts +39 -8
- package/src/public_types_mastering.ts +9 -0
- package/src/public_types_spectral.ts +16 -2
- package/src/realtime_engine.ts +39 -0
- package/src/sonare.js.d.ts +26 -0
- package/src/streaming_processors.ts +18 -0
- package/src/worklet/engine-node.ts +7 -2
- package/src/worklet/engine-processor.ts +59 -12
- package/src/worklet/messages.ts +12 -0
- package/src/worklet.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -227,6 +227,13 @@ function assertInterleavedSamples(fnName, samples, channels, validate) {
|
|
|
227
227
|
function requireModule() {
|
|
228
228
|
return getSonareModule();
|
|
229
229
|
}
|
|
230
|
+
function toVoicedFloat32(voiced) {
|
|
231
|
+
const out = new Float32Array(voiced.length);
|
|
232
|
+
for (let index = 0; index < voiced.length; index += 1) {
|
|
233
|
+
out[index] = voiced[index] ? 1 : 0;
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
}
|
|
230
237
|
function resolveEffectFftOptions(fnName, nFft, hopLength) {
|
|
231
238
|
const resolvedNFft = nFft === void 0 ? 2048 : nFft;
|
|
232
239
|
const resolvedHopLength = hopLength === void 0 ? 512 : hopLength;
|
|
@@ -374,7 +381,7 @@ function pitchCorrectToMidiTimevarying(samples, f0Hz, targetMidi, sampleRate = 2
|
|
|
374
381
|
if (request.voicedProb && request.voicedProb.length !== request.f0Hz.length) {
|
|
375
382
|
throw new RangeError("pitchCorrectToMidiTimevarying: voicedProb length must match f0Hz length");
|
|
376
383
|
}
|
|
377
|
-
const voicedF32 = request.voiced ?
|
|
384
|
+
const voicedF32 = request.voiced ? toVoicedFloat32(request.voiced) : void 0;
|
|
378
385
|
return requireModule().pitchCorrectToMidiTimevarying(
|
|
379
386
|
request.samples,
|
|
380
387
|
request.sampleRate ?? 22050,
|
|
@@ -396,7 +403,7 @@ function pitchCorrectTimevarying(samples, f0Hz, sampleRate = 22050, hopLength =
|
|
|
396
403
|
}
|
|
397
404
|
const nativeOptions = {
|
|
398
405
|
...request,
|
|
399
|
-
voiced: request.voiced ?
|
|
406
|
+
voiced: request.voiced ? toVoicedFloat32(request.voiced) : void 0
|
|
400
407
|
};
|
|
401
408
|
return requireModule().pitchCorrectTimevarying(
|
|
402
409
|
request.samples,
|
|
@@ -856,6 +863,30 @@ function masteringStreamingPreview(samples, sampleRate = 22050, platforms = [])
|
|
|
856
863
|
request.platforms ?? []
|
|
857
864
|
);
|
|
858
865
|
}
|
|
866
|
+
function masteringAssistantSuggestStereo(request) {
|
|
867
|
+
return requireModule4().masteringAssistantSuggestStereo(
|
|
868
|
+
request.left,
|
|
869
|
+
request.right,
|
|
870
|
+
request.sampleRate ?? 22050,
|
|
871
|
+
request.params ?? {}
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
function masteringAudioProfileStereo(request) {
|
|
875
|
+
return requireModule4().masteringAudioProfileStereo(
|
|
876
|
+
request.left,
|
|
877
|
+
request.right,
|
|
878
|
+
request.sampleRate ?? 22050,
|
|
879
|
+
request.params ?? {}
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
function masteringStreamingPreviewStereo(request) {
|
|
883
|
+
return requireModule4().masteringStreamingPreviewStereo(
|
|
884
|
+
request.left,
|
|
885
|
+
request.right,
|
|
886
|
+
request.sampleRate ?? 22050,
|
|
887
|
+
request.platforms ?? []
|
|
888
|
+
);
|
|
889
|
+
}
|
|
859
890
|
|
|
860
891
|
// src/mastering_dynamics.ts
|
|
861
892
|
function requireModule5() {
|
|
@@ -3740,6 +3771,15 @@ function meteringCrestFactorDb(samples, sampleRate = 22050, options = {}) {
|
|
|
3740
3771
|
assertSamples("meteringCrestFactorDb", request.samples, request.validate !== false);
|
|
3741
3772
|
return requireModule15().meteringCrestFactorDb(request.samples, request.sampleRate ?? 22050);
|
|
3742
3773
|
}
|
|
3774
|
+
function meteringCrestFactorDbStereo(request) {
|
|
3775
|
+
assertSamples("meteringCrestFactorDbStereo", request.left, request.validate !== false);
|
|
3776
|
+
assertSamples("meteringCrestFactorDbStereo", request.right, request.validate !== false);
|
|
3777
|
+
return requireModule15().meteringCrestFactorDbStereo(
|
|
3778
|
+
request.left,
|
|
3779
|
+
request.right,
|
|
3780
|
+
request.sampleRate ?? 22050
|
|
3781
|
+
);
|
|
3782
|
+
}
|
|
3743
3783
|
function meteringDcOffset(samples, sampleRate = 22050, options = {}) {
|
|
3744
3784
|
const request = samples instanceof Float32Array ? { samples, sampleRate, ...options } : samples;
|
|
3745
3785
|
assertSamples("meteringDcOffset", request.samples, request.validate !== false);
|
|
@@ -3975,6 +4015,20 @@ function projectLoopModeValue(mode) {
|
|
|
3975
4015
|
}
|
|
3976
4016
|
|
|
3977
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
|
+
}
|
|
3978
4032
|
function validateAssistSidecarUint32(value, field) {
|
|
3979
4033
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value > 4294967295) {
|
|
3980
4034
|
throw new RangeError(`Project.setAssistSidecar: ${field} must be a uint32`);
|
|
@@ -4330,12 +4384,23 @@ var Project = class _Project {
|
|
|
4330
4384
|
setProgramOnChannel(clipId, group, channel, program, bank = -1) {
|
|
4331
4385
|
this.native.setProgramOnChannel(clipId, group, channel, program, bank);
|
|
4332
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
|
+
}
|
|
4333
4397
|
/**
|
|
4334
|
-
*
|
|
4335
|
-
*
|
|
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.
|
|
4336
4401
|
*/
|
|
4337
|
-
|
|
4338
|
-
this.native.
|
|
4402
|
+
previewMidiFxCount(request) {
|
|
4403
|
+
return this.native.previewMidiFxCount(request.clipId, request.configJson);
|
|
4339
4404
|
}
|
|
4340
4405
|
/** Backward alias for {@link bakeMidiFx}. */
|
|
4341
4406
|
setMidiFx(clipId, configJson) {
|
|
@@ -5293,6 +5358,15 @@ var RealtimeEngine = class {
|
|
|
5293
5358
|
* Returns `-1` when the track, insert, or name is unknown. (The Python binding
|
|
5294
5359
|
* raises a `SonareError` for an unknown id where Node/WASM return the `-1`
|
|
5295
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.
|
|
5296
5370
|
*/
|
|
5297
5371
|
resolveTrackInsertAutomationId(trackId, insertIndex, paramName) {
|
|
5298
5372
|
return this.native.resolveTrackInsertAutomationId(trackId, insertIndex, paramName);
|
|
@@ -5420,6 +5494,33 @@ var RealtimeEngine = class {
|
|
|
5420
5494
|
processPrepared(numFrames) {
|
|
5421
5495
|
this.native.processPrepared(numFrames);
|
|
5422
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
|
+
}
|
|
5423
5524
|
processWithMonitor(channels) {
|
|
5424
5525
|
return this.native.processWithMonitor(channels);
|
|
5425
5526
|
}
|
|
@@ -7303,7 +7404,9 @@ export {
|
|
|
7303
7404
|
masterAudioWithProgress,
|
|
7304
7405
|
mastering,
|
|
7305
7406
|
masteringAssistantSuggest,
|
|
7407
|
+
masteringAssistantSuggestStereo,
|
|
7306
7408
|
masteringAudioProfile,
|
|
7409
|
+
masteringAudioProfileStereo,
|
|
7307
7410
|
masteringChain,
|
|
7308
7411
|
masteringChainStereo,
|
|
7309
7412
|
masteringChainStereoWithProgress,
|
|
@@ -7333,12 +7436,14 @@ export {
|
|
|
7333
7436
|
masteringStereoAnalysisNames,
|
|
7334
7437
|
masteringStereoAnalyze,
|
|
7335
7438
|
masteringStreamingPreview,
|
|
7439
|
+
masteringStreamingPreviewStereo,
|
|
7336
7440
|
melDelta,
|
|
7337
7441
|
melSpectrogram,
|
|
7338
7442
|
melToAudio,
|
|
7339
7443
|
melToHz,
|
|
7340
7444
|
melToStft,
|
|
7341
7445
|
meteringCrestFactorDb,
|
|
7446
|
+
meteringCrestFactorDbStereo,
|
|
7342
7447
|
meteringDcOffset,
|
|
7343
7448
|
meteringDetectClipping,
|
|
7344
7449
|
meteringDynamicRange,
|