@octoseq/mir 0.1.0-main.994cb4e → 0.1.0-main.9ea6d2e
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/{chunk-OLIDGECY.js → chunk-CI7QGWP7.js} +44 -3
- package/dist/chunk-CI7QGWP7.js.map +1 -0
- package/dist/index.d.ts +475 -7
- package/dist/index.js +1495 -90
- package/dist/index.js.map +1 -1
- package/dist/{runMir-CWsxri61.d.ts → runMir-D4t7WsN0.d.ts} +1 -1
- package/dist/runner/runMir.d.ts +2 -2
- package/dist/runner/runMir.js +1 -1
- package/dist/runner/workerProtocol.d.ts +1 -1
- package/dist/{types-D6eBRofe.d.ts → types-ifqndzu7.d.ts} +86 -6
- package/package.json +1 -1
- package/src/dsp/bandCqt.ts +662 -0
- package/src/dsp/bandEvents.ts +351 -0
- package/src/dsp/bandMir.ts +69 -0
- package/src/dsp/bandProposal.ts +30 -2
- package/src/dsp/customSignalReduction.ts +841 -0
- package/src/dsp/frequencyBand.ts +46 -3
- package/src/dsp/peakPicking.ts +519 -0
- package/src/dsp/spectral.ts +54 -0
- package/src/index.ts +93 -1
- package/src/runner/runMir.ts +24 -1
- package/src/types.ts +97 -4
- package/dist/chunk-OLIDGECY.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
import { B as BeatCandidate, T as TempoHypothesis, P as PhaseAlignmentConfig, a as PhaseHypothesis, M as MusicalTimeSegment, b as BeatPosition, c as MusicalTimeStructure, d as BeatGrid, F as FrequencySegment, e as FrequencyBand, f as FrequencyBandStructure, g as FrequencyBoundsAtTime, h as FrequencyKeyframe, i as BandMirFunctionId, j as BandMir1DResult, C as CqtConfig,
|
|
2
|
-
export {
|
|
3
|
-
import { S as Spectrogram, M as MirGPU, A as AudioBufferLike$1 } from './runMir-
|
|
4
|
-
export { a as SpectrogramConfig, r as runMir, s as spectrogram } from './runMir-
|
|
1
|
+
import { B as BeatCandidate, T as TempoHypothesis, P as PhaseAlignmentConfig, a as PhaseHypothesis, M as MusicalTimeSegment, b as BeatPosition, c as MusicalTimeStructure, d as BeatGrid, F as FrequencySegment, e as FrequencyBand, f as FrequencyBandStructure, g as FrequencyBoundsAtTime, h as FrequencyKeyframe, i as BandMirFunctionId, j as BandMir1DResult, k as BandEventFunctionId, l as BandEventsResult, C as CqtConfig, m as BandCqtFunctionId, n as BandCqt1DResult, o as CqtSpectrogram, p as MirRunMeta, q as CqtSignalResult, r as CqtSignalId, s as BandProposalConfig, t as BandProposalResult } from './types-ifqndzu7.js';
|
|
2
|
+
export { Q as BandEventDiagnostics, N as BandMirDiagnostics, O as BandMirEvent, S as BandProposal, R as BandProposalSource, E as BeatCandidateSource, G as BeatCandidatesResult, L as FrequencyBandProvenance, K as FrequencyBandTimeScope, w as Mir1DResult, x as Mir2DResult, D as MirAudioPayload, u as MirBackend, z as MirFunctionId, y as MirResult, A as MirRunRequest, v as MirRunTimings, J as MusicalTimeProvenance, I as TempoHypothesesResult, H as TempoHypothesisEvidence } from './types-ifqndzu7.js';
|
|
3
|
+
import { S as Spectrogram, M as MirGPU, A as AudioBufferLike$1 } from './runMir-D4t7WsN0.js';
|
|
4
|
+
export { a as SpectrogramConfig, r as runMir, s as spectrogram } from './runMir-D4t7WsN0.js';
|
|
5
5
|
|
|
6
|
+
type AmplitudeEnvelopeConfig = {
|
|
7
|
+
/** Hop size in samples (determines time resolution). Default: 512 */
|
|
8
|
+
hopSize?: number;
|
|
9
|
+
/** Window size for RMS calculation. Default: same as hopSize */
|
|
10
|
+
windowSize?: number;
|
|
11
|
+
};
|
|
12
|
+
type AmplitudeEnvelopeResult = {
|
|
13
|
+
times: Float32Array;
|
|
14
|
+
values: Float32Array;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Amplitude envelope from raw audio samples.
|
|
18
|
+
*
|
|
19
|
+
* Computes RMS amplitude over windows of the time-domain signal.
|
|
20
|
+
* More efficient than spectrogram-based computation for full spectrum.
|
|
21
|
+
*
|
|
22
|
+
* @param samples - Mono audio samples
|
|
23
|
+
* @param sampleRate - Sample rate of the audio
|
|
24
|
+
* @param config - Configuration options
|
|
25
|
+
* @returns Times (seconds) and RMS amplitude values
|
|
26
|
+
*/
|
|
27
|
+
declare function amplitudeEnvelope(samples: Float32Array, sampleRate: number, config?: AmplitudeEnvelopeConfig): AmplitudeEnvelopeResult;
|
|
6
28
|
/**
|
|
7
29
|
* Spectral centroid per frame (Hz).
|
|
8
30
|
*
|
|
@@ -279,6 +301,95 @@ declare function computePhaseHypotheses(bpm: number, candidates: BeatCandidate[]
|
|
|
279
301
|
*/
|
|
280
302
|
declare function generateBeatTimes(bpm: number, phaseOffset: number, userNudge: number, audioDuration: number): number[];
|
|
281
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Peak Picking Algorithm
|
|
306
|
+
*
|
|
307
|
+
* Detects local maxima in a 1D signal that exceed a threshold.
|
|
308
|
+
* Used to create event streams from continuous signals.
|
|
309
|
+
*/
|
|
310
|
+
interface PeakPickingParams {
|
|
311
|
+
/** Minimum normalized value (0-1) for a peak to be considered. Default: 0.3 */
|
|
312
|
+
threshold: number;
|
|
313
|
+
/** Minimum time between peaks in seconds. Default: 0.1 */
|
|
314
|
+
minDistance: number;
|
|
315
|
+
/** Number of samples to look back for local max comparison. Default: 2 */
|
|
316
|
+
preMax?: number;
|
|
317
|
+
/** Number of samples to look forward for local max comparison. Default: 2 */
|
|
318
|
+
postMax?: number;
|
|
319
|
+
}
|
|
320
|
+
interface PeakPickingResult {
|
|
321
|
+
/** Times of detected peaks (seconds) */
|
|
322
|
+
times: Float32Array;
|
|
323
|
+
/** Normalized strength of each peak (0-1, based on normalized value) */
|
|
324
|
+
strengths: Float32Array;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Default peak picking parameters
|
|
328
|
+
*/
|
|
329
|
+
declare const DEFAULT_PEAK_PICKING_PARAMS: Required<PeakPickingParams>;
|
|
330
|
+
/**
|
|
331
|
+
* Pick peaks from a continuous signal.
|
|
332
|
+
*
|
|
333
|
+
* @param times - Time values in seconds (Float32Array)
|
|
334
|
+
* @param values - Signal values (Float32Array)
|
|
335
|
+
* @param params - Peak picking parameters
|
|
336
|
+
* @returns Detected peaks with times and strengths
|
|
337
|
+
*/
|
|
338
|
+
declare function pickPeaks(times: Float32Array, values: Float32Array, params?: Partial<PeakPickingParams>): PeakPickingResult;
|
|
339
|
+
/**
|
|
340
|
+
* Result from adaptive peak picking, including the threshold curve for visualization.
|
|
341
|
+
*/
|
|
342
|
+
interface AdaptivePeakPickingResult extends PeakPickingResult {
|
|
343
|
+
/** The adaptive threshold curve (normalized 0-1) for visualization */
|
|
344
|
+
thresholdCurve: Float32Array;
|
|
345
|
+
/** Time values corresponding to threshold curve samples */
|
|
346
|
+
thresholdTimes: Float32Array;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Compute the adaptive threshold curve for visualization.
|
|
350
|
+
* This is the normalized threshold that would be used by pickPeaksAdaptive.
|
|
351
|
+
*
|
|
352
|
+
* @param values - Signal values (Float32Array)
|
|
353
|
+
* @param windowSize - Window size for local statistics (in samples)
|
|
354
|
+
* @param thresholdMultiplier - Multiplier for local std (default 1.5)
|
|
355
|
+
* @returns Normalized threshold curve (0-1 range)
|
|
356
|
+
*/
|
|
357
|
+
declare function computeAdaptiveThreshold(values: Float32Array, windowSize?: number, thresholdMultiplier?: number): Float32Array;
|
|
358
|
+
/**
|
|
359
|
+
* Pick peaks with adaptive threshold based on local statistics.
|
|
360
|
+
*
|
|
361
|
+
* @param times - Time values in seconds
|
|
362
|
+
* @param values - Signal values
|
|
363
|
+
* @param windowSize - Window size for local statistics (in samples)
|
|
364
|
+
* @param params - Base peak picking parameters (threshold used as multiplier of local std)
|
|
365
|
+
* @param includeThresholdCurve - If true, returns the threshold curve for visualization
|
|
366
|
+
*/
|
|
367
|
+
declare function pickPeaksAdaptive(times: Float32Array, values: Float32Array, windowSize?: number, params?: Partial<PeakPickingParams>, includeThresholdCurve?: boolean): PeakPickingResult | AdaptivePeakPickingResult;
|
|
368
|
+
/**
|
|
369
|
+
* Hysteresis gate parameters for peak filtering.
|
|
370
|
+
*/
|
|
371
|
+
interface HysteresisGateParams {
|
|
372
|
+
/** Upper threshold (0-1) - signal must exceed this to trigger "on" state */
|
|
373
|
+
onThreshold: number;
|
|
374
|
+
/** Lower threshold (0-1) - signal must fall below this to trigger "off" state */
|
|
375
|
+
offThreshold: number;
|
|
376
|
+
/** Minimum time between peaks in seconds */
|
|
377
|
+
minDistance: number;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Apply hysteresis gating to peaks.
|
|
381
|
+
* Peaks are only kept if the signal has dropped below offThreshold since the last peak.
|
|
382
|
+
* This prevents multiple triggers during sustained high-value regions.
|
|
383
|
+
*
|
|
384
|
+
* @param times - Time values of the original signal
|
|
385
|
+
* @param values - Values of the original signal (for checking hysteresis)
|
|
386
|
+
* @param peakTimes - Times of detected peaks
|
|
387
|
+
* @param peakStrengths - Strengths of detected peaks
|
|
388
|
+
* @param params - Hysteresis gate parameters
|
|
389
|
+
* @returns Filtered peaks after hysteresis gating
|
|
390
|
+
*/
|
|
391
|
+
declare function applyHysteresisGate(times: Float32Array, values: Float32Array, peakTimes: Float32Array, peakStrengths: Float32Array, params: HysteresisGateParams): PeakPickingResult;
|
|
392
|
+
|
|
282
393
|
/**
|
|
283
394
|
* Musical Time utilities for B4.
|
|
284
395
|
*
|
|
@@ -419,6 +530,8 @@ declare function createConstantBand(label: string, lowHz: number, highHz: number
|
|
|
419
530
|
enabled?: boolean;
|
|
420
531
|
sortOrder?: number;
|
|
421
532
|
id?: string;
|
|
533
|
+
/** The audio source this band belongs to. Defaults to "mixdown". */
|
|
534
|
+
sourceId?: string;
|
|
422
535
|
}): FrequencyBand;
|
|
423
536
|
/**
|
|
424
537
|
* Create a sectioned band (applies only to a time range).
|
|
@@ -435,6 +548,8 @@ declare function createSectionedBand(label: string, lowHz: number, highHz: numbe
|
|
|
435
548
|
enabled?: boolean;
|
|
436
549
|
sortOrder?: number;
|
|
437
550
|
id?: string;
|
|
551
|
+
/** The audio source this band belongs to. Defaults to "mixdown". */
|
|
552
|
+
sourceId?: string;
|
|
438
553
|
}): FrequencyBand;
|
|
439
554
|
/**
|
|
440
555
|
* Create standard frequency bands for a track.
|
|
@@ -448,9 +563,10 @@ declare function createSectionedBand(label: string, lowHz: number, highHz: numbe
|
|
|
448
563
|
* - Highs: 4000-20000 Hz
|
|
449
564
|
*
|
|
450
565
|
* @param duration - Track duration in seconds
|
|
566
|
+
* @param sourceId - The audio source these bands belong to. Defaults to "mixdown".
|
|
451
567
|
* @returns Array of FrequencyBand objects
|
|
452
568
|
*/
|
|
453
|
-
declare function createStandardBands(duration: number): FrequencyBand[];
|
|
569
|
+
declare function createStandardBands(duration: number, sourceId?: string): FrequencyBand[];
|
|
454
570
|
/**
|
|
455
571
|
* Get all bands active at a given time.
|
|
456
572
|
*
|
|
@@ -460,9 +576,10 @@ declare function createStandardBands(duration: number): FrequencyBand[];
|
|
|
460
576
|
*
|
|
461
577
|
* @param structure - Frequency band structure (can be null)
|
|
462
578
|
* @param time - Time in seconds
|
|
579
|
+
* @param sourceId - Optional: filter to a specific audio source
|
|
463
580
|
* @returns Array of active bands
|
|
464
581
|
*/
|
|
465
|
-
declare function bandsActiveAt(structure: FrequencyBandStructure | null, time: number): FrequencyBand[];
|
|
582
|
+
declare function bandsActiveAt(structure: FrequencyBandStructure | null, time: number, sourceId?: string): FrequencyBand[];
|
|
466
583
|
/**
|
|
467
584
|
* Get frequency bounds for a band at a given time.
|
|
468
585
|
*
|
|
@@ -755,6 +872,18 @@ declare function bandOnsetStrength(spec: Spectrogram, band: FrequencyBand, optio
|
|
|
755
872
|
* @returns Band MIR result with spectral flux
|
|
756
873
|
*/
|
|
757
874
|
declare function bandSpectralFlux(spec: Spectrogram, band: FrequencyBand, options?: BandMirOptions): BandMir1DResult;
|
|
875
|
+
/**
|
|
876
|
+
* Compute spectral centroid for a frequency band.
|
|
877
|
+
*
|
|
878
|
+
* Returns the weighted average of frequency bins within the band (center of mass).
|
|
879
|
+
* Output is in Hz per frame.
|
|
880
|
+
*
|
|
881
|
+
* @param spec - Source spectrogram
|
|
882
|
+
* @param band - Frequency band to analyze
|
|
883
|
+
* @param options - Computation options
|
|
884
|
+
* @returns Band MIR result with spectral centroid in Hz
|
|
885
|
+
*/
|
|
886
|
+
declare function bandSpectralCentroid(spec: Spectrogram, band: FrequencyBand, options?: BandMirOptions): BandMir1DResult;
|
|
758
887
|
type BandMirBatchRequest = {
|
|
759
888
|
bands: FrequencyBand[];
|
|
760
889
|
functions: BandMirFunctionId[];
|
|
@@ -788,6 +917,187 @@ declare function runBandMirBatch(spec: Spectrogram, request: BandMirBatchRequest
|
|
|
788
917
|
*/
|
|
789
918
|
declare function getBandMirFunctionLabel(fn: BandMirFunctionId): string;
|
|
790
919
|
|
|
920
|
+
/**
|
|
921
|
+
* Band Event Extraction for F3.
|
|
922
|
+
*
|
|
923
|
+
* These functions extract discrete events (onset peaks, beat candidates)
|
|
924
|
+
* from band-scoped 1D signals.
|
|
925
|
+
*/
|
|
926
|
+
|
|
927
|
+
type BandOnsetPeaksOptions = {
|
|
928
|
+
/** Minimum inter-peak interval in seconds. Default: 0.0625 (~0.125 beats at 120 BPM). */
|
|
929
|
+
minIntervalSec?: number;
|
|
930
|
+
/** Adaptive threshold factor. Default: 0.8 (conservative for bands). */
|
|
931
|
+
adaptiveFactor?: number;
|
|
932
|
+
/** Use strict peak detection (> neighbors). Default: true. */
|
|
933
|
+
strict?: boolean;
|
|
934
|
+
};
|
|
935
|
+
type BandBeatCandidatesOptions = {
|
|
936
|
+
/** Minimum inter-candidate interval in seconds. Default: 0.1. */
|
|
937
|
+
minIntervalSec?: number;
|
|
938
|
+
/** Threshold factor for adaptive detection. Lower = more candidates. Default: 0.5. */
|
|
939
|
+
thresholdFactor?: number;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* Extract onset peaks from a band MIR 1D signal.
|
|
943
|
+
*
|
|
944
|
+
* Uses peak picking with conservative defaults optimized for band-scoped
|
|
945
|
+
* extraction. Typically applied to bandOnsetStrength or bandAmplitudeEnvelope.
|
|
946
|
+
*
|
|
947
|
+
* @param signal - The band MIR 1D result to extract peaks from
|
|
948
|
+
* @param options - Peak picking options
|
|
949
|
+
* @returns Band events result with onset peaks
|
|
950
|
+
*/
|
|
951
|
+
declare function bandOnsetPeaks(signal: BandMir1DResult, options?: BandOnsetPeaksOptions): BandEventsResult;
|
|
952
|
+
/**
|
|
953
|
+
* Extract beat candidates from a band's onset peaks.
|
|
954
|
+
*
|
|
955
|
+
* Similar to full-track beat candidate detection but simplified for
|
|
956
|
+
* single-band input. Uses the onset peaks to identify beat-like events.
|
|
957
|
+
*
|
|
958
|
+
* @param onsetPeaks - Band onset peaks result
|
|
959
|
+
* @param options - Beat candidate options
|
|
960
|
+
* @returns Band events result with beat candidates
|
|
961
|
+
*/
|
|
962
|
+
declare function bandBeatCandidates(onsetPeaks: BandEventsResult, options?: BandBeatCandidatesOptions): BandEventsResult;
|
|
963
|
+
type BandEventsBatchRequest = {
|
|
964
|
+
/** Band MIR results to extract events from (keyed by bandId) */
|
|
965
|
+
bandMirResults: Map<string, BandMir1DResult[]>;
|
|
966
|
+
/** Event functions to run */
|
|
967
|
+
functions: BandEventFunctionId[];
|
|
968
|
+
/** Source signal function to use for onset peaks. Default: bandOnsetStrength */
|
|
969
|
+
sourceFunction?: "bandOnsetStrength" | "bandAmplitudeEnvelope";
|
|
970
|
+
/** Options for onset peaks extraction */
|
|
971
|
+
onsetPeaksOptions?: BandOnsetPeaksOptions;
|
|
972
|
+
/** Options for beat candidates extraction */
|
|
973
|
+
beatCandidatesOptions?: BandBeatCandidatesOptions;
|
|
974
|
+
};
|
|
975
|
+
type BandEventsBatchResult = {
|
|
976
|
+
/** Results keyed by bandId, each containing results for requested functions */
|
|
977
|
+
results: Map<string, BandEventsResult[]>;
|
|
978
|
+
/** Total computation time in ms */
|
|
979
|
+
totalTimingMs: number;
|
|
980
|
+
};
|
|
981
|
+
/**
|
|
982
|
+
* Run band event extraction for multiple bands.
|
|
983
|
+
*
|
|
984
|
+
* @param request - Batch request specifying bands, functions, and options
|
|
985
|
+
* @returns Map of results by band ID
|
|
986
|
+
*/
|
|
987
|
+
declare function runBandEventsBatch(request: BandEventsBatchRequest): Promise<BandEventsBatchResult>;
|
|
988
|
+
/**
|
|
989
|
+
* Get a human-readable label for a band event function.
|
|
990
|
+
*
|
|
991
|
+
* @param fn - Band event function ID
|
|
992
|
+
* @returns Human-readable label
|
|
993
|
+
*/
|
|
994
|
+
declare function getBandEventFunctionLabel(fn: BandEventFunctionId): string;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Band-Scoped CQT utilities for F3.
|
|
998
|
+
*
|
|
999
|
+
* These functions compute CQT-derived features (harmonic energy, bass pitch motion,
|
|
1000
|
+
* tonal stability) for frequency bands by applying spectral masks to a CQT
|
|
1001
|
+
* spectrogram.
|
|
1002
|
+
*
|
|
1003
|
+
* CQT uses log-frequency bins, so band masking requires mapping Hz ranges
|
|
1004
|
+
* to CQT bin indices using hzToCqtBin().
|
|
1005
|
+
*/
|
|
1006
|
+
|
|
1007
|
+
type BandCqtOptions = {
|
|
1008
|
+
/** Soft edge width in bins for mask transitions. Default: 0 */
|
|
1009
|
+
edgeSmoothBins?: number;
|
|
1010
|
+
/** Optional cancellation hook */
|
|
1011
|
+
isCancelled?: () => boolean;
|
|
1012
|
+
};
|
|
1013
|
+
type MaskedCqtSpectrogram = {
|
|
1014
|
+
/** Original CQT times */
|
|
1015
|
+
times: Float32Array;
|
|
1016
|
+
/** Masked CQT magnitudes */
|
|
1017
|
+
magnitudes: Float32Array[];
|
|
1018
|
+
/** CQT config */
|
|
1019
|
+
config: CqtConfig;
|
|
1020
|
+
/** Energy retained per frame (0-1) */
|
|
1021
|
+
energyRetainedPerFrame: Float32Array;
|
|
1022
|
+
/** CQT bin frequencies */
|
|
1023
|
+
binFrequencies: Float32Array;
|
|
1024
|
+
};
|
|
1025
|
+
/**
|
|
1026
|
+
* Apply a frequency band mask to a CQT spectrogram.
|
|
1027
|
+
*
|
|
1028
|
+
* Maps the band's Hz range to CQT bin indices and masks accordingly.
|
|
1029
|
+
*
|
|
1030
|
+
* @param cqt - Source CQT spectrogram
|
|
1031
|
+
* @param band - Frequency band to apply
|
|
1032
|
+
* @param options - Masking options
|
|
1033
|
+
* @returns Masked CQT spectrogram with energy retention diagnostics
|
|
1034
|
+
*/
|
|
1035
|
+
declare function applyBandMaskToCqt(cqt: CqtSpectrogram, band: FrequencyBand, options?: BandCqtOptions): MaskedCqtSpectrogram;
|
|
1036
|
+
/**
|
|
1037
|
+
* Compute harmonic energy for a frequency band using CQT.
|
|
1038
|
+
*
|
|
1039
|
+
* Measures the ratio of energy at harmonic intervals within the band.
|
|
1040
|
+
* Adapted from cqtSignals.ts:harmonicEnergy.
|
|
1041
|
+
*
|
|
1042
|
+
* @param cqt - Source CQT spectrogram
|
|
1043
|
+
* @param band - Frequency band to analyze
|
|
1044
|
+
* @param options - Computation options
|
|
1045
|
+
* @returns Band CQT result with harmonic energy
|
|
1046
|
+
*/
|
|
1047
|
+
declare function bandCqtHarmonicEnergy(cqt: CqtSpectrogram, band: FrequencyBand, options?: BandCqtOptions): BandCqt1DResult;
|
|
1048
|
+
/**
|
|
1049
|
+
* Compute bass pitch motion for a frequency band using CQT.
|
|
1050
|
+
*
|
|
1051
|
+
* Measures pitch movement in bass-range CQT bins within the band.
|
|
1052
|
+
* Most meaningful for bands overlapping the bass range (20-300 Hz).
|
|
1053
|
+
*
|
|
1054
|
+
* @param cqt - Source CQT spectrogram
|
|
1055
|
+
* @param band - Frequency band to analyze
|
|
1056
|
+
* @param options - Computation options
|
|
1057
|
+
* @returns Band CQT result with bass pitch motion
|
|
1058
|
+
*/
|
|
1059
|
+
declare function bandCqtBassPitchMotion(cqt: CqtSpectrogram, band: FrequencyBand, options?: BandCqtOptions): BandCqt1DResult;
|
|
1060
|
+
/**
|
|
1061
|
+
* Compute tonal stability for a frequency band using CQT.
|
|
1062
|
+
*
|
|
1063
|
+
* Measures consistency of chroma distribution over time within the band.
|
|
1064
|
+
* Adapted from cqtSignals.ts:tonalStability.
|
|
1065
|
+
*
|
|
1066
|
+
* @param cqt - Source CQT spectrogram
|
|
1067
|
+
* @param band - Frequency band to analyze
|
|
1068
|
+
* @param options - Computation options
|
|
1069
|
+
* @returns Band CQT result with tonal stability
|
|
1070
|
+
*/
|
|
1071
|
+
declare function bandCqtTonalStability(cqt: CqtSpectrogram, band: FrequencyBand, options?: BandCqtOptions): BandCqt1DResult;
|
|
1072
|
+
type BandCqtBatchRequest = {
|
|
1073
|
+
bands: FrequencyBand[];
|
|
1074
|
+
functions: BandCqtFunctionId[];
|
|
1075
|
+
/** Maximum number of bands to process concurrently. Default: 4 */
|
|
1076
|
+
maxConcurrent?: number;
|
|
1077
|
+
};
|
|
1078
|
+
type BandCqtBatchResult = {
|
|
1079
|
+
/** Results keyed by bandId */
|
|
1080
|
+
results: Map<string, BandCqt1DResult[]>;
|
|
1081
|
+
/** Total computation time in ms */
|
|
1082
|
+
totalTimingMs: number;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Run band CQT analysis for multiple bands.
|
|
1086
|
+
*
|
|
1087
|
+
* @param cqt - Source CQT spectrogram
|
|
1088
|
+
* @param request - Batch request specifying bands and functions
|
|
1089
|
+
* @param options - Computation options
|
|
1090
|
+
* @returns Map of results by band ID
|
|
1091
|
+
*/
|
|
1092
|
+
declare function runBandCqtBatch(cqt: CqtSpectrogram, request: BandCqtBatchRequest, options?: BandCqtOptions): Promise<BandCqtBatchResult>;
|
|
1093
|
+
/**
|
|
1094
|
+
* Get a human-readable label for a band CQT function.
|
|
1095
|
+
*
|
|
1096
|
+
* @param fn - Band CQT function ID
|
|
1097
|
+
* @returns Human-readable label
|
|
1098
|
+
*/
|
|
1099
|
+
declare function getBandCqtFunctionLabel(fn: BandCqtFunctionId): string;
|
|
1100
|
+
|
|
791
1101
|
type SpectrogramLike2D = {
|
|
792
1102
|
times: Float32Array;
|
|
793
1103
|
bins: number;
|
|
@@ -981,6 +1291,164 @@ type BandProposalOptions = {
|
|
|
981
1291
|
*/
|
|
982
1292
|
declare function generateBandProposals(audio: AudioBufferLike$1, duration: number, options?: BandProposalOptions): Promise<BandProposalResult>;
|
|
983
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* Custom Signal Reduction
|
|
1296
|
+
*
|
|
1297
|
+
* Provides algorithms for reducing 2D spectral data (mel spectrogram, HPSS,
|
|
1298
|
+
* MFCC, etc.) to 1D signals with configurable bin ranges and reduction methods.
|
|
1299
|
+
*/
|
|
1300
|
+
/**
|
|
1301
|
+
* Input format for 2D time-aligned data.
|
|
1302
|
+
* Shape: data[timeIndex][featureIndex]
|
|
1303
|
+
*/
|
|
1304
|
+
interface ReductionInput {
|
|
1305
|
+
/** 2D data: data[timeIndex][featureIndex] */
|
|
1306
|
+
data: Float32Array[];
|
|
1307
|
+
/** Time in seconds for each frame */
|
|
1308
|
+
times: Float32Array;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Reduction algorithm identifiers.
|
|
1312
|
+
*/
|
|
1313
|
+
type ReductionAlgorithmId = "mean" | "max" | "sum" | "variance" | "amplitude" | "spectralFlux" | "spectralCentroid" | "onsetStrength";
|
|
1314
|
+
/**
|
|
1315
|
+
* Options for bin range selection.
|
|
1316
|
+
*/
|
|
1317
|
+
interface BinRangeOptions {
|
|
1318
|
+
/** Low bin index (inclusive). Default: 0 */
|
|
1319
|
+
lowBin?: number;
|
|
1320
|
+
/** High bin index (exclusive). Default: all bins */
|
|
1321
|
+
highBin?: number;
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Options for onset strength algorithm.
|
|
1325
|
+
*/
|
|
1326
|
+
interface OnsetStrengthOptions {
|
|
1327
|
+
/** Smoothing window in milliseconds. Default: 10 */
|
|
1328
|
+
smoothMs?: number;
|
|
1329
|
+
/** Whether to log-compress before differencing. Default: true */
|
|
1330
|
+
useLog?: boolean;
|
|
1331
|
+
/** Difference method. Default: "rectified" */
|
|
1332
|
+
diffMethod?: "rectified" | "abs";
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Options for spectral flux algorithm.
|
|
1336
|
+
*/
|
|
1337
|
+
interface SpectralFluxOptions {
|
|
1338
|
+
/** Whether to normalize frames before computing flux. Default: true */
|
|
1339
|
+
normalized?: boolean;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Combined options for reduction.
|
|
1343
|
+
*/
|
|
1344
|
+
interface ReductionOptions {
|
|
1345
|
+
/** Bin range selection */
|
|
1346
|
+
binRange?: BinRangeOptions;
|
|
1347
|
+
/** Onset strength parameters */
|
|
1348
|
+
onsetStrength?: OnsetStrengthOptions;
|
|
1349
|
+
/** Spectral flux parameters */
|
|
1350
|
+
spectralFlux?: SpectralFluxOptions;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Result of a reduction operation.
|
|
1354
|
+
*/
|
|
1355
|
+
interface ReductionResult {
|
|
1356
|
+
/** Frame times in seconds */
|
|
1357
|
+
times: Float32Array;
|
|
1358
|
+
/** Reduced values per frame */
|
|
1359
|
+
values: Float32Array;
|
|
1360
|
+
/** Value range for normalization */
|
|
1361
|
+
valueRange: {
|
|
1362
|
+
min: number;
|
|
1363
|
+
max: number;
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Reduce 2D time-aligned data to a 1D signal using the specified algorithm.
|
|
1368
|
+
*
|
|
1369
|
+
* @param input - 2D input data (frames x bins)
|
|
1370
|
+
* @param algorithm - Reduction algorithm to use
|
|
1371
|
+
* @param options - Algorithm options including bin range selection
|
|
1372
|
+
* @returns Reduction result with times, values, and value range
|
|
1373
|
+
*/
|
|
1374
|
+
declare function reduce2DToSignal(input: ReductionInput, algorithm: ReductionAlgorithmId, options?: ReductionOptions): ReductionResult;
|
|
1375
|
+
/**
|
|
1376
|
+
* Get human-readable label for a reduction algorithm.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function getReductionAlgorithmLabel(algorithm: ReductionAlgorithmId): string;
|
|
1379
|
+
/**
|
|
1380
|
+
* Get description for a reduction algorithm.
|
|
1381
|
+
*/
|
|
1382
|
+
declare function getReductionAlgorithmDescription(algorithm: ReductionAlgorithmId): string;
|
|
1383
|
+
/**
|
|
1384
|
+
* Polarity interpretation mode.
|
|
1385
|
+
* - "signed": Preserve direction (signal can be positive or negative)
|
|
1386
|
+
* - "magnitude": Activity level only (always positive, uses absolute value)
|
|
1387
|
+
*/
|
|
1388
|
+
type PolarityMode = "signed" | "magnitude";
|
|
1389
|
+
/**
|
|
1390
|
+
* Apply polarity interpretation to a signal.
|
|
1391
|
+
* Called after reduction, before stabilization.
|
|
1392
|
+
*
|
|
1393
|
+
* @param values - Input signal values
|
|
1394
|
+
* @param mode - Polarity mode to apply
|
|
1395
|
+
* @returns Transformed signal values
|
|
1396
|
+
*/
|
|
1397
|
+
declare function applyPolarity(values: Float32Array, mode: PolarityMode): Float32Array;
|
|
1398
|
+
/**
|
|
1399
|
+
* Stabilization mode presets.
|
|
1400
|
+
*/
|
|
1401
|
+
type StabilizationMode = "none" | "light" | "medium" | "heavy";
|
|
1402
|
+
/**
|
|
1403
|
+
* Envelope mode for signal shaping.
|
|
1404
|
+
*/
|
|
1405
|
+
type EnvelopeMode = "raw" | "attackRelease";
|
|
1406
|
+
/**
|
|
1407
|
+
* Options for signal stabilization.
|
|
1408
|
+
*/
|
|
1409
|
+
interface StabilizationOptions {
|
|
1410
|
+
/** Smoothing intensity preset. */
|
|
1411
|
+
mode: StabilizationMode;
|
|
1412
|
+
/** Envelope shaping mode. */
|
|
1413
|
+
envelopeMode: EnvelopeMode;
|
|
1414
|
+
/** Attack time in seconds (only for attackRelease mode). */
|
|
1415
|
+
attackTimeSec?: number;
|
|
1416
|
+
/** Release time in seconds (only for attackRelease mode). */
|
|
1417
|
+
releaseTimeSec?: number;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Apply stabilization to a signal.
|
|
1421
|
+
*
|
|
1422
|
+
* @param values - Input signal values
|
|
1423
|
+
* @param times - Frame times in seconds
|
|
1424
|
+
* @param options - Stabilization options
|
|
1425
|
+
* @returns Stabilized signal values
|
|
1426
|
+
*/
|
|
1427
|
+
declare function stabilizeSignal(values: Float32Array, times: Float32Array, options: StabilizationOptions): Float32Array;
|
|
1428
|
+
/**
|
|
1429
|
+
* Compute percentile values from a signal.
|
|
1430
|
+
*
|
|
1431
|
+
* @param values - Signal values
|
|
1432
|
+
* @param percentiles - Array of percentiles to compute (0-100)
|
|
1433
|
+
* @returns Object mapping percentile to value
|
|
1434
|
+
*/
|
|
1435
|
+
declare function computePercentiles(values: Float32Array, percentiles: number[]): Record<number, number>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Compute local (viewport) statistics for a signal.
|
|
1438
|
+
*
|
|
1439
|
+
* @param values - Signal values
|
|
1440
|
+
* @param times - Frame times in seconds
|
|
1441
|
+
* @param startTime - Viewport start time
|
|
1442
|
+
* @param endTime - Viewport end time
|
|
1443
|
+
* @returns Statistics within the viewport
|
|
1444
|
+
*/
|
|
1445
|
+
declare function computeLocalStats(values: Float32Array, times: Float32Array, startTime: number, endTime: number): {
|
|
1446
|
+
min: number;
|
|
1447
|
+
max: number;
|
|
1448
|
+
p5: number;
|
|
1449
|
+
p95: number;
|
|
1450
|
+
};
|
|
1451
|
+
|
|
984
1452
|
type NormaliseForWaveformOptions = {
|
|
985
1453
|
min?: number;
|
|
986
1454
|
max?: number;
|
|
@@ -1296,4 +1764,4 @@ type AudioBufferLike = {
|
|
|
1296
1764
|
*/
|
|
1297
1765
|
declare function helloMir(name?: string): string;
|
|
1298
1766
|
|
|
1299
|
-
export { type AudioBufferLike, type BandMaskOptions, BandMir1DResult, type BandMirBatchRequest, type BandMirBatchResult, BandMirFunctionId, type BandMirOptions, BandProposalConfig, type BandProposalOptions, BandProposalResult, BeatCandidate, type BeatCandidatesOptions, type BeatCandidatesOutput, BeatGrid, BeatPosition, type BeatSalienceSignal, CQT_DEFAULTS, CqtConfig, type CqtOptions, CqtSignalId, CqtSignalResult, CqtSpectrogram, type DeltaOptions, type Features2D, FrequencyBand, FrequencyBandStructure, FrequencyBoundsAtTime, FrequencyKeyframe, FrequencySegment, type HpssOptions, MIR_VERSION, type MaskedSpectrogram, type MelConfig, type MelConversionConfig, type MelSpectrogram, type MfccOptions, type MfccResult, type MinMax, type MirFingerprintV1, type MirFingerprintVectorWeights, MirGPU, type MirRefinementCandidateLabelV1, MirRunMeta, type MirSearchCandidate, type MirSearchCurveKindV1, type MirSearchGuidedOptionsV1, type MirSearchOptionsV1, type MirSearchResultV1, type MirSearchResultV1Guided, type MirVersion, MusicalTimeSegment, MusicalTimeStructure, type OnsetEnvelope, type OnsetEnvelopeGpuResult, type OnsetEnvelopeOptions, type PeakPickEvent, type PeakPickOptions, PhaseAlignmentConfig, PhaseHypothesis, Spectrogram, type Spectrogram2D, type SpectrogramLike2D, type SpectrogramToDbOptions, type TempoHypothesesOptions, type TempoHypothesesOutput, TempoHypothesis, addBandToStructure, allFrequencyBoundsAt, applyBandMaskToSpectrogram, bandAmplitudeEnvelope, bandOnsetStrength, bandSpectralFlux, bandsActiveAt, bassPitchMotion, beatSalienceFromMel, binToHz, clampDb, computeAllCqtSignals, computeBandMaskAtTime, computeBeatPosition, computeBeatPositionFromStructure, computeCqt, computeCqtSignal, computeFrameAmplitude, computeFrameEnergy, computePhaseHypotheses, cqtBinToHz, cqtSpectrogram, createBandStructure, createConstantBand, createMusicalTimeStructure, createSectionedBand, createSegmentFromGrid, createStandardBands, delta, deltaDelta, detectBeatCandidates, featureIndexToHz, findBandById, findSegmentAtTime, fingerprintToVectorV1, fingerprintV1, frequencyBoundsAt, generateBandId, generateBandProposals, generateBeatTimes, generateSegmentBeatTimes, generateSegmentId, generateTempoHypotheses, getBandMirFunctionLabel, getCqtBinFrequencies, getNumBins, getNumOctaves, harmonicEnergy, helloMir, hpss, hzToBin, hzToCqtBin, hzToFeatureIndex, hzToMel, keyframesFromBand, melSpectrogram, melToHz, mergeAdjacentSegments, mfcc, minMax, moveKeyframeTime, normaliseForWaveform, onsetEnvelopeFromMel, onsetEnvelopeFromMelGpu, onsetEnvelopeFromSpectrogram, peakPick, removeBandFromStructure, removeKeyframe, runBandMirBatch, searchTrackV1, searchTrackV1Guided, segmentsFromKeyframes, similarityFingerprintV1, sortBands, sortFrequencySegments, sortSegments, spectralCentroid, spectralFlux, spectrogramToDb, splitBandSegmentAt, splitSegment, tonalStability, touchStructure, updateBandInStructure, updateKeyframe, validateBandStructure, validateFrequencyBand, validateFrequencySegments, validateSegments, withCqtDefaults };
|
|
1767
|
+
export { type AdaptivePeakPickingResult, type AmplitudeEnvelopeConfig, type AmplitudeEnvelopeResult, type AudioBufferLike, type BandBeatCandidatesOptions, BandCqt1DResult, type BandCqtBatchRequest, type BandCqtBatchResult, BandCqtFunctionId, type BandCqtOptions, BandEventFunctionId, type BandEventsBatchRequest, type BandEventsBatchResult, BandEventsResult, type BandMaskOptions, BandMir1DResult, type BandMirBatchRequest, type BandMirBatchResult, BandMirFunctionId, type BandMirOptions, type BandOnsetPeaksOptions, BandProposalConfig, type BandProposalOptions, BandProposalResult, BeatCandidate, type BeatCandidatesOptions, type BeatCandidatesOutput, BeatGrid, BeatPosition, type BeatSalienceSignal, type BinRangeOptions, CQT_DEFAULTS, CqtConfig, type CqtOptions, CqtSignalId, CqtSignalResult, CqtSpectrogram, DEFAULT_PEAK_PICKING_PARAMS, type DeltaOptions, type EnvelopeMode, type Features2D, FrequencyBand, FrequencyBandStructure, FrequencyBoundsAtTime, FrequencyKeyframe, FrequencySegment, type HpssOptions, type HysteresisGateParams, MIR_VERSION, type MaskedCqtSpectrogram, type MaskedSpectrogram, type MelConfig, type MelConversionConfig, type MelSpectrogram, type MfccOptions, type MfccResult, type MinMax, type MirFingerprintV1, type MirFingerprintVectorWeights, MirGPU, type MirRefinementCandidateLabelV1, MirRunMeta, type MirSearchCandidate, type MirSearchCurveKindV1, type MirSearchGuidedOptionsV1, type MirSearchOptionsV1, type MirSearchResultV1, type MirSearchResultV1Guided, type MirVersion, MusicalTimeSegment, MusicalTimeStructure, type OnsetEnvelope, type OnsetEnvelopeGpuResult, type OnsetEnvelopeOptions, type OnsetStrengthOptions, type PeakPickEvent, type PeakPickOptions, type PeakPickingParams, type PeakPickingResult, PhaseAlignmentConfig, PhaseHypothesis, type PolarityMode, type ReductionAlgorithmId, type ReductionInput, type ReductionOptions, type ReductionResult, type SpectralFluxOptions, Spectrogram, type Spectrogram2D, type SpectrogramLike2D, type SpectrogramToDbOptions, type StabilizationMode, type StabilizationOptions, type TempoHypothesesOptions, type TempoHypothesesOutput, TempoHypothesis, addBandToStructure, allFrequencyBoundsAt, amplitudeEnvelope, applyBandMaskToCqt, applyBandMaskToSpectrogram, applyHysteresisGate, applyPolarity, bandAmplitudeEnvelope, bandBeatCandidates, bandCqtBassPitchMotion, bandCqtHarmonicEnergy, bandCqtTonalStability, bandOnsetPeaks, bandOnsetStrength, bandSpectralCentroid, bandSpectralFlux, bandsActiveAt, bassPitchMotion, beatSalienceFromMel, binToHz, clampDb, computeAdaptiveThreshold, computeAllCqtSignals, computeBandMaskAtTime, computeBeatPosition, computeBeatPositionFromStructure, computeCqt, computeCqtSignal, computeFrameAmplitude, computeFrameEnergy, computeLocalStats, computePercentiles, computePhaseHypotheses, cqtBinToHz, cqtSpectrogram, createBandStructure, createConstantBand, createMusicalTimeStructure, createSectionedBand, createSegmentFromGrid, createStandardBands, delta, deltaDelta, detectBeatCandidates, featureIndexToHz, findBandById, findSegmentAtTime, fingerprintToVectorV1, fingerprintV1, frequencyBoundsAt, generateBandId, generateBandProposals, generateBeatTimes, generateSegmentBeatTimes, generateSegmentId, generateTempoHypotheses, getBandCqtFunctionLabel, getBandEventFunctionLabel, getBandMirFunctionLabel, getCqtBinFrequencies, getNumBins, getNumOctaves, getReductionAlgorithmDescription, getReductionAlgorithmLabel, harmonicEnergy, helloMir, hpss, hzToBin, hzToCqtBin, hzToFeatureIndex, hzToMel, keyframesFromBand, melSpectrogram, melToHz, mergeAdjacentSegments, mfcc, minMax, moveKeyframeTime, normaliseForWaveform, onsetEnvelopeFromMel, onsetEnvelopeFromMelGpu, onsetEnvelopeFromSpectrogram, peakPick, pickPeaks, pickPeaksAdaptive, reduce2DToSignal, removeBandFromStructure, removeKeyframe, runBandCqtBatch, runBandEventsBatch, runBandMirBatch, searchTrackV1, searchTrackV1Guided, segmentsFromKeyframes, similarityFingerprintV1, sortBands, sortFrequencySegments, sortSegments, spectralCentroid, spectralFlux, spectrogramToDb, splitBandSegmentAt, splitSegment, stabilizeSignal, tonalStability, touchStructure, updateBandInStructure, updateKeyframe, validateBandStructure, validateFrequencyBand, validateFrequencySegments, validateSegments, withCqtDefaults };
|