@libraz/libsonare 1.7.2 → 1.8.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.
- package/NOTICE +178 -0
- package/README.md +26 -203
- package/dist/_chain_config.d.ts +14 -0
- package/dist/_chain_config.d.ts.map +1 -0
- package/dist/_effects_common.d.ts +6 -0
- package/dist/_effects_common.d.ts.map +1 -0
- package/dist/_feature_validation.d.ts +8 -0
- package/dist/_feature_validation.d.ts.map +1 -0
- package/dist/_fft_options.d.ts +24 -0
- package/dist/_fft_options.d.ts.map +1 -0
- package/dist/align_take.d.ts +50 -0
- package/dist/align_take.d.ts.map +1 -0
- package/dist/analysis.d.ts +29 -5840
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +873 -722
- package/dist/analysis.js.map +1 -1
- package/dist/analysis_helpers.d.ts +9 -0
- package/dist/analysis_helpers.d.ts.map +1 -0
- package/dist/audio.d.ts +163 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/clip_page_streamer.d.ts +133 -0
- package/dist/clip_page_streamer.d.ts.map +1 -0
- package/dist/codes.d.ts +44 -0
- package/dist/codes.d.ts.map +1 -0
- package/dist/effects_mastering.d.ts +23 -0
- package/dist/effects_mastering.d.ts.map +1 -0
- package/dist/effects_note_ops.d.ts +477 -0
- package/dist/effects_note_ops.d.ts.map +1 -0
- package/dist/effects_percussive.d.ts +185 -0
- package/dist/effects_percussive.d.ts.map +1 -0
- package/dist/effects_separation.d.ts +65 -0
- package/dist/effects_separation.d.ts.map +1 -0
- package/dist/effects_spectral.d.ts +28 -0
- package/dist/effects_spectral.d.ts.map +1 -0
- package/dist/effects_timepitch.d.ts +129 -0
- package/dist/effects_timepitch.d.ts.map +1 -0
- package/dist/effects_voice_change.d.ts +53 -0
- package/dist/effects_voice_change.d.ts.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/feature_core.d.ts +341 -0
- package/dist/feature_core.d.ts.map +1 -0
- package/dist/feature_decompose.d.ts +278 -0
- package/dist/feature_decompose.d.ts.map +1 -0
- package/dist/feature_inverse.d.ts +128 -0
- package/dist/feature_inverse.d.ts.map +1 -0
- package/dist/feature_loudness.d.ts +66 -0
- package/dist/feature_loudness.d.ts.map +1 -0
- package/dist/feature_music.d.ts +307 -0
- package/dist/feature_music.d.ts.map +1 -0
- package/dist/feature_pitch.d.ts +108 -0
- package/dist/feature_pitch.d.ts.map +1 -0
- package/dist/feature_resample.d.ts +16 -0
- package/dist/feature_resample.d.ts.map +1 -0
- package/dist/feature_spectral.d.ts +137 -0
- package/dist/feature_spectral.d.ts.map +1 -0
- package/dist/feature_spectrogram.d.ts +198 -0
- package/dist/feature_spectrogram.d.ts.map +1 -0
- package/dist/features.d.ts +10 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/hrtf/default.shrf +0 -0
- package/dist/index.d.ts +74 -7431
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3758 -1362
- package/dist/index.js.map +1 -1
- package/dist/instrument_types.d.ts +517 -0
- package/dist/instrument_types.d.ts.map +1 -0
- package/dist/live_audio.d.ts +35 -0
- package/dist/live_audio.d.ts.map +1 -0
- package/dist/mastering_chain.d.ts +213 -0
- package/dist/mastering_chain.d.ts.map +1 -0
- package/dist/mastering_core.d.ts +457 -0
- package/dist/mastering_core.d.ts.map +1 -0
- package/dist/mastering_dynamics.d.ts +80 -0
- package/dist/mastering_dynamics.d.ts.map +1 -0
- package/dist/metering.d.ts +287 -0
- package/dist/metering.d.ts.map +1 -0
- package/dist/mixer.d.ts +464 -0
- package/dist/mixer.d.ts.map +1 -0
- package/dist/mixing_assistant.d.ts +62 -0
- package/dist/mixing_assistant.d.ts.map +1 -0
- package/dist/mixing_oneshot.d.ts +40 -0
- package/dist/mixing_oneshot.d.ts.map +1 -0
- package/dist/module_state.d.ts +15 -0
- package/dist/module_state.d.ts.map +1 -0
- package/dist/opfs_clip_pages.d.ts +28 -0
- package/dist/opfs_clip_pages.d.ts.map +1 -0
- package/dist/playback_renderer.d.ts +128 -0
- package/dist/playback_renderer.d.ts.map +1 -0
- package/dist/polyphony.d.ts +202 -0
- package/dist/polyphony.d.ts.map +1 -0
- package/dist/project.d.ts +8 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project_class.d.ts +562 -0
- package/dist/project_class.d.ts.map +1 -0
- package/dist/project_internal.d.ts +194 -0
- package/dist/project_internal.d.ts.map +1 -0
- package/dist/project_synth.d.ts +74 -0
- package/dist/project_synth.d.ts.map +1 -0
- package/dist/project_types.d.ts +652 -0
- package/dist/project_types.d.ts.map +1 -0
- package/dist/public_types.d.ts +185 -0
- package/dist/public_types.d.ts.map +1 -0
- package/dist/public_types_acoustic.d.ts +215 -0
- package/dist/public_types_acoustic.d.ts.map +1 -0
- package/dist/public_types_mastering.d.ts +510 -0
- package/dist/public_types_mastering.d.ts.map +1 -0
- package/dist/public_types_mixing.d.ts +436 -0
- package/dist/public_types_mixing.d.ts.map +1 -0
- package/dist/public_types_music.d.ts +619 -0
- package/dist/public_types_music.d.ts.map +1 -0
- package/dist/public_types_playback.d.ts +164 -0
- package/dist/public_types_playback.d.ts.map +1 -0
- package/dist/public_types_realtime.d.ts +174 -0
- package/dist/public_types_realtime.d.ts.map +1 -0
- package/dist/public_types_repair.d.ts +424 -0
- package/dist/public_types_repair.d.ts.map +1 -0
- package/dist/public_types_spectral.d.ts +697 -0
- package/dist/public_types_spectral.d.ts.map +1 -0
- package/dist/quick_analysis.d.ts +445 -0
- package/dist/quick_analysis.d.ts.map +1 -0
- package/dist/realtime_engine.d.ts +850 -0
- package/dist/realtime_engine.d.ts.map +1 -0
- package/dist/realtime_voice_changer.d.ts +158 -0
- package/dist/realtime_voice_changer.d.ts.map +1 -0
- package/dist/repair_dereverb.d.ts +187 -0
- package/dist/repair_dereverb.d.ts.map +1 -0
- package/dist/repair_impulsive.d.ts +186 -0
- package/dist/repair_impulsive.d.ts.map +1 -0
- package/dist/repair_noise.d.ts +239 -0
- package/dist/repair_noise.d.ts.map +1 -0
- package/dist/repair_trim.d.ts +123 -0
- package/dist/repair_trim.d.ts.map +1 -0
- package/dist/sample_bank.d.ts +84 -0
- package/dist/sample_bank.d.ts.map +1 -0
- package/dist/scale.d.ts +10 -0
- package/dist/scale.d.ts.map +1 -0
- package/dist/schemas/mixer-scene.schema.json +393 -0
- package/dist/schemas/playback-renderer-config.schema.json +392 -0
- package/dist/sonare-analysis.d.ts +8 -0
- package/dist/sonare-analysis.js +2 -2
- package/dist/sonare-analysis.wasm +0 -0
- package/dist/sonare.d.ts +3909 -0
- package/dist/sonare.js +2 -2
- package/dist/sonare.wasm +0 -0
- package/dist/stream_analyzer.d.ts +163 -0
- package/dist/stream_analyzer.d.ts.map +1 -0
- package/dist/stream_types.d.ts +214 -0
- package/dist/stream_types.d.ts.map +1 -0
- package/dist/streaming_mixing.d.ts +6 -0
- package/dist/streaming_mixing.d.ts.map +1 -0
- package/dist/streaming_processors.d.ts +335 -0
- package/dist/streaming_processors.d.ts.map +1 -0
- package/dist/transcribe.d.ts +77 -0
- package/dist/transcribe.d.ts.map +1 -0
- package/dist/validation.d.ts +140 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/web_midi.d.ts +77 -0
- package/dist/web_midi.d.ts.map +1 -0
- package/dist/worker.d.ts +5 -48
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +94 -41
- package/dist/worker.js.map +1 -1
- package/dist/worker_client.d.ts +96 -0
- package/dist/worker_client.d.ts.map +1 -0
- package/dist/worker_protocol.d.ts +43 -0
- package/dist/worker_protocol.d.ts.map +1 -0
- package/dist/worklet/audio_types.d.ts +21 -0
- package/dist/worklet/audio_types.d.ts.map +1 -0
- package/dist/worklet/engine-automation.d.ts +29 -0
- package/dist/worklet/engine-automation.d.ts.map +1 -0
- package/dist/worklet/engine-capture-facade.d.ts +35 -0
- package/dist/worklet/engine-capture-facade.d.ts.map +1 -0
- package/dist/worklet/engine-clips.d.ts +23 -0
- package/dist/worklet/engine-clips.d.ts.map +1 -0
- package/dist/worklet/engine-markers.d.ts +40 -0
- package/dist/worklet/engine-markers.d.ts.map +1 -0
- package/dist/worklet/engine-mixer-facade.d.ts +128 -0
- package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
- package/dist/worklet/engine-node.d.ts +81 -0
- package/dist/worklet/engine-node.d.ts.map +1 -0
- package/dist/worklet/engine-offline.d.ts +81 -0
- package/dist/worklet/engine-offline.d.ts.map +1 -0
- package/dist/worklet/engine-options.d.ts +12 -0
- package/dist/worklet/engine-options.d.ts.map +1 -0
- package/dist/worklet/engine-parameter-facade.d.ts +106 -0
- package/dist/worklet/engine-parameter-facade.d.ts.map +1 -0
- package/dist/worklet/engine-processor.d.ts +68 -0
- package/dist/worklet/engine-processor.d.ts.map +1 -0
- package/dist/worklet/engine-register.d.ts +2 -0
- package/dist/worklet/engine-register.d.ts.map +1 -0
- package/dist/worklet/engine-strips.d.ts +73 -0
- package/dist/worklet/engine-strips.d.ts.map +1 -0
- package/dist/worklet/engine-sync.d.ts +37 -0
- package/dist/worklet/engine-sync.d.ts.map +1 -0
- package/dist/worklet/engine-tempo-facade.d.ts +48 -0
- package/dist/worklet/engine-tempo-facade.d.ts.map +1 -0
- package/dist/worklet/engine.d.ts +397 -0
- package/dist/worklet/engine.d.ts.map +1 -0
- package/dist/worklet/guards.d.ts +47 -0
- package/dist/worklet/guards.d.ts.map +1 -0
- package/dist/worklet/messages.d.ts +710 -0
- package/dist/worklet/messages.d.ts.map +1 -0
- package/dist/worklet/mixer-processor.d.ts +46 -0
- package/dist/worklet/mixer-processor.d.ts.map +1 -0
- package/dist/worklet/playback-processor.d.ts +62 -0
- package/dist/worklet/playback-processor.d.ts.map +1 -0
- package/dist/worklet/protocol.d.ts +323 -0
- package/dist/worklet/protocol.d.ts.map +1 -0
- package/dist/worklet/voice-changer-processor.d.ts +41 -0
- package/dist/worklet/voice-changer-processor.d.ts.map +1 -0
- package/dist/worklet.d.ts +16 -2515
- package/dist/worklet.d.ts.map +1 -0
- package/dist/worklet.js +2763 -501
- package/dist/worklet.js.map +1 -1
- package/package.json +23 -12
- package/src/_effects_common.ts +17 -0
- package/src/_feature_validation.ts +34 -0
- package/src/_fft_options.ts +39 -0
- package/src/align_take.ts +64 -0
- package/src/analysis.ts +56 -3
- package/src/analysis_helpers.ts +7 -0
- package/src/audio.ts +106 -3
- package/src/codes.ts +39 -2
- package/src/effects_mastering.ts +97 -22
- package/src/effects_note_ops.ts +635 -0
- package/src/effects_percussive.ts +217 -0
- package/src/effects_separation.ts +150 -0
- package/src/effects_spectral.ts +60 -0
- package/src/effects_timepitch.ts +377 -0
- package/src/errors.ts +23 -1
- package/src/feature_core.ts +127 -2
- package/src/feature_decompose.ts +633 -0
- package/src/feature_inverse.ts +454 -0
- package/src/feature_loudness.ts +125 -0
- package/src/feature_music.ts +107 -14
- package/src/feature_pitch.ts +96 -1
- package/src/feature_spectral.ts +16 -611
- package/src/feature_spectrogram.ts +63 -450
- package/src/features.ts +36 -22
- package/src/index.ts +282 -30
- package/src/instrument_types.ts +645 -0
- package/src/live_audio.ts +27 -1
- package/src/mastering_chain.ts +184 -0
- package/src/mastering_core.ts +346 -32
- package/src/mastering_dynamics.ts +22 -11
- package/src/metering.ts +67 -24
- package/src/mixer.ts +212 -3
- package/src/mixing_assistant.ts +138 -0
- package/src/mixing_oneshot.ts +10 -5
- package/src/module_state.ts +24 -2
- package/src/playback_renderer.ts +252 -0
- package/src/polyphony.ts +279 -0
- package/src/project.ts +61 -24
- package/src/project_class.ts +450 -27
- package/src/project_internal.ts +149 -42
- package/src/project_synth.ts +67 -1
- package/src/project_types.ts +268 -270
- package/src/public_types.ts +122 -3
- package/src/public_types_acoustic.ts +112 -3
- package/src/public_types_mastering.ts +254 -73
- package/src/public_types_mixing.ts +363 -1
- package/src/public_types_music.ts +312 -2
- package/src/public_types_playback.ts +195 -0
- package/src/public_types_realtime.ts +39 -7
- package/src/public_types_repair.ts +446 -0
- package/src/public_types_spectral.ts +487 -1
- package/src/quick_analysis.ts +203 -26
- package/src/realtime_engine.ts +711 -28
- package/src/realtime_voice_changer.ts +55 -1
- package/src/repair_dereverb.ts +299 -0
- package/src/repair_impulsive.ts +395 -0
- package/src/repair_noise.ts +425 -0
- package/src/repair_trim.ts +226 -0
- package/src/sample_bank.ts +113 -0
- package/src/sonare.js.d.ts +1122 -30
- package/src/stream_analyzer.ts +36 -4
- package/src/stream_types.ts +37 -0
- package/src/streaming_mixing.ts +1 -1
- package/src/streaming_processors.ts +194 -10
- package/src/transcribe.ts +89 -0
- package/src/validation.ts +285 -11
- package/src/web_midi.ts +1 -6
- package/src/worker.ts +18 -2
- package/src/worklet/audio_types.ts +37 -0
- package/src/worklet/engine-mixer-facade.ts +444 -10
- package/src/worklet/engine-node.ts +78 -26
- package/src/worklet/engine-offline.ts +14 -8
- package/src/worklet/engine-parameter-facade.ts +21 -0
- package/src/worklet/engine-processor.ts +272 -83
- package/src/worklet/engine-register.ts +32 -18
- package/src/worklet/engine-strips.ts +280 -9
- package/src/worklet/engine-sync.ts +14 -6
- package/src/worklet/engine.ts +365 -31
- package/src/worklet/guards.ts +140 -44
- package/src/worklet/messages.ts +227 -2
- package/src/worklet/mixer-processor.ts +109 -47
- package/src/worklet/playback-processor.ts +300 -0
- package/src/worklet/protocol.ts +53 -3
- package/src/worklet/voice-changer-processor.ts +17 -11
- package/src/worklet.ts +17 -0
- package/src/effects_transform.ts +0 -718
- package/src/mastering_repair.ts +0 -273
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harmonic/percussive separation: the masked split and the two shortcuts
|
|
3
|
+
* that return a single component.
|
|
4
|
+
*/
|
|
5
|
+
import type { HpssResult } from './public_types';
|
|
6
|
+
import type { ValidateOptions } from './validation';
|
|
7
|
+
/** Canonical request form for HPSS. */
|
|
8
|
+
export interface HpssRequest {
|
|
9
|
+
samples: Float32Array;
|
|
10
|
+
sampleRate?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Horizontal median filter size, in STFT frames: a positive odd integer at
|
|
13
|
+
* most 524287. Default 31. The ceiling is 524288 and an even kernel is
|
|
14
|
+
* refused, so 524287 is the largest legal value.
|
|
15
|
+
*/
|
|
16
|
+
kernelHarmonic?: number;
|
|
17
|
+
/** Vertical median filter size, in STFT bins, under the same rule. Default 31. */
|
|
18
|
+
kernelPercussive?: number;
|
|
19
|
+
nFft?: number;
|
|
20
|
+
hopLength?: number;
|
|
21
|
+
hardMask?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface HarmonicRequest extends ValidateOptions {
|
|
24
|
+
samples: Float32Array;
|
|
25
|
+
sampleRate?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PercussiveRequest extends ValidateOptions {
|
|
28
|
+
samples: Float32Array;
|
|
29
|
+
sampleRate?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Perform Harmonic-Percussive Source Separation (HPSS).
|
|
33
|
+
*
|
|
34
|
+
* @param samples - Audio samples (mono, float32)
|
|
35
|
+
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
36
|
+
* @param kernelHarmonic - Horizontal median filter size in STFT frames; a
|
|
37
|
+
* positive odd integer at most 524287 (default: 31)
|
|
38
|
+
* @param kernelPercussive - Vertical median filter size in STFT bins, under the
|
|
39
|
+
* same rule (default: 31)
|
|
40
|
+
* @returns Separated harmonic and percussive components
|
|
41
|
+
* @throws SonareError (`InvalidParameter`) on a kernel that is not an integer
|
|
42
|
+
* within the signed 32-bit range, or one the core rejects as even,
|
|
43
|
+
* non-positive or above its ceiling
|
|
44
|
+
*/
|
|
45
|
+
export declare function hpss(request: HpssRequest): HpssResult;
|
|
46
|
+
export declare function hpss(samples: Float32Array, sampleRate?: number, kernelHarmonic?: number, kernelPercussive?: number, nFft?: number, hopLength?: number, hardMask?: boolean): HpssResult;
|
|
47
|
+
/**
|
|
48
|
+
* Extract harmonic component from audio.
|
|
49
|
+
*
|
|
50
|
+
* @param samples - Audio samples (mono, float32)
|
|
51
|
+
* @param sampleRate - Sample rate in Hz
|
|
52
|
+
* @returns Harmonic component
|
|
53
|
+
*/
|
|
54
|
+
export declare function harmonic(request: HarmonicRequest): Float32Array;
|
|
55
|
+
export declare function harmonic(samples: Float32Array, sampleRate?: number, options?: ValidateOptions): Float32Array;
|
|
56
|
+
/**
|
|
57
|
+
* Extract percussive component from audio.
|
|
58
|
+
*
|
|
59
|
+
* @param samples - Audio samples (mono, float32)
|
|
60
|
+
* @param sampleRate - Sample rate in Hz
|
|
61
|
+
* @returns Percussive component
|
|
62
|
+
*/
|
|
63
|
+
export declare function percussive(request: PercussiveRequest): Float32Array;
|
|
64
|
+
export declare function percussive(samples: Float32Array, sampleRate?: number, options?: ValidateOptions): Float32Array;
|
|
65
|
+
//# sourceMappingURL=effects_separation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects_separation.d.ts","sourceRoot":"","sources":["../src/effects_separation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiBpD,uCAAuC;AACvC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAAC;AACvD,wBAAgB,IAAI,CAClB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,OAAO,GACjB,UAAU,CAAC;AA8Bd;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAAC;AACjE,wBAAgB,QAAQ,CACtB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAWhB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC;AACrE,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Region-based spectral editing: time x frequency rectangles applied over an
|
|
3
|
+
* STFT and resynthesized.
|
|
4
|
+
*/
|
|
5
|
+
import type { SpectralEditOptions, SpectralRegionOp } from './public_types';
|
|
6
|
+
import type { ValidateOptions } from './validation';
|
|
7
|
+
export interface SpectralEditRequest extends SpectralEditOptions, ValidateOptions {
|
|
8
|
+
samples: Float32Array;
|
|
9
|
+
sampleRate: number;
|
|
10
|
+
ops?: SpectralRegionOp[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Apply region-based spectral edits (gain/attenuate/mute/heal) to mono audio.
|
|
14
|
+
*
|
|
15
|
+
* Each op is a time x frequency rectangle applied in array order over a single
|
|
16
|
+
* STFT buffer, so a later op observes the result of earlier ops. The output has
|
|
17
|
+
* the same length and sample rate as the input; an empty `ops` list is an
|
|
18
|
+
* identity transform (within the iSTFT's own tolerance).
|
|
19
|
+
*
|
|
20
|
+
* @param samples - Audio samples (mono, float32)
|
|
21
|
+
* @param sampleRate - Sample rate in Hz
|
|
22
|
+
* @param ops - Region edit ops applied in order ({@link SpectralRegionOp})
|
|
23
|
+
* @param options - STFT + heal configuration ({@link SpectralEditOptions})
|
|
24
|
+
* @returns Edited audio
|
|
25
|
+
*/
|
|
26
|
+
export declare function spectralEdit(request: SpectralEditRequest): Float32Array;
|
|
27
|
+
export declare function spectralEdit(samples: Float32Array, sampleRate: number, ops?: SpectralRegionOp[], options?: SpectralEditOptions & ValidateOptions): Float32Array;
|
|
28
|
+
//# sourceMappingURL=effects_spectral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects_spectral.d.ts","sourceRoot":"","sources":["../src/effects_spectral.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB,EAAE,eAAe;IAC/E,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC;AACzE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAAG,eAAe,GAC9C,YAAY,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time and pitch transforms over a whole buffer: stretching, shifting, and
|
|
3
|
+
* correction onto a target pitch.
|
|
4
|
+
*/
|
|
5
|
+
import type { PitchCorrectOptions, VoicedFlags } from './public_types';
|
|
6
|
+
import type { ValidateOptions } from './validation';
|
|
7
|
+
export interface TimeStretchRequest extends ValidateOptions {
|
|
8
|
+
samples: Float32Array;
|
|
9
|
+
sampleRate?: number;
|
|
10
|
+
rate: number;
|
|
11
|
+
nFft?: number;
|
|
12
|
+
hopLength?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PitchShiftRequest extends ValidateOptions {
|
|
15
|
+
samples: Float32Array;
|
|
16
|
+
sampleRate?: number;
|
|
17
|
+
semitones: number;
|
|
18
|
+
nFft?: number;
|
|
19
|
+
hopLength?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface PitchCorrectToMidiRequest extends ValidateOptions {
|
|
22
|
+
samples: Float32Array;
|
|
23
|
+
sampleRate?: number;
|
|
24
|
+
currentMidi?: number;
|
|
25
|
+
targetMidi?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PitchCorrectToMidiTimevaryingRequest extends ValidateOptions {
|
|
28
|
+
samples: Float32Array;
|
|
29
|
+
f0Hz: Float32Array;
|
|
30
|
+
targetMidi: number;
|
|
31
|
+
sampleRate?: number;
|
|
32
|
+
hopLength?: number;
|
|
33
|
+
voiced?: VoicedFlags;
|
|
34
|
+
voicedProb?: Float32Array;
|
|
35
|
+
}
|
|
36
|
+
export interface PitchCorrectTimevaryingRequest extends PitchCorrectOptions {
|
|
37
|
+
samples: Float32Array;
|
|
38
|
+
f0Hz: Float32Array;
|
|
39
|
+
sampleRate?: number;
|
|
40
|
+
hopLength?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Time-stretch audio without changing pitch.
|
|
44
|
+
*
|
|
45
|
+
* @param samples - Audio samples (mono, float32)
|
|
46
|
+
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
47
|
+
* @param rate - Time stretch rate (0.5 = double duration, 2.0 = half duration)
|
|
48
|
+
* @param nFft - FFT size: an even integer >= 2 (default 2048)
|
|
49
|
+
* @param hopLength - Hop in samples, in `(0, nFft / 2]` (default 512), so
|
|
50
|
+
* frames overlap by at least half a window
|
|
51
|
+
* @returns Time-stretched audio
|
|
52
|
+
*/
|
|
53
|
+
export declare function timeStretch(request: TimeStretchRequest): Float32Array;
|
|
54
|
+
export declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number, options?: ValidateOptions): Float32Array;
|
|
55
|
+
export declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number, nFft?: number, hopLength?: number, options?: ValidateOptions): Float32Array;
|
|
56
|
+
/**
|
|
57
|
+
* Pitch-shift audio without changing duration.
|
|
58
|
+
*
|
|
59
|
+
* @param samples - Audio samples (mono, float32)
|
|
60
|
+
* @param sampleRate - Sample rate in Hz (default: 22050)
|
|
61
|
+
* @param semitones - Pitch shift in semitones (+12 = one octave up, -12 = one octave down)
|
|
62
|
+
* @param nFft - FFT size: an even integer >= 2 (default 2048)
|
|
63
|
+
* @param hopLength - Hop in samples, in `(0, nFft / 2]` (default 512), so
|
|
64
|
+
* frames overlap by at least half a window
|
|
65
|
+
* @returns Pitch-shifted audio
|
|
66
|
+
*/
|
|
67
|
+
export declare function pitchShift(request: PitchShiftRequest): Float32Array;
|
|
68
|
+
export declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number, options?: ValidateOptions): Float32Array;
|
|
69
|
+
export declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number, nFft?: number, hopLength?: number, options?: ValidateOptions): Float32Array;
|
|
70
|
+
/**
|
|
71
|
+
* Pitch-correct audio from a current MIDI note to a target MIDI note.
|
|
72
|
+
*
|
|
73
|
+
* Applies one constant, immediate transpose with no retune glide and preserves
|
|
74
|
+
* the input buffer length. The whole interval is applied however large it is:
|
|
75
|
+
* both endpoints are validated to [0, 127], so a two-octave move such as
|
|
76
|
+
* C3 -> C5 transposes by the full 24 semitones. Use
|
|
77
|
+
* {@link pitchCorrectToMidiTimevarying} for a caller-supplied pitch contour.
|
|
78
|
+
*
|
|
79
|
+
* @param samples - Audio samples (mono, float32)
|
|
80
|
+
* @param sampleRate - Sample rate in Hz
|
|
81
|
+
* @param currentMidi - Detected/current MIDI note number
|
|
82
|
+
* @param targetMidi - Desired MIDI note number
|
|
83
|
+
* @returns Pitch-corrected audio
|
|
84
|
+
*/
|
|
85
|
+
export declare function pitchCorrectToMidi(request: PitchCorrectToMidiRequest): Float32Array;
|
|
86
|
+
export declare function pitchCorrectToMidi(samples: Float32Array, sampleRate?: number, currentMidi?: number, targetMidi?: number, options?: ValidateOptions): Float32Array;
|
|
87
|
+
/**
|
|
88
|
+
* Contour-following ("time-varying") pitch correction toward a MIDI target.
|
|
89
|
+
*
|
|
90
|
+
* Unlike {@link pitchCorrectToMidi} (a single constant transpose), this follows
|
|
91
|
+
* the caller-supplied per-frame `f0Hz` contour and retunes every voiced frame
|
|
92
|
+
* toward `targetMidi`, so vibrato/drift in the source is tracked rather than
|
|
93
|
+
* flattened. `voiced` (truthy = voiced) and `voicedProb` ([0,1]) are optional;
|
|
94
|
+
* omitting them treats every frame as voiced. An `f0Hz` NaN is accepted only
|
|
95
|
+
* when the corresponding `voiced` entry is falsy, matching pYIN output. The
|
|
96
|
+
* `voicedFlag` / `voicedProb` arrays of a {@link PitchResult} can be passed
|
|
97
|
+
* through directly.
|
|
98
|
+
*
|
|
99
|
+
* @param samples - Audio samples (mono, float32)
|
|
100
|
+
* @param f0Hz - Per-frame measured F0 in Hz (one entry per analysis frame)
|
|
101
|
+
* @param targetMidi - Desired MIDI note number
|
|
102
|
+
* @param sampleRate - Sample rate in Hz
|
|
103
|
+
* @param hopLength - F0 hop in samples (frame i covers sample i*hopLength)
|
|
104
|
+
* @param voiced - Optional per-frame voiced flags (truthy = voiced)
|
|
105
|
+
* @param voicedProb - Optional per-frame voicing probability in [0, 1]
|
|
106
|
+
* @returns Pitch-corrected audio
|
|
107
|
+
*/
|
|
108
|
+
export declare function pitchCorrectToMidiTimevarying(request: PitchCorrectToMidiTimevaryingRequest): Float32Array;
|
|
109
|
+
export declare function pitchCorrectToMidiTimevarying(samples: Float32Array, f0Hz: Float32Array, targetMidi: number, sampleRate?: number, hopLength?: number, voiced?: VoicedFlags, voicedProb?: Float32Array, options?: ValidateOptions): Float32Array;
|
|
110
|
+
/**
|
|
111
|
+
* Contour-following pitch correction toward a fixed MIDI note OR a musical
|
|
112
|
+
* scale, with tunable retune strength and vibrato preservation.
|
|
113
|
+
*
|
|
114
|
+
* Generalises {@link pitchCorrectToMidiTimevarying}: the same caller-supplied
|
|
115
|
+
* per-frame `f0Hz` contour drives correction, but `options.mode` selects between
|
|
116
|
+
* a fixed-MIDI target (`'midi'`, default) and scale quantisation (`'scale'`),
|
|
117
|
+
* and the retune knobs shape natural-vs-robotic correction. An `f0Hz` NaN is
|
|
118
|
+
* accepted only for a frame marked unvoiced.
|
|
119
|
+
*
|
|
120
|
+
* @param samples - Audio samples (mono, float32)
|
|
121
|
+
* @param f0Hz - Per-frame measured F0 in Hz (one entry per analysis frame)
|
|
122
|
+
* @param sampleRate - Sample rate in Hz
|
|
123
|
+
* @param hopLength - F0 hop in samples (frame i covers sample i*hopLength)
|
|
124
|
+
* @param options - Target mode + retune knobs + optional voiced/voicedProb arrays
|
|
125
|
+
* @returns Pitch-corrected audio
|
|
126
|
+
*/
|
|
127
|
+
export declare function pitchCorrectTimevarying(request: PitchCorrectTimevaryingRequest): Float32Array;
|
|
128
|
+
export declare function pitchCorrectTimevarying(samples: Float32Array, f0Hz: Float32Array, sampleRate?: number, hopLength?: number, options?: PitchCorrectOptions): Float32Array;
|
|
129
|
+
//# sourceMappingURL=effects_timepitch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects_timepitch.d.ts","sourceRoot":"","sources":["../src/effects_timepitch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAA0B,SAAQ,eAAe;IAChE,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oCAAqC,SAAQ,eAAe;IAC3E,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,8BAA+B,SAAQ,mBAAmB;IACzE,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY,CAAC;AACvE,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAChB,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAkDhB;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC;AACrE,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAChB,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AA+ChB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CAAC;AACrF,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAqBhB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,oCAAoC,GAC5C,YAAY,CAAC;AAChB,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,YAAY,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AA2ChB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,GAAG,YAAY,CAAC;AAC/F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,YAAY,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { RealtimeVoiceChangerConfigInput } from './public_types';
|
|
2
|
+
import type { ValidateOptions } from './validation';
|
|
3
|
+
/** Options for {@link voiceChange}. All fields are optional. */
|
|
4
|
+
export interface VoiceChangeOptions extends ValidateOptions {
|
|
5
|
+
/** Pitch shift in semitones (negative = down). Default 0. */
|
|
6
|
+
pitchSemitones?: number;
|
|
7
|
+
/** Formant scale factor (>1 brightens, <1 darkens). Default 1. */
|
|
8
|
+
formantFactor?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Canonical request form for one-shot voice changing. */
|
|
11
|
+
export interface VoiceChangeRequest extends VoiceChangeOptions {
|
|
12
|
+
samples: Float32Array;
|
|
13
|
+
sampleRate?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply a voice change by shifting pitch and formants independently.
|
|
17
|
+
*
|
|
18
|
+
* @param samples - Audio samples (mono, float32)
|
|
19
|
+
* @param sampleRate - Sample rate in Hz
|
|
20
|
+
* @param options - Pitch/formant settings ({@link VoiceChangeOptions})
|
|
21
|
+
* @returns Voice-changed audio
|
|
22
|
+
*/
|
|
23
|
+
export declare function voiceChange(request: VoiceChangeRequest): Float32Array;
|
|
24
|
+
export declare function voiceChange(samples: Float32Array, sampleRate?: number, options?: VoiceChangeOptions): Float32Array;
|
|
25
|
+
/** Options for the offline {@link voiceChangeRealtime} convenience wrapper. */
|
|
26
|
+
export interface VoiceChangeRealtimeOptions extends ValidateOptions {
|
|
27
|
+
/** Channel count (1 = mono, 2 = interleaved stereo). */
|
|
28
|
+
channels?: 1 | 2;
|
|
29
|
+
/** @deprecated The shared C-ABI renderer uses a fixed cross-surface block size. */
|
|
30
|
+
blockSize?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Canonical request form for offline realtime voice changing. */
|
|
33
|
+
export interface VoiceChangeRealtimeRequest extends VoiceChangeRealtimeOptions {
|
|
34
|
+
samples: Float32Array;
|
|
35
|
+
sampleRate?: number;
|
|
36
|
+
preset?: RealtimeVoiceChangerConfigInput;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Applies the realtime voice-changer chain to a whole buffer in one call.
|
|
40
|
+
*
|
|
41
|
+
* Uses the shared C-ABI renderer, so Python, Node, and WASM use the same
|
|
42
|
+
* fixed block size and latency compensation. For mono, `samples` is a plain
|
|
43
|
+
* buffer; for stereo, it is interleaved (L0,R0,L1,R1,...).
|
|
44
|
+
*
|
|
45
|
+
* @param samples - Audio samples (mono, or interleaved stereo when channels=2)
|
|
46
|
+
* @param sampleRate - Sample rate in Hz (default 48000, matching Python/Node)
|
|
47
|
+
* @param preset - Voice-changer preset id or full config object
|
|
48
|
+
* @param options - Channel count and block size ({@link VoiceChangeRealtimeOptions})
|
|
49
|
+
* @returns The processed buffer (same layout/length as the input).
|
|
50
|
+
*/
|
|
51
|
+
export declare function voiceChangeRealtime(request: VoiceChangeRealtimeRequest): Float32Array;
|
|
52
|
+
export declare function voiceChangeRealtime(samples: Float32Array, sampleRate?: number, preset?: RealtimeVoiceChangerConfigInput, options?: VoiceChangeRealtimeOptions): Float32Array;
|
|
53
|
+
//# sourceMappingURL=effects_voice_change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects_voice_change.d.ts","sourceRoot":"","sources":["../src/effects_voice_change.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,gEAAgE;AAChE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY,CAAC;AACvE,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,YAAY,CAAC;AAgBhB,+EAA+E;AAC/E,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kEAAkE;AAClE,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;IAC5E,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,+BAA+B,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,YAAY,CAAC;AACvF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,+BAA+B,EACxC,OAAO,CAAC,EAAE,0BAA0B,GACnC,YAAY,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric error codes carried by a {@link SonareError}. Mirrors the C ABI
|
|
3
|
+
* `SonareError` enum (and the Node / Python surfaces), so the same failure
|
|
4
|
+
* reports the same numeric code on every binding.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ErrorCode {
|
|
7
|
+
Ok = 0,
|
|
8
|
+
FileNotFound = 1,
|
|
9
|
+
InvalidFormat = 2,
|
|
10
|
+
DecodeFailed = 3,
|
|
11
|
+
InvalidParameter = 4,
|
|
12
|
+
OutOfMemory = 5,
|
|
13
|
+
NotSupported = 6,
|
|
14
|
+
InvalidState = 7,
|
|
15
|
+
Cancelled = 8,
|
|
16
|
+
EncodeFailed = 9,
|
|
17
|
+
Unknown = 99
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown by libsonare on a native (C++) failure. Carries a numeric
|
|
21
|
+
* {@link ErrorCode} `code` plus its canonical `codeName`, so callers can branch
|
|
22
|
+
* on the cause instead of matching message text.
|
|
23
|
+
*
|
|
24
|
+
* Narrow a caught value with {@link isSonareError} or with `instanceof`; both
|
|
25
|
+
* accept the same values. The Node package exports the same class under the
|
|
26
|
+
* same name.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SonareError extends Error {
|
|
29
|
+
/** Numeric error code, equal to an {@link ErrorCode} value. */
|
|
30
|
+
readonly code: number;
|
|
31
|
+
/** Canonical name of `code`, e.g. `'InvalidParameter'`. */
|
|
32
|
+
readonly codeName: string;
|
|
33
|
+
constructor(code: number, codeName: string, message: string);
|
|
34
|
+
/**
|
|
35
|
+
* Brand-based `instanceof`: an error that carries the shape narrows here even
|
|
36
|
+
* when it is not literally an instance of this class. That is not a
|
|
37
|
+
* hypothetical — an error posted from the analysis worker arrives as a
|
|
38
|
+
* structured clone with its prototype gone, which a prototype-based
|
|
39
|
+
* `instanceof` would silently miss. Delegates to {@link isSonareError} so the
|
|
40
|
+
* two never disagree.
|
|
41
|
+
*/
|
|
42
|
+
static [Symbol.hasInstance](value: unknown): value is SonareError;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Type guard: whether a caught value is a libsonare {@link SonareError}.
|
|
46
|
+
*
|
|
47
|
+
* Duck-typed on purpose: a value that crossed a worker boundary has lost its
|
|
48
|
+
* prototype, so a prototype check would miss it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isSonareError(value: unknown): value is SonareError;
|
|
51
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,SAAS;IACnB,EAAE,IAAI;IACN,YAAY,IAAI;IAChB,aAAa,IAAI;IACjB,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB,WAAW,IAAI;IACf,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,OAAO,KAAK;CACb;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAO3D;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW;CAGlE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAMlE"}
|