dspx 1.2.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -78
- package/binding.gyp +10 -0
- package/dist/FilterBankDesign.d.ts +233 -0
- package/dist/FilterBankDesign.d.ts.map +1 -0
- package/dist/FilterBankDesign.js +247 -0
- package/dist/FilterBankDesign.js.map +1 -0
- package/dist/advanced-dsp.d.ts +6 -6
- package/dist/advanced-dsp.d.ts.map +1 -1
- package/dist/advanced-dsp.js +35 -12
- package/dist/advanced-dsp.js.map +1 -1
- package/dist/backends.d.ts +0 -103
- package/dist/backends.d.ts.map +1 -1
- package/dist/backends.js +0 -217
- package/dist/backends.js.map +1 -1
- package/dist/bindings.d.ts +270 -17
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js +566 -43
- package/dist/bindings.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +67 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +38 -8
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +84 -26
- package/dist/utils.js.map +1 -1
- package/package.json +1 -2
- package/prebuilds/win32-x64/dspx.node +0 -0
- package/scripts/add-dispose-to-tests.js +145 -0
- package/src/native/DspPipeline.cc +699 -126
- package/src/native/DspPipeline.h +13 -0
- package/src/native/FilterBankDesignBindings.cc +241 -0
- package/src/native/IDspStage.h +24 -0
- package/src/native/UtilityBindings.cc +130 -0
- package/src/native/adapters/AmplifyStage.h +148 -0
- package/src/native/adapters/ClipDetectionStage.h +15 -4
- package/src/native/adapters/ConvolutionStage.h +101 -0
- package/src/native/adapters/CumulativeMovingAverageStage.h +264 -0
- package/src/native/adapters/DecimatorStage.h +80 -0
- package/src/native/adapters/DifferentiatorStage.h +13 -0
- package/src/native/adapters/ExponentialMovingAverageStage.h +290 -0
- package/src/native/adapters/FilterBankStage.cc +336 -0
- package/src/native/adapters/FilterBankStage.h +170 -0
- package/src/native/adapters/FilterStage.cc +122 -0
- package/src/native/adapters/FilterStage.h +4 -0
- package/src/native/adapters/HilbertEnvelopeStage.h +55 -0
- package/src/native/adapters/IntegratorStage.h +15 -0
- package/src/native/adapters/InterpolatorStage.h +51 -0
- package/src/native/adapters/LinearRegressionStage.h +40 -0
- package/src/native/adapters/LmsStage.h +63 -0
- package/src/native/adapters/MeanAbsoluteValueStage.h +76 -0
- package/src/native/adapters/MovingAverageStage.h +119 -0
- package/src/native/adapters/PeakDetectionStage.h +53 -0
- package/src/native/adapters/RectifyStage.h +14 -0
- package/src/native/adapters/ResamplerStage.h +67 -0
- package/src/native/adapters/RlsStage.h +76 -0
- package/src/native/adapters/RmsStage.h +72 -0
- package/src/native/adapters/SnrStage.h +45 -0
- package/src/native/adapters/SquareStage.h +78 -0
- package/src/native/adapters/SscStage.h +65 -0
- package/src/native/adapters/StftStage.h +62 -0
- package/src/native/adapters/VarianceStage.h +59 -0
- package/src/native/adapters/WampStage.h +59 -0
- package/src/native/adapters/WaveformLengthStage.h +51 -0
- package/src/native/adapters/ZScoreNormalizeStage.h +64 -0
- package/src/native/core/CumulativeMovingAverageFilter.h +123 -0
- package/src/native/core/ExponentialMovingAverageFilter.h +129 -0
- package/src/native/core/FilterBankDesign.h +266 -0
- package/src/native/core/Policies.h +124 -0
- package/src/native/utils/CircularBufferArray.cc +2 -1
- package/src/native/utils/SimdOps.h +67 -0
- package/src/native/utils/Toon.h +195 -0
package/dist/bindings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProcessOptions,
|
|
1
|
+
import type { ProcessOptions, MovingAverageParams, ExponentialMovingAverageParams, CumulativeMovingAverageParams, RmsParams, RectifyParams, VarianceParams, ZScoreNormalizeParams, MeanAbsoluteValueParams, WaveformLengthParams, SlopeSignChangeParams, WillisonAmplitudeParams, LinearRegressionParams, LmsFilterParams, InterpolateParams, DecimateParams, ResampleParams, ConvolutionParams, WaveletTransformParams, HilbertEnvelopeParams, PipelineCallbacks, RlsFilterParams, TapCallback, PipelineStateSummary, BeamformerWeightsResult, CspResult, GscPreprocessorParams, ChannelSelectorParams, ChannelSelectParams, ChannelMergeParams, FilterBankParams, ClipDetectionParams, PeakDetectionParams, CspTransformParams, fftParams, stftParams, MelSpectrogramParams, MfccParams } from "./types.js";
|
|
2
2
|
import { type FilterOptions } from "./filters.js";
|
|
3
3
|
/**
|
|
4
4
|
* DSP Processor class that wraps the native C++ DspPipeline
|
|
@@ -57,6 +57,82 @@ declare class DspProcessor {
|
|
|
57
57
|
* pipeline.MovingAverage({ mode: "moving", windowDuration: 5000 }); // 5 seconds
|
|
58
58
|
*/
|
|
59
59
|
MovingAverage(params: MovingAverageParams): this;
|
|
60
|
+
/**
|
|
61
|
+
* Add an Exponential Moving Average (EMA) stage to the pipeline
|
|
62
|
+
*
|
|
63
|
+
* EMA gives exponentially decaying weight to older samples, providing adaptive smoothing.
|
|
64
|
+
* Formula: EMA(t) = α * value(t) + (1 - α) * EMA(t-1)
|
|
65
|
+
*
|
|
66
|
+
* @param params - Configuration for the EMA filter
|
|
67
|
+
* @param params.mode - "batch" for stateless EMA (resets per chunk), "moving" for stateful with continuity
|
|
68
|
+
* @param params.alpha - Smoothing factor (0 < α ≤ 1)
|
|
69
|
+
* - α close to 1: Fast response to changes (less smoothing)
|
|
70
|
+
* - α close to 0: Slow response to changes (more smoothing)
|
|
71
|
+
* - From N-period SMA: α = 2 / (N + 1)
|
|
72
|
+
* @returns this instance for method chaining
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Batch mode: Reset EMA for each process() call
|
|
76
|
+
* pipeline.ExponentialMovingAverage({ mode: "batch", alpha: 0.3 });
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // Moving mode: EMA continues across process() calls
|
|
80
|
+
* pipeline.ExponentialMovingAverage({ mode: "moving", alpha: 0.1 });
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Fast adaptive filter (equivalent to ~10-sample SMA)
|
|
84
|
+
* pipeline.ExponentialMovingAverage({ mode: "moving", alpha: 2 / (10 + 1) });
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Chain with other stages for advanced processing
|
|
88
|
+
* pipeline
|
|
89
|
+
* .ExponentialMovingAverage({ mode: "moving", alpha: 0.2 })
|
|
90
|
+
* .Rectify({ mode: "full" })
|
|
91
|
+
* .Rms({ mode: "moving", windowSize: 50 });
|
|
92
|
+
*/
|
|
93
|
+
ExponentialMovingAverage(params: ExponentialMovingAverageParams): this;
|
|
94
|
+
/**
|
|
95
|
+
* Add a Cumulative Moving Average (CMA) stage to the pipeline
|
|
96
|
+
*
|
|
97
|
+
* CMA is the average of ALL samples seen since initialization (not just a window).
|
|
98
|
+
* Formula: CMA(n) = (sum of all values) / n
|
|
99
|
+
*
|
|
100
|
+
* Unlike simple moving average (SMA), CMA considers entire history:
|
|
101
|
+
* - SMA: Uses fixed window of recent N samples
|
|
102
|
+
* - CMA: Uses all samples from start to current
|
|
103
|
+
*
|
|
104
|
+
* Memory-efficient: only stores running sum and count.
|
|
105
|
+
*
|
|
106
|
+
* @param params - Configuration for the CMA filter
|
|
107
|
+
* @param params.mode - "batch" for stateless CMA (resets per chunk), "moving" for stateful with continuity
|
|
108
|
+
* @returns this instance for method chaining
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Batch mode: CMA resets for each process() call
|
|
112
|
+
* pipeline.CumulativeMovingAverage({ mode: "batch" });
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Moving mode: CMA accumulates across all process() calls
|
|
116
|
+
* pipeline.CumulativeMovingAverage({ mode: "moving" });
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Use case: Long-term baseline estimation from calibration data
|
|
120
|
+
* const calibrationPipeline = createDspPipeline();
|
|
121
|
+
* calibrationPipeline.CumulativeMovingAverage({ mode: "moving" });
|
|
122
|
+
*
|
|
123
|
+
* // Process calibration chunks
|
|
124
|
+
* await calibrationPipeline.process(chunk1, { channels: 1 });
|
|
125
|
+
* await calibrationPipeline.process(chunk2, { channels: 1 });
|
|
126
|
+
* await calibrationPipeline.process(chunk3, { channels: 1 });
|
|
127
|
+
* // Final output contains cumulative average across all chunks
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // Chain with variance for online statistics
|
|
131
|
+
* pipeline
|
|
132
|
+
* .CumulativeMovingAverage({ mode: "moving" })
|
|
133
|
+
* .tap((samples) => console.log('Running mean:', samples[samples.length - 1]));
|
|
134
|
+
*/
|
|
135
|
+
CumulativeMovingAverage(params: CumulativeMovingAverageParams): this;
|
|
60
136
|
/**
|
|
61
137
|
* Add a RMS (root mean square) stage to the pipeline
|
|
62
138
|
* @param params - Configuration for the RMS filter
|
|
@@ -742,6 +818,49 @@ declare class DspProcessor {
|
|
|
742
818
|
* pipeline.ChannelMerge({ mapping: [0, 2, 1, 0], numInputChannels: 3 });
|
|
743
819
|
*/
|
|
744
820
|
ChannelMerge(params: ChannelMergeParams): this;
|
|
821
|
+
/**
|
|
822
|
+
* Apply a bank of IIR filters to split each input channel into multiple frequency bands.
|
|
823
|
+
*
|
|
824
|
+
* Implements frequency decomposition for:
|
|
825
|
+
* - Speech recognition: Mel-scale filter banks (20-40 bands)
|
|
826
|
+
* - Audio compression: Bark-scale psychoacoustic analysis
|
|
827
|
+
* - Musical analysis: Octave bands (log scale)
|
|
828
|
+
* - Research: Linear-scale frequency analysis
|
|
829
|
+
*
|
|
830
|
+
* Architecture:
|
|
831
|
+
* - Input: N channels (interleaved)
|
|
832
|
+
* - Output: N × M channels (interleaved, channel-major layout)
|
|
833
|
+
* - Layout: All bands for channel 1, then all bands for channel 2, etc.
|
|
834
|
+
*
|
|
835
|
+
* @param params - Filter bank parameters
|
|
836
|
+
* @param params.definitions - Array of filter definitions (one per band)
|
|
837
|
+
* @param params.inputChannels - Number of input channels
|
|
838
|
+
* @returns this instance for method chaining
|
|
839
|
+
*
|
|
840
|
+
* @throws {TypeError} If definitions or inputChannels are missing
|
|
841
|
+
* @throws {RangeError} If inputChannels <= 0 or definitions is empty
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* // Design a 24-band Mel-scale filter bank for speech
|
|
845
|
+
* import { FilterBankDesign } from 'dspx';
|
|
846
|
+
*
|
|
847
|
+
* const melBank = FilterBankDesign.createMel(24, 16000, [100, 8000]);
|
|
848
|
+
* pipeline.FilterBank({
|
|
849
|
+
* definitions: melBank,
|
|
850
|
+
* inputChannels: 1
|
|
851
|
+
* });
|
|
852
|
+
* // Output: 24 channels (one per Mel band)
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* // Custom 10-band octave filter bank for stereo input
|
|
856
|
+
* const octaveBank = FilterBankDesign.createLog(10, 44100, [20, 20000]);
|
|
857
|
+
* pipeline.FilterBank({
|
|
858
|
+
* definitions: octaveBank,
|
|
859
|
+
* inputChannels: 2
|
|
860
|
+
* });
|
|
861
|
+
* // Output: 20 channels (10 bands × 2 input channels)
|
|
862
|
+
*/
|
|
863
|
+
FilterBank(params: FilterBankParams): this;
|
|
745
864
|
/**
|
|
746
865
|
* Detect clipping (signal saturation) in the input stream.
|
|
747
866
|
*
|
|
@@ -849,6 +968,60 @@ declare class DspProcessor {
|
|
|
849
968
|
* .Differentiator();
|
|
850
969
|
*/
|
|
851
970
|
Differentiator(): this;
|
|
971
|
+
/**
|
|
972
|
+
* Apply element-wise squaring to the signal.
|
|
973
|
+
*
|
|
974
|
+
* Implements: y[n] = x[n]²
|
|
975
|
+
*
|
|
976
|
+
* Squaring is commonly used for:
|
|
977
|
+
* - Energy/power calculation
|
|
978
|
+
* - Non-linear signal transformation
|
|
979
|
+
* - Envelope detection
|
|
980
|
+
* - Part of Pan-Tompkins QRS detection algorithm (ECG)
|
|
981
|
+
*
|
|
982
|
+
* **Note:** Amplifies large values and suppresses small ones.
|
|
983
|
+
* This stage is stateless - no mode selection needed.
|
|
984
|
+
*
|
|
985
|
+
* @returns this instance for method chaining
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* // Calculate signal power
|
|
989
|
+
* pipeline.Square();
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* // Pan-Tompkins QRS detection
|
|
993
|
+
* pipeline
|
|
994
|
+
* .ButterworthBandpass({ lowCutoff: 5, highCutoff: 15, order: 2, sampleRate: 360 })
|
|
995
|
+
* .Differentiator()
|
|
996
|
+
* .Square()
|
|
997
|
+
* .MovingAverage({ mode: "moving", windowSize: 30 });
|
|
998
|
+
*/
|
|
999
|
+
Square(): this;
|
|
1000
|
+
/**
|
|
1001
|
+
* Amplify (scale) the signal by a constant gain factor.
|
|
1002
|
+
*
|
|
1003
|
+
* Multiplies all samples by the gain value: y[n] = gain * x[n]
|
|
1004
|
+
*
|
|
1005
|
+
* Use cases:
|
|
1006
|
+
* - Scale signals to appropriate amplitude ranges for peak detection
|
|
1007
|
+
* - Compensate for sensor attenuation
|
|
1008
|
+
* - Normalize signal levels between processing stages
|
|
1009
|
+
*
|
|
1010
|
+
* @param params - Amplification parameters
|
|
1011
|
+
* @param params.gain - Gain factor (must be positive). Default: 1.0
|
|
1012
|
+
* @returns this (for method chaining)
|
|
1013
|
+
*
|
|
1014
|
+
* @example
|
|
1015
|
+
* // Amplify signal by 1000x for better peak detection sensitivity
|
|
1016
|
+
* pipeline.Amplify({ gain: 1000 });
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* // Attenuate signal by 50%
|
|
1020
|
+
* pipeline.Amplify({ gain: 0.5 });
|
|
1021
|
+
*/
|
|
1022
|
+
Amplify(params: {
|
|
1023
|
+
gain: number;
|
|
1024
|
+
}): this;
|
|
852
1025
|
/**
|
|
853
1026
|
* Apply leaky integration (accumulation) using IIR filter.
|
|
854
1027
|
*
|
|
@@ -1409,6 +1582,16 @@ declare class DspProcessor {
|
|
|
1409
1582
|
* });
|
|
1410
1583
|
*
|
|
1411
1584
|
* @example
|
|
1585
|
+
* // Generic IIR filter (uses Butterworth internally)
|
|
1586
|
+
* pipeline.filter({
|
|
1587
|
+
* type: "iir",
|
|
1588
|
+
* mode: "highpass",
|
|
1589
|
+
* cutoffFrequency: 500,
|
|
1590
|
+
* sampleRate: 8000,
|
|
1591
|
+
* order: 2
|
|
1592
|
+
* });
|
|
1593
|
+
*
|
|
1594
|
+
* @example
|
|
1412
1595
|
* // Butterworth band-pass filter
|
|
1413
1596
|
* pipeline.filter({
|
|
1414
1597
|
* type: "butterworth",
|
|
@@ -1454,6 +1637,11 @@ declare class DspProcessor {
|
|
|
1454
1637
|
* Helper to create Chebyshev filter from options
|
|
1455
1638
|
*/
|
|
1456
1639
|
private createChebyshevFilter;
|
|
1640
|
+
/**
|
|
1641
|
+
* Helper to create generic IIR filter from options
|
|
1642
|
+
* Uses first-order filters for order=1, Butterworth otherwise
|
|
1643
|
+
*/
|
|
1644
|
+
private createIirFilter;
|
|
1457
1645
|
/**
|
|
1458
1646
|
* Helper to create Biquad filter from options
|
|
1459
1647
|
*/
|
|
@@ -1504,10 +1692,10 @@ declare class DspProcessor {
|
|
|
1504
1692
|
*/
|
|
1505
1693
|
process(input: Float32Array, timestampsOrOptions: Float32Array | ProcessOptions, optionsIfTimestamps?: ProcessOptions): Promise<Float32Array>;
|
|
1506
1694
|
/**
|
|
1507
|
-
* Process a copy of the
|
|
1695
|
+
* Process a copy of the input data through the DSP pipeline
|
|
1508
1696
|
* This method creates a copy of the input, so the original is preserved
|
|
1509
1697
|
*
|
|
1510
|
-
* @param input - Float32Array containing interleaved
|
|
1698
|
+
* @param input - Float32Array containing interleaved input samples (original is preserved)
|
|
1511
1699
|
* @param timestampsOrOptions - Either timestamps array or processing options (sample rate and channel count)
|
|
1512
1700
|
* @param optionsIfTimestamps - Processing options if timestamps were provided in second parameter
|
|
1513
1701
|
* @returns Promise that resolves to a new Float32Array with the processed data
|
|
@@ -1522,30 +1710,96 @@ declare class DspProcessor {
|
|
|
1522
1710
|
*/
|
|
1523
1711
|
processCopy(input: Float32Array, timestampsOrOptions: Float32Array | ProcessOptions, optionsIfTimestamps?: ProcessOptions): Promise<Float32Array>;
|
|
1524
1712
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
*
|
|
1713
|
+
* Process data synchronously (BLOCKING).
|
|
1714
|
+
* * ⚠️ PERFORMANCE WARNING:
|
|
1715
|
+
* Only use this method inside Worker Threads or Cluster Workers.
|
|
1716
|
+
* Using this on the Main Thread of a server will block the Event Loop.
|
|
1717
|
+
* * This method bypasses the libuv thread pool, running DSP logic directly
|
|
1718
|
+
* on the calling thread. Ideal for high-frequency real-time audio loops.
|
|
1719
|
+
* * @param input - Float32Array containing samples (modified in-place if no resizing)
|
|
1720
|
+
* @param timestampsOrOptions - Timestamps array or options object
|
|
1721
|
+
* @param optionsIfTimestamps - Options object if timestamps provided
|
|
1722
|
+
*/
|
|
1723
|
+
processSync(input: Float32Array, timestampsOrOptions: Float32Array | ProcessOptions, optionsIfTimestamps?: ProcessOptions): Float32Array;
|
|
1724
|
+
/**
|
|
1725
|
+
* Process a copy of the input data through the DSP pipeline
|
|
1726
|
+
* This method creates a copy of the input, so the original is preserved
|
|
1727
|
+
* * ⚠️ PERFORMANCE WARNING:
|
|
1728
|
+
* Only use this method inside Worker Threads or Cluster Workers.
|
|
1729
|
+
* Using this on the Main Thread of a server will block the Event Loop.
|
|
1730
|
+
* * This method bypasses the libuv thread pool, running DSP logic directly
|
|
1731
|
+
* on the calling thread. Ideal for high-frequency real-time audio loops.
|
|
1732
|
+
* @param input - Float32Array containing interleaved input samples (original is preserved)
|
|
1733
|
+
* @param timestampsOrOptions - Either timestamps array or processing options (sample rate and channel count)
|
|
1734
|
+
* @param optionsIfTimestamps - Processing options if timestamps were provided in second parameter
|
|
1735
|
+
* @returns Promise that resolves to a new Float32Array with the processed data
|
|
1736
|
+
*
|
|
1737
|
+
* @example
|
|
1738
|
+
* // Legacy sample-based (original preserved)
|
|
1739
|
+
* const output = await pipeline.processSyncCopy(samples, { sampleRate: 100, channels: 1 });
|
|
1740
|
+
*
|
|
1741
|
+
* @example
|
|
1742
|
+
* // Time-based with explicit timestamps (original preserved)
|
|
1743
|
+
* const output = await pipeline.processSyncCopy(samples, timestamps, { channels: 1 });
|
|
1744
|
+
*/
|
|
1745
|
+
processSyncCopy(input: Float32Array, timestampsOrOptions: Float32Array | ProcessOptions, optionsIfTimestamps?: ProcessOptions): Float32Array;
|
|
1746
|
+
/**
|
|
1747
|
+
* @brief Dispose of the DSP pipeline and free native resources
|
|
1748
|
+
* After calling this method, the instance should not be used again
|
|
1527
1749
|
*
|
|
1528
|
-
* @
|
|
1750
|
+
* @example
|
|
1751
|
+
* const pipeline = createDspPipeline()
|
|
1752
|
+
* .MovingAverage({ mode: "moving", windowSize: 100 })
|
|
1753
|
+
* .Rectify({ mode: 'full' })
|
|
1754
|
+
* const output = await pipeline.process(samples, { sampleRate: 1000, channels: 1 });
|
|
1755
|
+
* pipeline.dispose();
|
|
1756
|
+
* // Free resources when done, pipeline cannot be used after this for processing the input signal since the stages have been disposed
|
|
1757
|
+
*/
|
|
1758
|
+
dispose(): void;
|
|
1759
|
+
/**
|
|
1760
|
+
* Save the current pipeline state
|
|
1761
|
+
* Supports two formats:
|
|
1762
|
+
* - JSON (default): Returns a string for text-based storage
|
|
1763
|
+
* - TOON: Returns a Buffer for binary serialization (60-70% smaller, faster)
|
|
1764
|
+
*
|
|
1765
|
+
* @param options - Optional configuration with format: 'json' | 'toon'
|
|
1766
|
+
* @returns JSON string (default) or Buffer (if format: 'toon')
|
|
1529
1767
|
*
|
|
1530
1768
|
* @example
|
|
1769
|
+
* // Default JSON format
|
|
1531
1770
|
* const stateJson = await pipeline.saveState();
|
|
1532
1771
|
* await redis.set('dsp:state', stateJson);
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* // TOON binary format (smaller, faster)
|
|
1775
|
+
* const stateBinary = await pipeline.saveState({ format: 'toon' });
|
|
1776
|
+
* await redis.set('dsp:state', stateBinary);
|
|
1533
1777
|
*/
|
|
1534
|
-
saveState(
|
|
1778
|
+
saveState(options?: {
|
|
1779
|
+
format?: "json" | "toon";
|
|
1780
|
+
}): Promise<string | Buffer>;
|
|
1535
1781
|
/**
|
|
1536
|
-
* Load pipeline state from
|
|
1537
|
-
*
|
|
1782
|
+
* Load pipeline state from JSON string or TOON binary Buffer
|
|
1783
|
+
* Auto-detects format: Buffer → TOON, string → JSON
|
|
1538
1784
|
*
|
|
1539
|
-
* @param
|
|
1785
|
+
* @param state - JSON string or TOON Buffer containing the pipeline state
|
|
1540
1786
|
* @returns Promise that resolves to true if successful
|
|
1541
1787
|
*
|
|
1542
1788
|
* @example
|
|
1789
|
+
* // Load JSON state
|
|
1543
1790
|
* const stateJson = await redis.get('dsp:state');
|
|
1544
1791
|
* if (stateJson) {
|
|
1545
1792
|
* await pipeline.loadState(stateJson);
|
|
1546
1793
|
* }
|
|
1794
|
+
*
|
|
1795
|
+
* @example
|
|
1796
|
+
* // Load TOON binary state (auto-detected)
|
|
1797
|
+
* const stateBinary = await redis.getBuffer('dsp:state');
|
|
1798
|
+
* if (stateBinary) {
|
|
1799
|
+
* await pipeline.loadState(stateBinary);
|
|
1800
|
+
* }
|
|
1547
1801
|
*/
|
|
1548
|
-
loadState(
|
|
1802
|
+
loadState(state: string | Buffer): Promise<boolean>;
|
|
1549
1803
|
/**
|
|
1550
1804
|
* Clear all pipeline state (reset all filters to initial state)
|
|
1551
1805
|
* This resets filter buffers without removing the stages
|
|
@@ -1588,17 +1842,13 @@ declare class DspProcessor {
|
|
|
1588
1842
|
*
|
|
1589
1843
|
* @example
|
|
1590
1844
|
* // Create pipeline with Redis state persistence
|
|
1591
|
-
* const pipeline = createDspPipeline(
|
|
1592
|
-
* redisHost: 'localhost',
|
|
1593
|
-
* redisPort: 6379,
|
|
1594
|
-
* stateKey: 'dsp:channel1'
|
|
1595
|
-
* });
|
|
1845
|
+
* const pipeline = createDspPipeline();
|
|
1596
1846
|
*
|
|
1597
1847
|
* @example
|
|
1598
1848
|
* // Create pipeline without Redis (state is not persisted)
|
|
1599
1849
|
* const pipeline = createDspPipeline();
|
|
1600
1850
|
*/
|
|
1601
|
-
export declare function createDspPipeline(
|
|
1851
|
+
export declare function createDspPipeline(): DspProcessor;
|
|
1602
1852
|
export { DspProcessor };
|
|
1603
1853
|
import type { PcaResult, IcaResult, WhiteningResult, PcaTransformParams, IcaTransformParams, WhiteningTransformParams } from "./types.js";
|
|
1604
1854
|
/**
|
|
@@ -1959,4 +2209,7 @@ export declare function calculateBeamformerWeights(numChannels: number, arrayGeo
|
|
|
1959
2209
|
* @see CspTransform
|
|
1960
2210
|
*/
|
|
1961
2211
|
export declare function calculateCommonSpatialPatterns(dataClass1: Float32Array, dataClass2: Float32Array, numChannels: number, numFilters?: number): CspResult;
|
|
2212
|
+
export type { FilterBankParams, FilterDefinition } from "./types.js";
|
|
2213
|
+
export { FilterBankDesign } from "./FilterBankDesign.js";
|
|
2214
|
+
export type { FilterBankOptions, FilterCoefficients, FilterScale, FilterBankType, } from "./FilterBankDesign.js";
|
|
1962
2215
|
//# sourceMappingURL=bindings.d.ts.map
|
package/dist/bindings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/ts/bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/ts/bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,8BAA8B,EAC9B,6BAA6B,EAC7B,SAAS,EACT,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EAC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