@libraz/libsonare 1.2.2 → 1.2.3
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.d.ts +132 -12
- package/dist/index.js +103 -8
- package/dist/index.js.map +1 -1
- package/dist/sonare-rt.wasm +0 -0
- package/dist/sonare.js +1 -1
- package/dist/sonare.wasm +0 -0
- package/dist/worklet.d.ts +44 -5
- package/dist/worklet.js +348 -73
- package/dist/worklet.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +189 -8
- package/src/public_types.ts +67 -0
- package/src/sonare.js.d.ts +84 -0
- package/src/stream_types.ts +4 -1
- package/src/worklet.ts +525 -81
package/dist/index.d.ts
CHANGED
|
@@ -271,6 +271,63 @@ interface AcousticResult {
|
|
|
271
271
|
confidence: number;
|
|
272
272
|
isBlind: boolean;
|
|
273
273
|
}
|
|
274
|
+
/** Shoebox geometry + placement shared by RIR synthesis and the room morph. */
|
|
275
|
+
interface RoomGeometryOptions {
|
|
276
|
+
lengthM?: number;
|
|
277
|
+
widthM?: number;
|
|
278
|
+
heightM?: number;
|
|
279
|
+
absorption?: number;
|
|
280
|
+
sourceX?: number;
|
|
281
|
+
sourceY?: number;
|
|
282
|
+
sourceZ?: number;
|
|
283
|
+
listenerX?: number;
|
|
284
|
+
listenerY?: number;
|
|
285
|
+
listenerZ?: number;
|
|
286
|
+
ismOrder?: number;
|
|
287
|
+
seed?: number;
|
|
288
|
+
maxSeconds?: number;
|
|
289
|
+
}
|
|
290
|
+
interface RirSynthOptions extends RoomGeometryOptions {
|
|
291
|
+
sampleRate?: number;
|
|
292
|
+
/** Use the Eyring statistical late-tail model (default true); false = Sabine. */
|
|
293
|
+
preferEyring?: boolean;
|
|
294
|
+
/** Early/late crossover in ms (0 = auto, ~sqrt(V) ms). */
|
|
295
|
+
mixingTimeMs?: number;
|
|
296
|
+
/** Equal-power crossfade width around the mixing time in ms (0 = default). */
|
|
297
|
+
crossfadeMs?: number;
|
|
298
|
+
}
|
|
299
|
+
interface RirResult {
|
|
300
|
+
rir: Float32Array;
|
|
301
|
+
sampleRate: number;
|
|
302
|
+
hasError: boolean;
|
|
303
|
+
}
|
|
304
|
+
interface RoomEstimateOptions {
|
|
305
|
+
aspectHintLw?: number;
|
|
306
|
+
aspectHintLh?: number;
|
|
307
|
+
referenceAbsorption?: number;
|
|
308
|
+
preferEyring?: boolean;
|
|
309
|
+
nOctaveBands?: number;
|
|
310
|
+
/** Analyzer routing: 0 = auto, 1 = blind, 2 = impulse-response. */
|
|
311
|
+
mode?: number;
|
|
312
|
+
/** Analyzer decay-fit span in dB (0 = library default). */
|
|
313
|
+
minDecayDb?: number;
|
|
314
|
+
/** Analyzer noise-floor margin in dB (0 = library default). */
|
|
315
|
+
noiseFloorMarginDb?: number;
|
|
316
|
+
}
|
|
317
|
+
interface RoomEstimateResult {
|
|
318
|
+
volume: number;
|
|
319
|
+
length: number;
|
|
320
|
+
width: number;
|
|
321
|
+
height: number;
|
|
322
|
+
drrDb: number;
|
|
323
|
+
confidence: number;
|
|
324
|
+
absorptionBands: Float32Array;
|
|
325
|
+
rt60Bands: Float32Array;
|
|
326
|
+
}
|
|
327
|
+
interface RoomMorphOptions extends RoomGeometryOptions {
|
|
328
|
+
wet?: number;
|
|
329
|
+
sourceTailSuppression?: number;
|
|
330
|
+
}
|
|
274
331
|
/**
|
|
275
332
|
* HPSS (Harmonic-Percussive Source Separation) result
|
|
276
333
|
*/
|
|
@@ -713,6 +770,10 @@ interface RealtimeVoiceChangerPodConfig {
|
|
|
713
770
|
reverb_seed: number;
|
|
714
771
|
limiter_ceiling_db: number;
|
|
715
772
|
limiter_release_ms: number;
|
|
773
|
+
/** Non-zero enables the 4x-oversampled inter-sample-peak limiter (default enabled). */
|
|
774
|
+
limiter_enable_isp_limiter: boolean;
|
|
775
|
+
/** True-peak ceiling in dBTP applied by the ISP limiter (default -1.0). */
|
|
776
|
+
limiter_isp_ceiling_dbtp: number;
|
|
716
777
|
}
|
|
717
778
|
/** Options for {@link StreamingEqualizer.match}. */
|
|
718
779
|
interface EqMatchOptions {
|
|
@@ -787,6 +848,8 @@ interface AnalyzerStats {
|
|
|
787
848
|
*/
|
|
788
849
|
interface FrameBuffer {
|
|
789
850
|
nFrames: number;
|
|
851
|
+
/** Number of mel bands; flat `mel` is `[nFrames * nMels]` row-major. */
|
|
852
|
+
nMels: number;
|
|
790
853
|
timestamps: Float32Array;
|
|
791
854
|
mel: Float32Array;
|
|
792
855
|
chroma: Float32Array;
|
|
@@ -824,7 +887,8 @@ interface StreamFramesI16 {
|
|
|
824
887
|
* Configuration for StreamAnalyzer
|
|
825
888
|
*/
|
|
826
889
|
interface StreamConfig {
|
|
827
|
-
|
|
890
|
+
/** Sample rate in Hz. Optional for parity with the Node/Python bindings (default 44100). */
|
|
891
|
+
sampleRate?: number;
|
|
828
892
|
nFft?: number;
|
|
829
893
|
hopLength?: number;
|
|
830
894
|
nMels?: number;
|
|
@@ -849,7 +913,7 @@ interface StreamConfig {
|
|
|
849
913
|
*
|
|
850
914
|
* @example
|
|
851
915
|
* ```typescript
|
|
852
|
-
* import { init, detectBpm, detectKey, analyze } from '@libraz/
|
|
916
|
+
* import { init, detectBpm, detectKey, analyze } from '@libraz/libsonare';
|
|
853
917
|
*
|
|
854
918
|
* await init();
|
|
855
919
|
*
|
|
@@ -1019,6 +1083,25 @@ declare class RealtimeEngine {
|
|
|
1019
1083
|
captureStatus(): EngineCaptureStatus;
|
|
1020
1084
|
capturedAudio(): Float32Array[];
|
|
1021
1085
|
process(channels: Float32Array[]): Float32Array[];
|
|
1086
|
+
/**
|
|
1087
|
+
* Allocates persistent per-channel WASM-heap scratch for the zero-copy
|
|
1088
|
+
* `getChannelBuffer` / `processPrepared` realtime path. Call once (off the
|
|
1089
|
+
* audio thread) before driving `processPrepared` from an AudioWorklet so the
|
|
1090
|
+
* render callback never allocates on the C++/JS heap.
|
|
1091
|
+
*/
|
|
1092
|
+
prepareChannels(numChannels: number, maxFrames: number): void;
|
|
1093
|
+
/**
|
|
1094
|
+
* Returns a Float32Array view onto the persistent WASM-heap scratch for one
|
|
1095
|
+
* channel (valid for up to `numFrames`). Fill it, call `processPrepared`, then
|
|
1096
|
+
* read the same view back. Re-acquire after WASM memory growth.
|
|
1097
|
+
*/
|
|
1098
|
+
getChannelBuffer(channel: number, numFrames: number): Float32Array;
|
|
1099
|
+
/**
|
|
1100
|
+
* Runs the engine in place over the prepared per-channel scratch buffers.
|
|
1101
|
+
* Allocation-free: safe to call on the AudioWorklet render thread after
|
|
1102
|
+
* `prepareChannels`.
|
|
1103
|
+
*/
|
|
1104
|
+
processPrepared(numFrames: number): void;
|
|
1022
1105
|
processWithMonitor(channels: Float32Array[]): WasmEngineProcessWithMonitorResult;
|
|
1023
1106
|
renderOffline(channels: Float32Array[], blockSize?: number): Float32Array[];
|
|
1024
1107
|
bounceOffline(options: EngineBounceOptions): EngineBounceResult;
|
|
@@ -1087,6 +1170,22 @@ declare function detectChords(samples: Float32Array, sampleRate?: number, option
|
|
|
1087
1170
|
declare function analyze(samples: Float32Array, sampleRate?: number): AnalysisResult;
|
|
1088
1171
|
declare function analyzeImpulseResponse(samples: Float32Array, sampleRate?: number, nOctaveBands?: number): AcousticResult;
|
|
1089
1172
|
declare function detectAcoustic(samples: Float32Array, sampleRate?: number, nOctaveBands?: number, nThirdOctaveSubbands?: number, minDecayDb?: number, noiseFloorMarginDb?: number): AcousticResult;
|
|
1173
|
+
/**
|
|
1174
|
+
* Synthesize a room impulse response from shoebox geometry. `hasError` is true
|
|
1175
|
+
* when the source/listener falls outside the room (the RIR is then empty).
|
|
1176
|
+
*/
|
|
1177
|
+
declare function synthesizeRir(options?: RirSynthOptions): RirResult;
|
|
1178
|
+
/**
|
|
1179
|
+
* Estimate an equivalent room (volume/dimensions/absorption/DRR) from a
|
|
1180
|
+
* recording or impulse response.
|
|
1181
|
+
*/
|
|
1182
|
+
declare function estimateRoom(samples: Float32Array, sampleRate?: number, options?: RoomEstimateOptions): RoomEstimateResult;
|
|
1183
|
+
/**
|
|
1184
|
+
* Morph a recording's reverberation toward a target room (creative FX, not
|
|
1185
|
+
* dereverberation). Returns the morphed samples (input length plus the target
|
|
1186
|
+
* room's reverb tail).
|
|
1187
|
+
*/
|
|
1188
|
+
declare function roomMorph(samples: Float32Array, sampleRate: number, options?: RoomMorphOptions): Float32Array;
|
|
1090
1189
|
/**
|
|
1091
1190
|
* Perform complete music analysis with progress reporting.
|
|
1092
1191
|
*
|
|
@@ -1189,7 +1288,7 @@ declare function hpss(samples: Float32Array, sampleRate?: number, kernelHarmonic
|
|
|
1189
1288
|
* @param sampleRate - Sample rate in Hz
|
|
1190
1289
|
* @returns Harmonic component
|
|
1191
1290
|
*/
|
|
1192
|
-
declare function harmonic(samples: Float32Array, sampleRate: number): Float32Array;
|
|
1291
|
+
declare function harmonic(samples: Float32Array, sampleRate: number, options?: ValidateOptions): Float32Array;
|
|
1193
1292
|
/**
|
|
1194
1293
|
* Extract percussive component from audio.
|
|
1195
1294
|
*
|
|
@@ -1197,7 +1296,7 @@ declare function harmonic(samples: Float32Array, sampleRate: number): Float32Arr
|
|
|
1197
1296
|
* @param sampleRate - Sample rate in Hz
|
|
1198
1297
|
* @returns Percussive component
|
|
1199
1298
|
*/
|
|
1200
|
-
declare function percussive(samples: Float32Array, sampleRate: number): Float32Array;
|
|
1299
|
+
declare function percussive(samples: Float32Array, sampleRate: number, options?: ValidateOptions): Float32Array;
|
|
1201
1300
|
/**
|
|
1202
1301
|
* Time-stretch audio without changing pitch.
|
|
1203
1302
|
*
|
|
@@ -1206,7 +1305,7 @@ declare function percussive(samples: Float32Array, sampleRate: number): Float32A
|
|
|
1206
1305
|
* @param rate - Time stretch rate (0.5 = double duration, 2.0 = half duration)
|
|
1207
1306
|
* @returns Time-stretched audio
|
|
1208
1307
|
*/
|
|
1209
|
-
declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number): Float32Array;
|
|
1308
|
+
declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number, options?: ValidateOptions): Float32Array;
|
|
1210
1309
|
/**
|
|
1211
1310
|
* Pitch-shift audio without changing duration.
|
|
1212
1311
|
*
|
|
@@ -1215,7 +1314,7 @@ declare function timeStretch(samples: Float32Array, sampleRate: number, rate: nu
|
|
|
1215
1314
|
* @param semitones - Pitch shift in semitones (+12 = one octave up, -12 = one octave down)
|
|
1216
1315
|
* @returns Pitch-shifted audio
|
|
1217
1316
|
*/
|
|
1218
|
-
declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number): Float32Array;
|
|
1317
|
+
declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number, options?: ValidateOptions): Float32Array;
|
|
1219
1318
|
/**
|
|
1220
1319
|
* Pitch-correct audio from a current MIDI note to a target MIDI note.
|
|
1221
1320
|
*
|
|
@@ -1225,7 +1324,7 @@ declare function pitchShift(samples: Float32Array, sampleRate: number, semitones
|
|
|
1225
1324
|
* @param targetMidi - Desired MIDI note number
|
|
1226
1325
|
* @returns Pitch-corrected audio
|
|
1227
1326
|
*/
|
|
1228
|
-
declare function pitchCorrectToMidi(samples: Float32Array, sampleRate?: number, currentMidi?: number, targetMidi?: number): Float32Array;
|
|
1327
|
+
declare function pitchCorrectToMidi(samples: Float32Array, sampleRate?: number, currentMidi?: number, targetMidi?: number, options?: ValidateOptions): Float32Array;
|
|
1229
1328
|
/**
|
|
1230
1329
|
* Time-stretch a note region between two sample offsets without changing pitch.
|
|
1231
1330
|
*
|
|
@@ -1236,7 +1335,7 @@ declare function pitchCorrectToMidi(samples: Float32Array, sampleRate?: number,
|
|
|
1236
1335
|
* @param stretchRatio - Stretch ratio (0.5 = double duration, 2.0 = half duration)
|
|
1237
1336
|
* @returns Audio with the note region stretched
|
|
1238
1337
|
*/
|
|
1239
|
-
declare function noteStretch(samples: Float32Array, sampleRate?: number, onsetSample?: number, offsetSample?: number, stretchRatio?: number): Float32Array;
|
|
1338
|
+
declare function noteStretch(samples: Float32Array, sampleRate?: number, onsetSample?: number, offsetSample?: number, stretchRatio?: number, options?: ValidateOptions): Float32Array;
|
|
1240
1339
|
/**
|
|
1241
1340
|
* Apply a voice change by shifting pitch and formants independently.
|
|
1242
1341
|
*
|
|
@@ -1247,6 +1346,27 @@ declare function noteStretch(samples: Float32Array, sampleRate?: number, onsetSa
|
|
|
1247
1346
|
* @returns Voice-changed audio
|
|
1248
1347
|
*/
|
|
1249
1348
|
declare function voiceChange(samples: Float32Array, sampleRate?: number, pitchSemitones?: number, formantFactor?: number, options?: ValidateOptions): Float32Array;
|
|
1349
|
+
/** Options for the offline {@link voiceChangeRealtime} convenience wrapper. */
|
|
1350
|
+
interface VoiceChangeRealtimeOptions extends ValidateOptions {
|
|
1351
|
+
sampleRate?: number;
|
|
1352
|
+
/** Voice-changer preset id or full config object. */
|
|
1353
|
+
preset?: RealtimeVoiceChangerConfigInput;
|
|
1354
|
+
/** Channel count (1 = mono, 2 = interleaved stereo). */
|
|
1355
|
+
channels?: 1 | 2;
|
|
1356
|
+
/** Block size for the internal render loop (default 512). */
|
|
1357
|
+
blockSize?: number;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Applies the realtime voice-changer chain to a whole buffer in one call.
|
|
1361
|
+
*
|
|
1362
|
+
* Constructs and prepares a {@link RealtimeVoiceChanger}, runs the block loop
|
|
1363
|
+
* for the caller, then disposes it — matching the Python `voice_change_realtime`
|
|
1364
|
+
* and Node `voiceChangeRealtime` convenience wrappers. For mono, `samples` is a
|
|
1365
|
+
* plain mono buffer; for stereo, `samples` is interleaved (L0,R0,L1,R1,...).
|
|
1366
|
+
*
|
|
1367
|
+
* @returns The processed buffer (same layout/length as the input).
|
|
1368
|
+
*/
|
|
1369
|
+
declare function voiceChangeRealtime(samples: Float32Array, options?: VoiceChangeRealtimeOptions): Float32Array;
|
|
1250
1370
|
/**
|
|
1251
1371
|
* Normalize audio to target peak level.
|
|
1252
1372
|
*
|
|
@@ -1255,7 +1375,7 @@ declare function voiceChange(samples: Float32Array, sampleRate?: number, pitchSe
|
|
|
1255
1375
|
* @param targetDb - Target peak level in dB (default: 0 dB = full scale)
|
|
1256
1376
|
* @returns Normalized audio
|
|
1257
1377
|
*/
|
|
1258
|
-
declare function normalize(samples: Float32Array, sampleRate: number, targetDb?: number): Float32Array;
|
|
1378
|
+
declare function normalize(samples: Float32Array, sampleRate: number, targetDb?: number, options?: ValidateOptions): Float32Array;
|
|
1259
1379
|
/**
|
|
1260
1380
|
* Apply mastering loudness normalization with a true-peak ceiling.
|
|
1261
1381
|
*
|
|
@@ -2540,7 +2660,7 @@ declare function resample(samples: Float32Array, srcSr: number, targetSr: number
|
|
|
2540
2660
|
*
|
|
2541
2661
|
* @example
|
|
2542
2662
|
* ```typescript
|
|
2543
|
-
* import { init, Audio } from '@libraz/
|
|
2663
|
+
* import { init, Audio } from '@libraz/libsonare';
|
|
2544
2664
|
*
|
|
2545
2665
|
* await init();
|
|
2546
2666
|
*
|
|
@@ -2617,7 +2737,7 @@ declare class Audio {
|
|
|
2617
2737
|
*
|
|
2618
2738
|
* @example
|
|
2619
2739
|
* ```typescript
|
|
2620
|
-
* import { init, StreamAnalyzer } from '@libraz/
|
|
2740
|
+
* import { init, StreamAnalyzer } from '@libraz/libsonare';
|
|
2621
2741
|
*
|
|
2622
2742
|
* await init();
|
|
2623
2743
|
*
|
|
@@ -2720,4 +2840,4 @@ declare class StreamAnalyzer {
|
|
|
2720
2840
|
dispose(): void;
|
|
2721
2841
|
}
|
|
2722
2842
|
|
|
2723
|
-
export { type AcousticResult, type AnalysisResult, type AnalyzerStats, Audio, type AutomationCurve, type BarChord, type Beat, type BpmAnalysisResult, type BpmCandidate, type Chord, type ChordAnalysisResult, type ChordChange, type ChordDetectionOptions, ChordQuality, type ChromaResult, type ClippingRegion, type ClippingReport, type CompressorDetector, type CompressorOptions, type CqtResult, type DeclickOptions, type DeclipOptions, type DecomposeResult, type DecrackleMode, type DecrackleOptions, type DehumOptions, type DenoiseClassicalMode, type DenoiseClassicalNoiseEstimator, type DenoiseClassicalOptions, type DereverbClassicalOptions, type DynamicRangeReport, type Dynamics, type DynamicsAnalysisResult, type DynamicsResult, EXPECTED_ENGINE_ABI_VERSION, type EngineAutomationPoint, type EngineBounceOptions, type EngineBounceResult, type EngineCapabilities, type EngineCaptureStatus, type EngineClip, type EngineFreezeOptions, type EngineFreezeResult, type EngineGraphSpec, type EngineMarker, type EngineMeterTelemetry, type EngineMetronomeConfig, type EngineParameterInfo, type EngineTelemetry, type EngineTransportState, type EqBand, type EqBandPhase, type EqBandType, type EqCoeffMode, type EqMatchOptions, type EqSpectrumSnapshot, type EqStereoPlacement, type FrameBuffer, type GateOptions, type GoniometerPoint, type HpssResult, type HpssWithResidualResult, type Key, type KeyCandidate, type KeyDetectionOptions, KeyProfile, type KeyProfileName, type LufsResult, type MasteringChainConfig, type MasteringChainResult, type MasteringPreset, type MasteringProcessorParams, type MasteringResult, type MasteringStereoChainResult, type MasteringStereoResult, type Matrix2dResult, type MelSpectrogramResult, type MelodyPoint, type MelodyResult, type MeterTap, type MfccResult, type MixMeterSnapshot, type MixOptions, type MixResult, Mixer, type MixerProcessResult, type MixerRealtimeBuffer, Mode, type PairAnalysis, type PairProcessor, type PanLaw, type PanMode, type PatternScore, type PhaseScopeReport, PitchClass as Pitch, PitchClass, type PitchResult, type ProgressiveEstimate, RealtimeEngine, RealtimeVoiceChanger, type RealtimeVoiceChangerConfigInput, type RealtimeVoiceChangerInterleavedBuffer, type RealtimeVoiceChangerMonoBuffer, type RealtimeVoiceChangerPlanarBuffer, type RhythmAnalysisResult, type RhythmFeatures, type Section, SectionType, type SendTiming, type SoloProcessor, type SpectrumOptions, type SpectrumReport, type StereoAnalysis, type StftResult, StreamAnalyzer, type StreamConfig, type StreamFramesI16, type StreamFramesU8, StreamingEqualizer, type StreamingEqualizerConfig, StreamingMasteringChain, type StreamingPlatform, StreamingRetune, type StreamingRetuneConfig, type Timbre, type TimbreAnalysisResult, type TimbreFrame, type TimeSignature, type TransientShaperOptions, type TrimSilenceMode, type TrimSilenceOptions, type ValidateOptions, type VectorscopeReport, type VoicePresetId, amplitudeToDb, analyze, analyzeBpm, analyzeDynamics, analyzeImpulseResponse, analyzeMelody, analyzeRhythm, analyzeSections, analyzeTimbre, analyzeWithProgress, chroma, cqt, cyclicTempogram, dbToAmplitude, dbToPower, decompose, deemphasis, detectAcoustic, detectBeats, detectBpm, detectChords, detectDownbeats, detectKey, detectKeyCandidates, detectOnsets, ebur128LoudnessRange, engineAbiVersion, engineCapabilities, estimateTuning, fixFrames, fixLength, fourierTempogram, frameSignal, framesToSamples, framesToTime, harmonic, hasFfmpegSupport, hpss, hpssWithResidual, hzToMel, hzToMidi, hzToNote, init, isInitialized, lufs, lufsInterleaved, masterAudio, masterAudioStereo, masterAudioStereoWithProgress, masterAudioWithProgress, mastering, masteringAssistantSuggest, masteringAudioProfile, masteringChain, masteringChainStereo, masteringChainStereoWithProgress, masteringChainWithProgress, masteringDynamicsCompressor, masteringDynamicsGate, masteringDynamicsTransientShaper, masteringPairAnalysisNames, masteringPairAnalyze, masteringPairProcess, masteringPairProcessorNames, masteringPresetNames, masteringProcess, masteringProcessStereo, masteringProcessorNames, masteringRepairDeclick, masteringRepairDeclip, masteringRepairDecrackle, masteringRepairDehum, masteringRepairDenoiseClassical, masteringRepairDereverbClassical, masteringRepairTrimSilence, masteringStereoAnalysisNames, masteringStereoAnalyze, masteringStreamingPreview, melSpectrogram, melToAudio, melToHz, melToStft, meteringCrestFactorDb, meteringDcOffset, meteringDetectClipping, meteringDynamicRange, meteringPeakDb, meteringPhaseScope, meteringRmsDb, meteringSpectrum, meteringStereoCorrelation, meteringStereoWidth, meteringTruePeakDb, meteringVectorscope, mfcc, mfccToAudio, mfccToMel, midiToHz, mixStereo, mixingScenePresetJson, mixingScenePresetNames, momentaryLufs, nnFilter, nnlsChroma, normalize, noteStretch, noteToHz, onsetEnvelope, padCenter, pcen, peakPick, percussive, phaseVocoder, pitchCorrectToMidi, pitchPyin, pitchShift, pitchTuning, pitchYin, plp, polyFeatures, powerToDb, preemphasis, realtimeVoiceChangerPresetConfig, realtimeVoiceChangerPresetJson, realtimeVoiceChangerPresetNames, remix, resample, rmsEnergy, samplesToFrames, scaleCorrectionSemitones, scalePitchClassEnabled, scaleQuantizeMidi, shortTermLufs, spectralBandwidth, spectralCentroid, spectralContrast, spectralFlatness, spectralRolloff, splitSilence, stft, stftDb, tempogram, tempogramRatio, timeStretch, timeToFrames, tonnetz, trim, trimSilence, validateRealtimeVoiceChangerPresetJson, vectorNormalize, version, voiceChange, voiceChangerAbiVersion, voiceCharacterPresetId, vqt, zeroCrossingRate, zeroCrossings };
|
|
2843
|
+
export { type AcousticResult, type AnalysisResult, type AnalyzerStats, Audio, type AutomationCurve, type BarChord, type Beat, type BpmAnalysisResult, type BpmCandidate, type Chord, type ChordAnalysisResult, type ChordChange, type ChordDetectionOptions, ChordQuality, type ChromaResult, type ClippingRegion, type ClippingReport, type CompressorDetector, type CompressorOptions, type CqtResult, type DeclickOptions, type DeclipOptions, type DecomposeResult, type DecrackleMode, type DecrackleOptions, type DehumOptions, type DenoiseClassicalMode, type DenoiseClassicalNoiseEstimator, type DenoiseClassicalOptions, type DereverbClassicalOptions, type DynamicRangeReport, type Dynamics, type DynamicsAnalysisResult, type DynamicsResult, EXPECTED_ENGINE_ABI_VERSION, type EngineAutomationPoint, type EngineBounceOptions, type EngineBounceResult, type EngineCapabilities, type EngineCaptureStatus, type EngineClip, type EngineFreezeOptions, type EngineFreezeResult, type EngineGraphSpec, type EngineMarker, type EngineMeterTelemetry, type EngineMetronomeConfig, type EngineParameterInfo, type EngineTelemetry, type EngineTransportState, type EqBand, type EqBandPhase, type EqBandType, type EqCoeffMode, type EqMatchOptions, type EqSpectrumSnapshot, type EqStereoPlacement, type FrameBuffer, type GateOptions, type GoniometerPoint, type HpssResult, type HpssWithResidualResult, type Key, type KeyCandidate, type KeyDetectionOptions, KeyProfile, type KeyProfileName, type LufsResult, type MasteringChainConfig, type MasteringChainResult, type MasteringPreset, type MasteringProcessorParams, type MasteringResult, type MasteringStereoChainResult, type MasteringStereoResult, type Matrix2dResult, type MelPowerResult, type MelSpectrogramResult, type MelodyPoint, type MelodyResult, type MeterTap, type MfccResult, type MixMeterSnapshot, type MixOptions, type MixResult, Mixer, type MixerProcessResult, type MixerRealtimeBuffer, Mode, type PairAnalysis, type PairProcessor, type PanLaw, type PanMode, type PatternScore, type PhaseScopeReport, PitchClass as Pitch, PitchClass, type PitchResult, type ProgressiveEstimate, RealtimeEngine, RealtimeVoiceChanger, type RealtimeVoiceChangerConfigInput, type RealtimeVoiceChangerInterleavedBuffer, type RealtimeVoiceChangerMonoBuffer, type RealtimeVoiceChangerPlanarBuffer, type RealtimeVoiceChangerPodConfig, type RhythmAnalysisResult, type RhythmFeatures, type RirResult, type RirSynthOptions, type RoomEstimateOptions, type RoomEstimateResult, type RoomGeometryOptions, type RoomMorphOptions, type Section, SectionType, type SendTiming, type SoloProcessor, type SpectrumOptions, type SpectrumReport, type StereoAnalysis, type StftPowerResult, type StftResult, StreamAnalyzer, type StreamConfig, type StreamFramesI16, type StreamFramesU8, StreamingEqualizer, type StreamingEqualizerConfig, StreamingMasteringChain, type StreamingPlatform, StreamingRetune, type StreamingRetuneConfig, type TempogramMode, type Timbre, type TimbreAnalysisResult, type TimbreFrame, type TimeSignature, type TransientShaperOptions, type TrimSilenceMode, type TrimSilenceOptions, type ValidateOptions, type VectorscopeReport, type VoiceChangeRealtimeOptions, type VoicePresetId, amplitudeToDb, analyze, analyzeBpm, analyzeDynamics, analyzeImpulseResponse, analyzeMelody, analyzeRhythm, analyzeSections, analyzeTimbre, analyzeWithProgress, chroma, cqt, cyclicTempogram, dbToAmplitude, dbToPower, decompose, deemphasis, detectAcoustic, detectBeats, detectBpm, detectChords, detectDownbeats, detectKey, detectKeyCandidates, detectOnsets, ebur128LoudnessRange, engineAbiVersion, engineCapabilities, estimateRoom, estimateTuning, fixFrames, fixLength, fourierTempogram, frameSignal, framesToSamples, framesToTime, harmonic, hasFfmpegSupport, hpss, hpssWithResidual, hzToMel, hzToMidi, hzToNote, init, isInitialized, lufs, lufsInterleaved, masterAudio, masterAudioStereo, masterAudioStereoWithProgress, masterAudioWithProgress, mastering, masteringAssistantSuggest, masteringAudioProfile, masteringChain, masteringChainStereo, masteringChainStereoWithProgress, masteringChainWithProgress, masteringDynamicsCompressor, masteringDynamicsGate, masteringDynamicsTransientShaper, masteringPairAnalysisNames, masteringPairAnalyze, masteringPairProcess, masteringPairProcessorNames, masteringPresetNames, masteringProcess, masteringProcessStereo, masteringProcessorNames, masteringRepairDeclick, masteringRepairDeclip, masteringRepairDecrackle, masteringRepairDehum, masteringRepairDenoiseClassical, masteringRepairDereverbClassical, masteringRepairTrimSilence, masteringStereoAnalysisNames, masteringStereoAnalyze, masteringStreamingPreview, melSpectrogram, melToAudio, melToHz, melToStft, meteringCrestFactorDb, meteringDcOffset, meteringDetectClipping, meteringDynamicRange, meteringPeakDb, meteringPhaseScope, meteringRmsDb, meteringSpectrum, meteringStereoCorrelation, meteringStereoWidth, meteringTruePeakDb, meteringVectorscope, mfcc, mfccToAudio, mfccToMel, midiToHz, mixStereo, mixingScenePresetJson, mixingScenePresetNames, momentaryLufs, nnFilter, nnlsChroma, normalize, noteStretch, noteToHz, onsetEnvelope, padCenter, pcen, peakPick, percussive, phaseVocoder, pitchCorrectToMidi, pitchPyin, pitchShift, pitchTuning, pitchYin, plp, polyFeatures, powerToDb, preemphasis, realtimeVoiceChangerPresetConfig, realtimeVoiceChangerPresetJson, realtimeVoiceChangerPresetNames, remix, resample, rmsEnergy, roomMorph, samplesToFrames, scaleCorrectionSemitones, scalePitchClassEnabled, scaleQuantizeMidi, shortTermLufs, spectralBandwidth, spectralCentroid, spectralContrast, spectralFlatness, spectralRolloff, splitSilence, stft, stftDb, synthesizeRir, tempogram, tempogramRatio, timeStretch, timeToFrames, tonnetz, trim, trimSilence, validateRealtimeVoiceChangerPresetJson, vectorNormalize, version, voiceChange, voiceChangeRealtime, voiceChangerAbiVersion, voiceCharacterPresetId, vqt, zeroCrossingRate, zeroCrossings };
|
package/dist/index.js
CHANGED
|
@@ -359,6 +359,31 @@ var RealtimeEngine = class {
|
|
|
359
359
|
process(channels) {
|
|
360
360
|
return this.native.process(channels);
|
|
361
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Allocates persistent per-channel WASM-heap scratch for the zero-copy
|
|
364
|
+
* `getChannelBuffer` / `processPrepared` realtime path. Call once (off the
|
|
365
|
+
* audio thread) before driving `processPrepared` from an AudioWorklet so the
|
|
366
|
+
* render callback never allocates on the C++/JS heap.
|
|
367
|
+
*/
|
|
368
|
+
prepareChannels(numChannels, maxFrames) {
|
|
369
|
+
this.native.prepareChannels(numChannels, maxFrames);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Returns a Float32Array view onto the persistent WASM-heap scratch for one
|
|
373
|
+
* channel (valid for up to `numFrames`). Fill it, call `processPrepared`, then
|
|
374
|
+
* read the same view back. Re-acquire after WASM memory growth.
|
|
375
|
+
*/
|
|
376
|
+
getChannelBuffer(channel, numFrames) {
|
|
377
|
+
return this.native.getChannelBuffer(channel, numFrames);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Runs the engine in place over the prepared per-channel scratch buffers.
|
|
381
|
+
* Allocation-free: safe to call on the AudioWorklet render thread after
|
|
382
|
+
* `prepareChannels`.
|
|
383
|
+
*/
|
|
384
|
+
processPrepared(numFrames) {
|
|
385
|
+
this.native.processPrepared(numFrames);
|
|
386
|
+
}
|
|
362
387
|
processWithMonitor(channels) {
|
|
363
388
|
return this.native.processWithMonitor(channels);
|
|
364
389
|
}
|
|
@@ -630,6 +655,33 @@ function detectAcoustic(samples, sampleRate = 48e3, nOctaveBands = 6, nThirdOcta
|
|
|
630
655
|
);
|
|
631
656
|
return result;
|
|
632
657
|
}
|
|
658
|
+
function synthesizeRir(options = {}) {
|
|
659
|
+
if (!module) {
|
|
660
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
661
|
+
}
|
|
662
|
+
if (typeof module.synthesizeRir !== "function") {
|
|
663
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
664
|
+
}
|
|
665
|
+
return module.synthesizeRir(options);
|
|
666
|
+
}
|
|
667
|
+
function estimateRoom(samples, sampleRate = 48e3, options = {}) {
|
|
668
|
+
if (!module) {
|
|
669
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
670
|
+
}
|
|
671
|
+
if (typeof module.estimateRoom !== "function") {
|
|
672
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
673
|
+
}
|
|
674
|
+
return module.estimateRoom(samples, sampleRate, options);
|
|
675
|
+
}
|
|
676
|
+
function roomMorph(samples, sampleRate, options = {}) {
|
|
677
|
+
if (!module) {
|
|
678
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
679
|
+
}
|
|
680
|
+
if (typeof module.roomMorph !== "function") {
|
|
681
|
+
throw new Error("libsonare was built without acoustic-simulation support");
|
|
682
|
+
}
|
|
683
|
+
return module.roomMorph(samples, sampleRate, options);
|
|
684
|
+
}
|
|
633
685
|
function analyzeWithProgress(samples, sampleRate = 22050, onProgress) {
|
|
634
686
|
if (!module) {
|
|
635
687
|
throw new Error("Module not initialized. Call init() first.");
|
|
@@ -682,40 +734,46 @@ function hpss(samples, sampleRate = 22050, kernelHarmonic = 31, kernelPercussive
|
|
|
682
734
|
}
|
|
683
735
|
return module.hpss(samples, sampleRate, kernelHarmonic, kernelPercussive);
|
|
684
736
|
}
|
|
685
|
-
function harmonic(samples, sampleRate) {
|
|
737
|
+
function harmonic(samples, sampleRate, options = {}) {
|
|
686
738
|
if (!module) {
|
|
687
739
|
throw new Error("Module not initialized. Call init() first.");
|
|
688
740
|
}
|
|
741
|
+
assertSamples("harmonic", samples, options.validate !== false);
|
|
689
742
|
return module.harmonic(samples, sampleRate);
|
|
690
743
|
}
|
|
691
|
-
function percussive(samples, sampleRate) {
|
|
744
|
+
function percussive(samples, sampleRate, options = {}) {
|
|
692
745
|
if (!module) {
|
|
693
746
|
throw new Error("Module not initialized. Call init() first.");
|
|
694
747
|
}
|
|
748
|
+
assertSamples("percussive", samples, options.validate !== false);
|
|
695
749
|
return module.percussive(samples, sampleRate);
|
|
696
750
|
}
|
|
697
|
-
function timeStretch(samples, sampleRate, rate) {
|
|
751
|
+
function timeStretch(samples, sampleRate, rate, options = {}) {
|
|
698
752
|
if (!module) {
|
|
699
753
|
throw new Error("Module not initialized. Call init() first.");
|
|
700
754
|
}
|
|
755
|
+
assertSamples("timeStretch", samples, options.validate !== false);
|
|
701
756
|
return module.timeStretch(samples, sampleRate, rate);
|
|
702
757
|
}
|
|
703
|
-
function pitchShift(samples, sampleRate, semitones) {
|
|
758
|
+
function pitchShift(samples, sampleRate, semitones, options = {}) {
|
|
704
759
|
if (!module) {
|
|
705
760
|
throw new Error("Module not initialized. Call init() first.");
|
|
706
761
|
}
|
|
762
|
+
assertSamples("pitchShift", samples, options.validate !== false);
|
|
707
763
|
return module.pitchShift(samples, sampleRate, semitones);
|
|
708
764
|
}
|
|
709
|
-
function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69) {
|
|
765
|
+
function pitchCorrectToMidi(samples, sampleRate = 22050, currentMidi = 69, targetMidi = 69, options = {}) {
|
|
710
766
|
if (!module) {
|
|
711
767
|
throw new Error("Module not initialized. Call init() first.");
|
|
712
768
|
}
|
|
769
|
+
assertSamples("pitchCorrectToMidi", samples, options.validate !== false);
|
|
713
770
|
return module.pitchCorrectToMidi(samples, sampleRate, currentMidi, targetMidi);
|
|
714
771
|
}
|
|
715
|
-
function noteStretch(samples, sampleRate = 22050, onsetSample = 0, offsetSample = 0, stretchRatio = 1) {
|
|
772
|
+
function noteStretch(samples, sampleRate = 22050, onsetSample = 0, offsetSample = 0, stretchRatio = 1, options = {}) {
|
|
716
773
|
if (!module) {
|
|
717
774
|
throw new Error("Module not initialized. Call init() first.");
|
|
718
775
|
}
|
|
776
|
+
assertSamples("noteStretch", samples, options.validate !== false);
|
|
719
777
|
return module.noteStretch(samples, sampleRate, onsetSample, offsetSample, stretchRatio);
|
|
720
778
|
}
|
|
721
779
|
function voiceChange(samples, sampleRate = 22050, pitchSemitones = 0, formantFactor = 1, options = {}) {
|
|
@@ -725,10 +783,43 @@ function voiceChange(samples, sampleRate = 22050, pitchSemitones = 0, formantFac
|
|
|
725
783
|
assertSamples("voiceChange", samples, options.validate !== false);
|
|
726
784
|
return module.voiceChange(samples, sampleRate, pitchSemitones, formantFactor);
|
|
727
785
|
}
|
|
728
|
-
function
|
|
786
|
+
function voiceChangeRealtime(samples, options = {}) {
|
|
787
|
+
if (!module) {
|
|
788
|
+
throw new Error("Module not initialized. Call init() first.");
|
|
789
|
+
}
|
|
790
|
+
assertSamples("voiceChangeRealtime", samples, options.validate !== false);
|
|
791
|
+
const channels = options.channels ?? 1;
|
|
792
|
+
if (channels !== 1 && channels !== 2) {
|
|
793
|
+
throw new Error("voiceChangeRealtime: channels must be 1 or 2.");
|
|
794
|
+
}
|
|
795
|
+
const sampleRate = options.sampleRate ?? 48e3;
|
|
796
|
+
const blockSize = Math.max(1, Math.floor(options.blockSize ?? 512));
|
|
797
|
+
const changer = new RealtimeVoiceChanger(options.preset ?? "neutral-monitor");
|
|
798
|
+
try {
|
|
799
|
+
changer.prepare(sampleRate, blockSize, channels);
|
|
800
|
+
const out = new Float32Array(samples.length);
|
|
801
|
+
if (channels === 1) {
|
|
802
|
+
for (let offset = 0; offset < samples.length; offset += blockSize) {
|
|
803
|
+
const block = samples.subarray(offset, Math.min(offset + blockSize, samples.length));
|
|
804
|
+
out.set(changer.processMono(block), offset);
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
const frameStride = blockSize * 2;
|
|
808
|
+
for (let offset = 0; offset < samples.length; offset += frameStride) {
|
|
809
|
+
const block = samples.subarray(offset, Math.min(offset + frameStride, samples.length));
|
|
810
|
+
out.set(changer.processInterleaved(block, 2), offset);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return out;
|
|
814
|
+
} finally {
|
|
815
|
+
changer.delete();
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function normalize(samples, sampleRate, targetDb = 0, options = {}) {
|
|
729
819
|
if (!module) {
|
|
730
820
|
throw new Error("Module not initialized. Call init() first.");
|
|
731
821
|
}
|
|
822
|
+
assertSamples("normalize", samples, options.validate !== false);
|
|
732
823
|
return module.normalize(samples, sampleRate, targetDb);
|
|
733
824
|
}
|
|
734
825
|
function mastering(samples, sampleRate = 22050, targetLufs = -14, ceilingDb = -1, truePeakOversample = 4) {
|
|
@@ -2356,7 +2447,7 @@ var StreamAnalyzer = class {
|
|
|
2356
2447
|
throw new Error("Module not initialized. Call init() first.");
|
|
2357
2448
|
}
|
|
2358
2449
|
this.analyzer = new module.StreamAnalyzer(
|
|
2359
|
-
config.sampleRate,
|
|
2450
|
+
config.sampleRate ?? 44100,
|
|
2360
2451
|
config.nFft ?? 2048,
|
|
2361
2452
|
config.hopLength ?? 512,
|
|
2362
2453
|
config.nMels ?? 128,
|
|
@@ -2577,6 +2668,7 @@ export {
|
|
|
2577
2668
|
ebur128LoudnessRange,
|
|
2578
2669
|
engineAbiVersion,
|
|
2579
2670
|
engineCapabilities,
|
|
2671
|
+
estimateRoom,
|
|
2580
2672
|
estimateTuning,
|
|
2581
2673
|
fixFrames,
|
|
2582
2674
|
fixLength,
|
|
@@ -2677,6 +2769,7 @@ export {
|
|
|
2677
2769
|
remix,
|
|
2678
2770
|
resample,
|
|
2679
2771
|
rmsEnergy,
|
|
2772
|
+
roomMorph,
|
|
2680
2773
|
samplesToFrames,
|
|
2681
2774
|
scaleCorrectionSemitones,
|
|
2682
2775
|
scalePitchClassEnabled,
|
|
@@ -2690,6 +2783,7 @@ export {
|
|
|
2690
2783
|
splitSilence,
|
|
2691
2784
|
stft,
|
|
2692
2785
|
stftDb,
|
|
2786
|
+
synthesizeRir,
|
|
2693
2787
|
tempogram,
|
|
2694
2788
|
tempogramRatio,
|
|
2695
2789
|
timeStretch,
|
|
@@ -2701,6 +2795,7 @@ export {
|
|
|
2701
2795
|
vectorNormalize,
|
|
2702
2796
|
version,
|
|
2703
2797
|
voiceChange,
|
|
2798
|
+
voiceChangeRealtime,
|
|
2704
2799
|
voiceChangerAbiVersion,
|
|
2705
2800
|
voiceCharacterPresetId,
|
|
2706
2801
|
vqt,
|