dspx 0.2.0-alpha.1 → 0.2.0-alpha.11

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.
Files changed (73) hide show
  1. package/LICENSE +224 -21
  2. package/README.md +155 -3
  3. package/binding.gyp +36 -3
  4. package/dist/backends.d.ts +251 -4
  5. package/dist/backends.d.ts.map +1 -1
  6. package/dist/backends.js +655 -122
  7. package/dist/backends.js.map +1 -1
  8. package/dist/bindings.d.ts +192 -1
  9. package/dist/bindings.d.ts.map +1 -1
  10. package/dist/bindings.js +409 -50
  11. package/dist/bindings.js.map +1 -1
  12. package/dist/easter-egg.d.ts +1 -0
  13. package/dist/easter-egg.d.ts.map +1 -1
  14. package/dist/easter-egg.js +31 -0
  15. package/dist/easter-egg.js.map +1 -1
  16. package/dist/fft.d.ts.map +1 -1
  17. package/dist/fft.js +16 -16
  18. package/dist/fft.js.map +1 -1
  19. package/dist/filters.d.ts +169 -0
  20. package/dist/filters.d.ts.map +1 -1
  21. package/dist/filters.js +210 -16
  22. package/dist/filters.js.map +1 -1
  23. package/dist/index.d.ts +13 -12
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +9 -8
  26. package/dist/index.js.map +1 -1
  27. package/dist/types.d.ts +124 -14
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/utils.d.ts +55 -0
  30. package/dist/utils.d.ts.map +1 -0
  31. package/dist/utils.js +88 -0
  32. package/dist/utils.js.map +1 -0
  33. package/package.json +7 -6
  34. package/prebuilds/linux-arm64/dspx.node +0 -0
  35. package/prebuilds/win32-x64/dspx.node +0 -0
  36. package/src/native/DspPipeline.cc +413 -4
  37. package/src/native/DspPipeline.h +1 -0
  38. package/src/native/FftBindings.cc +80 -28
  39. package/src/native/FilterBindings.cc +277 -0
  40. package/src/native/IDspStage.h +46 -0
  41. package/src/native/UtilityBindings.cc +83 -0
  42. package/src/native/adapters/ConvolutionStage.h +712 -0
  43. package/src/native/adapters/DecimatorStage.cc +13 -0
  44. package/src/native/adapters/DecimatorStage.h +302 -0
  45. package/src/native/adapters/FilterStage.cc +290 -0
  46. package/src/native/adapters/FilterStage.h +38 -0
  47. package/src/native/adapters/InterpolatorStage.cc +13 -0
  48. package/src/native/adapters/InterpolatorStage.h +193 -127
  49. package/src/native/adapters/LinearRegressionStage.h +344 -0
  50. package/src/native/adapters/LmsStage.h +201 -0
  51. package/src/native/adapters/ResamplerStage.cc +13 -0
  52. package/src/native/adapters/ResamplerStage.h +235 -155
  53. package/src/native/core/DifferentiableFilter.h +288 -0
  54. package/src/native/core/FftEngine.cc +120 -62
  55. package/src/native/core/FftEngine.h +4 -0
  56. package/src/native/core/Fftpack.cc +1540 -0
  57. package/src/native/core/Fftpack.h +74 -0
  58. package/src/native/core/FirFilter.cc +103 -37
  59. package/src/native/core/FirFilter.h +14 -0
  60. package/src/native/core/IirFilter.cc +243 -96
  61. package/src/native/core/IirFilter.h +28 -2
  62. package/src/native/core/MovingFftFilter.cc +1 -0
  63. package/src/native/core/MovingVarianceFilter.cc +1 -3
  64. package/src/native/utils/CircularBufferArray.cc +17 -44
  65. package/src/native/utils/CircularBufferArray.h +16 -5
  66. package/src/native/utils/ConvolutionPolicy.h +148 -0
  67. package/src/native/utils/SimdOps.h +198 -38
  68. package/src/native/utils/SlidingWindowFilter.cc +5 -0
  69. package/src/native/utils/SlidingWindowFilter.h +18 -12
  70. package/dist/build/dspx.node +0 -0
  71. package/prebuilds/linux-x64/dsp-ts-redis.node +0 -0
  72. package/prebuilds/win32-x64/dsp-ts-redis.node +0 -0
  73. package/src/build/dspx.node +0 -0
package/LICENSE CHANGED
@@ -1,21 +1,224 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Alan Kochukalam George
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Alan Kochukalam George
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+ ---
204
+
205
+ This product includes code derived from the following open-source project:
206
+
207
+ FFTPACK (Apache License 2.0)
208
+ Copyright (c) 2004–2016 University Corporation for Atmospheric Research/NCAR
209
+ Developed by Paul N. Swarztrauber
210
+ https://www.netlib.org/fftpack/
211
+
212
+ Licensed under the Apache License, Version 2.0 (the "License");
213
+ you may not use this file except in compliance with the License.
214
+ You may obtain a copy of the License at
215
+
216
+ http://www.apache.org/licenses/LICENSE-2.0
217
+
218
+ Unless required by applicable law or agreed to in writing, software
219
+ distributed under the License is distributed on an "AS IS" BASIS,
220
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221
+ See the License for the specific language governing permissions and
222
+ limitations under the License.
223
+
224
+ ---
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Work in Progress
2
2
 
3
3
  > The project’s in heavy development.
4
- > Once Phases 1 and 2 (core DSP + FFT/IIR/FIR) are stable, I’ll push the first npm release.
5
4
  > Expect breaking changes until then!
6
5
 
7
6
  # dspx
@@ -18,6 +17,7 @@ A modern DSP library built for Node.js backends processing real-time biosignals,
18
17
  - 🎯 **SIMD Acceleration** – AVX2/SSE2/NEON optimizations provide 2-8x speedup on batch operations and rectification
19
18
  - 🔧 **TypeScript-First** – Full type safety with excellent IntelliSense
20
19
  - 📡 **Redis State Persistence** – Fully implemented state serialization/deserialization including circular buffer contents and running sums
20
+ - 🔥 **Kafka Streaming (Experimental)** – Real-time data ingestion and log streaming via Apache Kafka (testing in progress)
21
21
  - ⏱️ **Time-Series Processing** – NEW! Support for irregular timestamps and time-based windows
22
22
  - 🔗 **Fluent Pipeline API** – Chain filter operations with method chaining
23
23
  - 🎯 **Zero-Copy Processing** – Direct TypedArray manipulation for minimal overhead
@@ -453,6 +453,39 @@ await pipeline.process(chunk2, { sampleRate: 2000, channels: 1 });
453
453
  pipeline.clearState();
454
454
  ```
455
455
 
456
+ ### With Kafka Streaming (Experimental)
457
+
458
+ > ⚠️ **Note:** Kafka integration is experimental and requires additional testing. See the [Contributing](#-contributing) section if you'd like to help!
459
+
460
+ ```typescript
461
+ import { createDspPipeline, createKafkaConsumer } from "dspx";
462
+
463
+ // Create DSP pipeline
464
+ const pipeline = createDspPipeline();
465
+ pipeline
466
+ .MovingAverage({ mode: "moving", windowSize: 10 })
467
+ .Rms({ mode: "moving", windowSize: 5 });
468
+
469
+ // Consume sensor data from Kafka topic
470
+ const consumer = await createKafkaConsumer({
471
+ brokers: ["localhost:9092"],
472
+ groupId: "dsp-processors",
473
+ topics: ["sensor-data"],
474
+ onMessage: async ({ value }) => {
475
+ const samples = new Float32Array(value.data);
476
+ const output = await pipeline.process(samples, {
477
+ channels: 1,
478
+ sampleRate: 44100,
479
+ });
480
+ console.log("Processed:", output[0]);
481
+ },
482
+ });
483
+
484
+ await consumer.run();
485
+ ```
486
+
487
+ **See [Kafka Integration Guide](https://github.com/A-KGeorge/dsp_ts_redis/blob/main/docs/KAFKA_INTEGRATION.md) for real-time streaming examples.**
488
+
456
489
  ### Multi-Channel Processing
457
490
 
458
491
  ```typescript
@@ -577,6 +610,102 @@ const result2 = await moving.process(new Float32Array([1, 2, 3, 4, 5]));
577
610
  - **Batch**: Quality control metrics, batch statistics, data summarization
578
611
  - **Moving**: Signal smoothing, noise reduction, trend analysis, low-pass filtering
579
612
 
613
+ ##### Convolution Filter
614
+
615
+ ```typescript
616
+ // Batch Mode - Process entire buffer with kernel
617
+ pipeline.Convolution({ mode: "batch", kernel: Float32Array });
618
+
619
+ // Moving Mode - Stateful streaming convolution
620
+ pipeline.Convolution({
621
+ mode: "moving",
622
+ kernel: Float32Array,
623
+ method: "auto" | "direct" | "fft", // auto (default): switches at kernel size 64
624
+ });
625
+ ```
626
+
627
+ Implements high-performance 1D convolution with automatic FFT acceleration for large kernels. Supports arbitrary kernels for filtering, edge detection, feature extraction, and more.
628
+
629
+ **Modes:**
630
+
631
+ | Mode | Description | State | Output | Use Case |
632
+ | ---------- | ---------------------------------- | --------- | --------------------------------- | ---------------------------------------- |
633
+ | `"batch"` | Convolve kernel with entire buffer | Stateless | Full convolution of input | Offline processing, batch filtering |
634
+ | `"moving"` | Stateful streaming convolution | Stateful | Overlap-add with state continuity | Real-time filtering, streaming workloads |
635
+
636
+ **Parameters:**
637
+
638
+ - `mode`: `"batch"` or `"moving"` - determines computation strategy
639
+ - `kernel`: Float32Array - convolution kernel/filter coefficients
640
+ - `method` (optional): `"auto"` (default), `"direct"`, or `"fft"`
641
+ - `"auto"`: Uses direct SIMD for kernel ≤ 64, FFT for kernel > 64
642
+ - `"direct"`: Always use direct convolution (SIMD-accelerated)
643
+ - `"fft"`: Always use FFT-based convolution (overlap-add for moving mode)
644
+
645
+ **Features:**
646
+
647
+ - **Automatic FFT acceleration**: Auto-switches at kernel size 64 for optimal performance
648
+ - **SIMD optimization**: AVX2/SSE2 accelerated direct convolution (4-8x throughput)
649
+ - **Zero allocations**: Pre-allocated buffers eliminate per-call overhead
650
+ - **Cache-friendly**: De-interleaved processing for multi-channel signals
651
+ - **Overlap-add**: Efficient chunked processing for moving mode FFT
652
+ - **Per-channel state**: Independent convolution state for each channel
653
+
654
+ **Performance Characteristics (Moving Mode):**
655
+
656
+ | Kernel Size | Method Used | Throughput (samples/sec) | vs Naive JS |
657
+ | ----------- | ------------- | ------------------------ | --------------------------------------- |
658
+ | K=8 | Direct (SIMD) | ~19M | Naive JS faster (110M) - see note below |
659
+ | K=32 | Direct (SIMD) | ~12M | Naive JS faster (36M) - see note below |
660
+ | K=64 | Direct (SIMD) | ~7M | Naive JS faster (18M) - threshold point |
661
+ | K=128 | FFT (overlap) | **82M** | **8.5x faster** than naive JS (9.6M) |
662
+ | K=256 | FFT (overlap) | **77M** | **15x faster** than naive JS (5M) |
663
+
664
+ **Example:**
665
+
666
+ ```typescript
667
+ // Batch mode: Simple edge detection kernel
668
+ const edgeKernel = new Float32Array([-1, 0, 1]); // Horizontal gradient
669
+ const batch = createDspPipeline().Convolution({
670
+ mode: "batch",
671
+ kernel: edgeKernel,
672
+ });
673
+ const edges = await batch.process(signal);
674
+
675
+ // Moving mode: Gaussian smoothing (auto FFT for K=7)
676
+ const gaussianKernel = new Float32Array([0.06, 0.24, 0.4, 0.24, 0.06]);
677
+ const moving = createDspPipeline().Convolution({
678
+ mode: "moving",
679
+ kernel: gaussianKernel,
680
+ method: "auto", // Uses direct SIMD (K < 64)
681
+ });
682
+ const smoothed = await moving.process(noisySignal);
683
+
684
+ // Large kernel: Automatic FFT acceleration (K=128)
685
+ const largeKernel = new Float32Array(128).fill(1 / 128); // Moving average K=128
686
+ const fftConv = createDspPipeline().Convolution({
687
+ mode: "moving",
688
+ kernel: largeKernel,
689
+ method: "auto", // Auto-switches to FFT for 9x speedup
690
+ });
691
+ const filtered = await fftConv.process(data);
692
+ ```
693
+
694
+ **Use Cases:**
695
+
696
+ - **Signal Processing**: Custom FIR filters, bandpass/bandstop filters, matched filtering
697
+ - **Computer Vision**: Edge detection (Sobel, Prewitt), Gaussian blur, sharpening
698
+ - **Feature Extraction**: Wavelet convolution, pattern matching, template detection
699
+ - **Audio Processing**: Impulse response convolution, reverb, echo effects
700
+ - **Time Series**: Smoothing, differentiation, integration kernels
701
+
702
+ **Mathematical Properties:**
703
+
704
+ - **Linearity**: Conv(a·x₁ + b·x₂, h) = a·Conv(x₁, h) + b·Conv(x₂, h)
705
+ - **Commutative**: x ⊛ h = h ⊛ x
706
+ - **Associative**: (x ⊛ h₁) ⊛ h₂ = x ⊛ (h₁ ⊛ h₂)
707
+ - **FFT Equivalence**: Time-domain convolution = Frequency-domain multiplication
708
+
580
709
  ##### RMS (Root Mean Square) Filter
581
710
 
582
711
  ```typescript
@@ -1778,9 +1907,32 @@ All 441 tests pass after these fixes. Run `npm test` to verify.
1778
1907
 
1779
1908
  ---
1780
1909
 
1781
- ## �📄 License
1910
+ ## 🤝 Contributing
1911
+
1912
+ We welcome contributions! Here are areas where help is particularly needed:
1913
+
1914
+ ### High Priority
1915
+
1916
+ - **Kafka Integration Testing** – The Kafka streaming feature is experimental and needs comprehensive integration tests. Help us validate producer/consumer patterns, error handling, and performance under load.
1917
+ - **Additional Filters** – Implement new DSP filters (bandpass, highpass, lowpass, etc.) following the existing architecture patterns.
1918
+
1919
+ ### How to Contribute
1920
+
1921
+ 1. Fork the repository
1922
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
1923
+ 3. Make your changes with tests
1924
+ 4. Run `npm test` to ensure all tests pass
1925
+ 5. Commit your changes (`git commit -m 'Add amazing feature'`)
1926
+ 6. Push to the branch (`git push origin feature/amazing-feature`)
1927
+ 7. Open a Pull Request
1928
+
1929
+ For questions or discussions, please open an issue first!
1930
+
1931
+ ---
1932
+
1933
+ ### 📄 License
1782
1934
 
1783
- MIT © Alan Kochukalam George
1935
+ Apache License 2.0 © Alan Kochukalam George
1784
1936
 
1785
1937
  ---
1786
1938
 
package/binding.gyp CHANGED
@@ -13,16 +13,19 @@
13
13
  "src/native/core/WampFilter.cc",
14
14
  "src/native/core/WaveformLengthFilter.cc",
15
15
  "src/native/core/FftEngine.cc",
16
+ "src/native/core/Fftpack.cc",
16
17
  "src/native/core/MovingFftFilter.cc",
17
18
  "src/native/core/FirFilter.cc",
18
19
  "src/native/core/IirFilter.cc",
19
20
  "src/native/FftBindings.cc",
20
21
  "src/native/FilterBindings.cc",
22
+ "src/native/UtilityBindings.cc",
21
23
  "src/native/utils/CircularBufferArray.cc",
22
24
  "src/native/utils/CircularBufferVector.cc",
23
25
  "src/native/utils/NapiUtils.cc",
24
26
  "src/native/utils/SlidingWindowFilter.cc",
25
- "src/native/utils/TimeSeriesBuffer.cc"
27
+ "src/native/utils/TimeSeriesBuffer.cc",
28
+ "src/native/adapters/FilterStage.cc"
26
29
  ],
27
30
  "include_dirs": [
28
31
  "<!@(node -p \"require('node-addon-api').include\")",
@@ -38,7 +41,7 @@
38
41
  "cflags!": [ "-fno-exceptions" ],
39
42
  "cflags_cc!": [ "-fno-exceptions" ],
40
43
  "cflags": [ "-O3", "-ffast-math" ],
41
- "cflags_cc": [ "-std=c++17", "-O3", "-ffast-math" ],
44
+ "cflags_cc": [ "-std=c++17", "-O3", "-ffast-math" ],
42
45
  "msvs_settings": {
43
46
  "VCCLCompilerTool": {
44
47
  "ExceptionHandling": 1,
@@ -52,12 +55,42 @@
52
55
  "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
53
56
  "CLANG_CXX_LIBRARY": "libc++",
54
57
  "MACOSX_DEPLOYMENT_TARGET": "10.15",
55
- "OTHER_CPLUSPLUSFLAGS": [ "-std=c++17", "-stdlib=libc++", "-O3", "-ffast-math" ],
58
+ "OTHER_CPLUSPLUSFLAGS": [ "-std=c++17", "-stdlib=libc++", "-O3", "-ffast-math"],
56
59
  "GCC_OPTIMIZATION_LEVEL": "3"
57
60
  },
58
61
  "conditions": [
62
+ # Condition for Windows
59
63
  ["OS=='win'", {
60
64
  "defines": [ "_HAS_EXCEPTIONS=1" ]
65
+ }],
66
+ # Condition for x64 architecture (Linux/macOS)
67
+ ['target_arch=="x64"', {
68
+ "cflags+": [ "-msse3", "-mavx", "-mavx2" ],
69
+ "cflags_cc+": [ "-msse3", "-mavx", "-mavx2" ],
70
+ 'xcode_settings': {
71
+ 'OTHER_CPLUSPLUSFLAGS+': [ '-msse3', '-mavx', '-mavx2' ]
72
+ }
73
+ }],
74
+ # Condition for ia32 architecture (Linux/macOS - if you support 32-bit x86)
75
+ ['target_arch=="ia32"', {
76
+ "cflags+": [ "-msse3", "-mavx", "-mavx2" ], # Or adjust based on 32-bit support
77
+ "cflags_cc+": [ "-msse3", "-mavx", "-mavx2" ],
78
+ 'xcode_settings': {
79
+ 'OTHER_CPLUSPLUSFLAGS+': [ '-msse3', '-mavx', '-mavx2' ]
80
+ }
81
+ }],
82
+ # Condition for arm64 architecture (Android, iOS, M1/M2 Macs, Tensor G4, etc.)
83
+ ['target_arch=="arm64"', {
84
+ "cflags+": [ "-march=armv8-a+fp+simd" ], # Enable NEON and FP on ARMv8
85
+ "cflags_cc+": [ "-march=armv8-a+fp+simd" ],
86
+ 'xcode_settings': {
87
+ 'OTHER_CPLUSPLUSFLAGS+': [ '-march=armv8-a+fp+simd' ]
88
+ }
89
+ }],
90
+ # Condition for 32-bit ARM (older Android devices)
91
+ ['target_arch=="arm"', {
92
+ "cflags+": [ "-mfpu=neon", "-mfloat-abi=hard" ], # 32-bit ARM NEON
93
+ "cflags_cc+": [ "-mfpu=neon", "-mfloat-abi=hard" ],
61
94
  }]
62
95
  ]
63
96
  }