@denaudio/den 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +102 -2
- package/dist/biquad-eq.d.ts +11 -0
- package/dist/biquad-eq.js +35 -0
- package/dist/catalog-filter-math.d.ts +4 -0
- package/dist/catalog-filter-math.js +30 -0
- package/dist/character-filter.d.ts +13 -0
- package/dist/character-filter.js +53 -0
- package/dist/convolution-spectrum.d.ts +25 -0
- package/dist/convolution-spectrum.js +82 -0
- package/dist/convolution.d.ts +15 -0
- package/dist/convolution.js +81 -0
- package/dist/crossover.d.ts +11 -0
- package/dist/crossover.js +17 -0
- package/dist/curve-shaper.d.ts +26 -0
- package/dist/curve-shaper.js +73 -0
- package/dist/delay-fx.d.ts +37 -0
- package/dist/delay-fx.js +84 -0
- package/dist/delay-readhead.d.ts +19 -0
- package/dist/delay-readhead.js +54 -0
- package/dist/delay-settings.d.ts +55 -0
- package/dist/delay-settings.js +20 -0
- package/dist/drive.d.ts +24 -0
- package/dist/drive.js +116 -0
- package/dist/dual-head-delay.d.ts +28 -0
- package/dist/dual-head-delay.js +77 -0
- package/dist/dynamics.d.ts +61 -0
- package/dist/dynamics.js +130 -0
- package/dist/envelope.d.ts +34 -0
- package/dist/envelope.js +62 -0
- package/dist/filter.d.ts +9 -0
- package/dist/filter.js +34 -0
- package/dist/filterbank-vocoder.d.ts +35 -0
- package/dist/filterbank-vocoder.js +52 -0
- package/dist/formant-bank.d.ts +15 -0
- package/dist/formant-bank.js +28 -0
- package/dist/freeze-reverb.d.ts +35 -0
- package/dist/freeze-reverb.js +61 -0
- package/dist/frequency-shifter.d.ts +24 -0
- package/dist/frequency-shifter.js +57 -0
- package/dist/gate.d.ts +2 -0
- package/dist/gate.js +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +12 -0
- package/dist/instrument-example.d.ts +12 -0
- package/dist/instrument-example.js +29 -0
- package/dist/instrument-settings.d.ts +95 -0
- package/dist/instrument-settings.js +36 -0
- package/dist/instrument.d.ts +42 -0
- package/dist/instrument.js +166 -0
- package/dist/lfo.d.ts +19 -0
- package/dist/lfo.js +55 -0
- package/dist/live-buffer.d.ts +39 -0
- package/dist/live-buffer.js +52 -0
- package/dist/live-granular.d.ts +41 -0
- package/dist/live-granular.js +64 -0
- package/dist/lookahead-limiter.d.ts +31 -0
- package/dist/lookahead-limiter.js +67 -0
- package/dist/loop-crossfade.d.ts +28 -0
- package/dist/loop-crossfade.js +72 -0
- package/dist/modulation-fx.d.ts +47 -0
- package/dist/modulation-fx.js +58 -0
- package/dist/modulation.d.ts +132 -0
- package/dist/modulation.js +228 -0
- package/dist/mpe-expression.d.ts +36 -0
- package/dist/mpe-expression.js +73 -0
- package/dist/multiband-dynamics.d.ts +50 -0
- package/dist/multiband-dynamics.js +60 -0
- package/dist/musical-controls.d.ts +76 -0
- package/dist/musical-controls.js +125 -0
- package/dist/musical-examples.d.ts +21 -0
- package/dist/musical-examples.js +142 -0
- package/dist/musical-materials.d.ts +110 -0
- package/dist/musical-materials.js +56 -0
- package/dist/oscillator.d.ts +10 -0
- package/dist/oscillator.js +35 -0
- package/dist/oversampled-drive.d.ts +19 -0
- package/dist/oversampled-drive.js +99 -0
- package/dist/performance.d.ts +61 -0
- package/dist/performance.js +241 -0
- package/dist/pitch-quantizer.d.ts +26 -0
- package/dist/pitch-quantizer.js +88 -0
- package/dist/prepared-convolution.d.ts +22 -0
- package/dist/prepared-convolution.js +99 -0
- package/dist/resident-recorder.d.ts +28 -0
- package/dist/resident-recorder.js +68 -0
- package/dist/resident-time-stretch.d.ts +44 -0
- package/dist/resident-time-stretch.js +135 -0
- package/dist/resonator.d.ts +32 -0
- package/dist/resonator.js +63 -0
- package/dist/reverb.d.ts +27 -0
- package/dist/reverb.js +52 -0
- package/dist/sample.d.ts +113 -0
- package/dist/sample.js +212 -0
- package/dist/source.d.ts +58 -0
- package/dist/source.js +113 -0
- package/dist/spatial-chains.d.ts +48 -0
- package/dist/spatial-chains.js +76 -0
- package/dist/spectral-fft.d.ts +21 -0
- package/dist/spectral-fft.js +74 -0
- package/dist/spectral-freeze.d.ts +22 -0
- package/dist/spectral-freeze.js +74 -0
- package/dist/spectral-gate.d.ts +21 -0
- package/dist/spectral-gate.js +58 -0
- package/dist/spectral-stft.d.ts +13 -0
- package/dist/spectral-stft.js +69 -0
- package/dist/spectral-texture.d.ts +42 -0
- package/dist/spectral-texture.js +141 -0
- package/dist/spectral.d.ts +16 -0
- package/dist/spectral.js +10 -0
- package/dist/state-variable-filter.d.ts +17 -0
- package/dist/state-variable-filter.js +25 -0
- package/dist/stereo-delay.d.ts +45 -0
- package/dist/stereo-delay.js +70 -0
- package/dist/virtual-analog.d.ts +26 -0
- package/dist/virtual-analog.js +66 -0
- package/dist/voice-policy.d.ts +37 -0
- package/dist/voice-policy.js +245 -0
- package/dist/wavetable-bands.d.ts +37 -0
- package/dist/wavetable-bands.js +145 -0
- package/dist/wavetable-read.d.ts +6 -0
- package/dist/wavetable-read.js +11 -0
- package/dist/wavetable.d.ts +29 -0
- package/dist/wavetable.js +49 -0
- package/dist/windowed-pitch-shift.d.ts +34 -0
- package/dist/windowed-pitch-shift.js +51 -0
- package/docs/catalog-audition.md +76 -0
- package/docs/catalog-filters.md +125 -0
- package/docs/catalog-modulation-fx.md +220 -0
- package/docs/catalog-status.md +431 -0
- package/docs/character-filter.md +139 -0
- package/docs/contracts.md +131 -0
- package/docs/control-modulation.md +194 -0
- package/docs/convolution.md +45 -0
- package/docs/curve-shaper.md +117 -0
- package/docs/delay-fx-capture-findings.json +134 -0
- package/docs/delay-fx.md +202 -0
- package/docs/delay-readhead.md +121 -0
- package/docs/delay-settings-candidate.json +333 -0
- package/docs/delay-settings.md +111 -0
- package/docs/dependency-findings.md +61 -0
- package/docs/deployment-status.md +37 -0
- package/docs/drive.md +152 -0
- package/docs/dual-head-delay.md +131 -0
- package/docs/dynamics.md +180 -0
- package/docs/envelope-integer-staging.md +64 -0
- package/docs/filter-materialization-results.json +71 -0
- package/docs/filter-materialization.md +135 -0
- package/docs/filter-oscillator.md +126 -0
- package/docs/filterbank-vocoder-entry.md +58 -0
- package/docs/freeze-reverb.md +179 -0
- package/docs/frequency-shifter.md +133 -0
- package/docs/frontend-audition.md +22 -0
- package/docs/gain-schedule-verification.md +53 -0
- package/docs/initial-acceptance.md +79 -0
- package/docs/instrument-performance.md +191 -0
- package/docs/instrument-settings.md +130 -0
- package/docs/instrument.md +204 -0
- package/docs/integration-candidate.md +114 -0
- package/docs/live-buffer.md +163 -0
- package/docs/live-granular.md +179 -0
- package/docs/lookahead-multiband.md +183 -0
- package/docs/loop-crossfade.md +99 -0
- package/docs/mpe-expression.md +65 -0
- package/docs/musical-clock-seek-boundary.md +31 -0
- package/docs/musical-controls-contract.md +144 -0
- package/docs/musical-examples.md +255 -0
- package/docs/oversampled-drive.md +153 -0
- package/docs/performance.md +53 -0
- package/docs/pitch-quantizer.md +55 -0
- package/docs/prepared-convolution.md +188 -0
- package/docs/realtime-audition.md +63 -0
- package/docs/resident-recorder.md +151 -0
- package/docs/resident-time-stretch.md +190 -0
- package/docs/sample.md +191 -0
- package/docs/sound-audition-headroom.md +103 -0
- package/docs/sources.md +81 -0
- package/docs/spatial-chains-entry.md +250 -0
- package/docs/spectral-freeze-entry.md +130 -0
- package/docs/spectral-gate-entry.md +130 -0
- package/docs/spectral-large-candidate.md +74 -0
- package/docs/spectral-texture-entry.md +174 -0
- package/docs/spectral.md +118 -0
- package/docs/virtual-analog.md +77 -0
- package/docs/voice-policy.md +38 -0
- package/docs/wavetable-bands.md +138 -0
- package/docs/wavetable.md +101 -0
- package/docs/windowed-pitch-shift.md +112 -0
- package/package.json +269 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Release pull requests add a dated version section here, with breaking changes
|
|
4
|
+
and migration instructions first. Unreleased entries do not imply npm availability.
|
|
5
|
+
|
|
6
|
+
## Unreleased
|
|
7
|
+
|
|
8
|
+
## 0.1.0 — 2026-10-09
|
|
9
|
+
|
|
10
|
+
- First public npm release of `@denaudio/den`, with 54 ESM module entry points,
|
|
11
|
+
TypeScript declarations, public DSP documentation and MIT OR Apache-2.0 licensing.
|
|
12
|
+
- Requires the tested `@unworklet/core` peer dependency at `0.4.1`.
|
|
13
|
+
- Add release-PR automation, npm trusted publishing, package-boundary checks and
|
|
14
|
+
version preparation for the package and its locked consumers.
|
|
15
|
+
- The initial DSP catalog remains CANDIDATE. See
|
|
16
|
+
[catalog status](docs/catalog-status.md) and
|
|
17
|
+
[initial acceptance](docs/initial-acceptance.md) for validation boundaries.
|
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright (c) 2026 den contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 den contributors
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# den
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Composable DSP modules, one MIDI instrument engine and one stereo Delay FX
|
|
4
|
+
engine built on unworklet. The initial candidate includes Bass, Percussion and
|
|
5
|
+
Pad from the same instrument, plus Chorus and Rhythmic delay settings from the
|
|
6
|
+
same Delay engine. Audio remains **CANDIDATE**, not an approved golden.
|
|
7
|
+
|
|
8
|
+
## Setup and verification
|
|
9
|
+
|
|
10
|
+
Use Node **24.19.0** (npm **11.9.0**). No Rust, Cargo, wasm-pack, Vite+, or external
|
|
11
|
+
WASM compiler is required. Binaryen comes from unworklet.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm ci
|
|
15
|
+
npm exec -- playwright install --with-deps chromium
|
|
16
|
+
npm run check
|
|
17
|
+
npm test
|
|
18
|
+
npm run build:site
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
With an existing Chromium installation, use `CHROMIUM_PATH=/usr/bin/chromium npm test`.
|
|
22
|
+
The tests build declarations/ESM, run independent numerical references, pack the
|
|
23
|
+
package, install it in clean locked consumers, build actual worklet/WASM assets,
|
|
24
|
+
and exercise real browser MIDI, AudioParams, snapshots and UI lifecycle. Generated
|
|
25
|
+
source/audio/waveform manifests and failures are retained in `artifacts/`; CI
|
|
26
|
+
uploads them. These verification commands do not publish to a registry.
|
|
27
|
+
|
|
28
|
+
## Code playground
|
|
29
|
+
|
|
30
|
+
`npm run build:site` packs the current den source into an isolated consumer and
|
|
31
|
+
builds the English TypeScript playground at `/`. Its Monaco editor resolves real
|
|
32
|
+
package declarations for completion, hover, signatures and diagnostics. Every
|
|
33
|
+
public import has an editable audio example. Run compiles in a cancellable
|
|
34
|
+
worker, creates a native node, and exposes its AudioParams; Stop disposes it.
|
|
35
|
+
See the [source format and host contract](https://github.com/yuichkun/den/blob/3042e73435986fa2804f5811604e784d93470c1f/playground/README.md).
|
|
36
|
+
|
|
37
|
+
The earlier public website was deleted before this replacement. Old
|
|
38
|
+
`catalog.html`, `audition.html`, `diagnostics.html` and `playground.html` routes
|
|
39
|
+
stay absent. Historical browser surfaces exist only as isolated test fixtures;
|
|
40
|
+
their canonical audio, MIDI, snapshot and interrupted-lifecycle gates remain.
|
|
41
|
+
See [deployment status](docs/deployment-status.md).
|
|
42
|
+
|
|
43
|
+
This replacement is under review. Generated audio remains **CANDIDATE**;
|
|
44
|
+
passing tests is not listening approval or all-device real-time acceptance.
|
|
45
|
+
See the [acceptance record](docs/initial-acceptance.md).
|
|
46
|
+
|
|
47
|
+
## Public package boundary
|
|
48
|
+
|
|
49
|
+
The ESM-only `@denaudio/den` requires **@unworklet/core 0.4.1** as a peer. All
|
|
50
|
+
exercised compiler, renderer, plugin and test dependencies are locked. Import
|
|
51
|
+
editable construction functions/subgraphs through these public subpaths:
|
|
52
|
+
|
|
53
|
+
- `@denaudio/den/envelope`, `/lfo`, `/filter`, `/oscillator`, `/voice-policy`
|
|
54
|
+
- `@denaudio/den/instrument`: `createInstrument`, diagnostic processor and the three sound settings
|
|
55
|
+
- `@denaudio/den/instrument-example`: custom oscillator/filter replacement example
|
|
56
|
+
- `@denaudio/den/delay-readhead`, `/delay-fx`, `/delay-settings`
|
|
57
|
+
- `@denaudio/den` and `/gate`: minimal composition and package diagnostics
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { createInstrument, bassConfig, bassParameters } from '@denaudio/den/instrument';
|
|
61
|
+
// Re-export this processor from a consumer module imported with ?worklet.
|
|
62
|
+
export default createInstrument(bassConfig);
|
|
63
|
+
// Pass bassParameters as createNode's initial AudioParam map.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use the existing `@unworklet/unplugin` Vite plugin and `createNode`; den adds no
|
|
67
|
+
loader, parameter, MIDI, routing, snapshot or serialization framework. Settings
|
|
68
|
+
are plain engine construction options and complete native parameter maps.
|
|
69
|
+
Snapshots require the same processor/schema/sample rate. See the
|
|
70
|
+
[instrument contract](docs/instrument.md), [sound settings](docs/instrument-settings.md),
|
|
71
|
+
[Delay FX contract](docs/delay-fx.md), [effect settings](docs/delay-settings.md),
|
|
72
|
+
[shared contracts](docs/contracts.md), and [dependency limitations](docs/dependency-findings.md).
|
|
73
|
+
|
|
74
|
+
## Extended catalog candidates
|
|
75
|
+
|
|
76
|
+
The [catalog coverage record](docs/catalog-status.md) lists additive clean filter/EQ,
|
|
77
|
+
formant/crossover, dynamics, drive/reduction, modulation/reverb, source/resonator
|
|
78
|
+
control/sequence/arpeggiator, sample/granular, wavetable/VA, sustain/expression
|
|
79
|
+
bounded spectral/convolution, character/frequency-shift, limiter/multiband,
|
|
80
|
+
editable-curve, fixed oversampling, dual-head delay, windowed pitch-shift,
|
|
81
|
+
manual lower-zone expression, framewise spectral gate, prepared convolution,
|
|
82
|
+
crossfaded loops, bounded native take recording, rolling accepted-write history and live grains, freeze/thaw tails, experimental resident WSOLA, musical pitch quantization, bin-centered spectral freeze, frequency-magnitude blur, gain-capped cross-synthesis, fixed filter-bank vocoder, segment-relative curved envelopes and tempo multiwave LFOs, hybrid spatial chains with feedforward pitched tails and musical-example candidates,
|
|
83
|
+
with their public imports, independent tests and remaining work. These modules
|
|
84
|
+
have separate acceptance evidence; the initial five sounds' feedback does not
|
|
85
|
+
approve new audio automatically.
|
|
86
|
+
|
|
87
|
+
## Evidence and scope
|
|
88
|
+
|
|
89
|
+
The [integration notes](docs/integration-candidate.md) describe lifecycle and
|
|
90
|
+
4×3 sound/FX coverage; [headroom evidence](docs/sound-audition-headroom.md) records
|
|
91
|
+
the bounded fixed-input measurements. [Deployment](docs/deployment-status.md)
|
|
92
|
+
uses the same packed consumers as the tests. Candidate audio has independent
|
|
93
|
+
numerical assertions and source/settings/input/audio/static-waveform manifests.
|
|
94
|
+
Golden promotion requires human approval tied to exact source/audio hashes in
|
|
95
|
+
a separate change. CI success does not supply that approval.
|
|
96
|
+
|
|
97
|
+
This is a fresh TS/unworklet implementation. The retired Rust/WASM contents are
|
|
98
|
+
preserved only in Git history. MIT/Apache-2.0 notices and attribution remain.
|
|
99
|
+
Development snapshots may use version `0.0.0`. Releases use reviewed
|
|
100
|
+
`release/vX.Y.Z` pull requests and npm trusted publishing; see the
|
|
101
|
+
[release guide](https://github.com/yuichkun/den/blob/main/RELEASE.md) and
|
|
102
|
+
[changelog](CHANGELOG.md). Before 1.0, breaking changes increment the minor
|
|
103
|
+
version. The automation setup itself does not publish a package.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Node } from '@unworklet/core';
|
|
2
|
+
export type BiquadEqMode = 'peaking' | 'lowShelf' | 'highShelf';
|
|
3
|
+
export interface BiquadEqConfig {
|
|
4
|
+
sampleRate: number;
|
|
5
|
+
mode: BiquadEqMode;
|
|
6
|
+
}
|
|
7
|
+
/** RBJ-equivalent responses realized with a linear TPT SVF; shelves use S=1. */
|
|
8
|
+
export declare const biquadEq: import("@unworklet/core").SubgraphDecl<[config: BiquadEqConfig], {
|
|
9
|
+
/** Cutoff [20,min(20000,.45*fs)], Q [.5,10], gain [-24,24] dB. Q is unused by S=1 shelves. */
|
|
10
|
+
tick(input: Node<"f32">, cutoffHz: Node<"f32">, q: Node<"f32">, gainDb: Node<"f32">, reset: Node<"bool">): Node<"f32">;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineSubgraph, f32, f64, select, state } from '@unworklet/core';
|
|
2
|
+
import { boundedDbAmplitude, checkedSampleRate, tangentHalfAngle } from './catalog-filter-math.js';
|
|
3
|
+
/** RBJ-equivalent responses realized with a linear TPT SVF; shelves use S=1. */
|
|
4
|
+
export const biquadEq = defineSubgraph((config) => {
|
|
5
|
+
const maximum = checkedSampleRate(config.sampleRate);
|
|
6
|
+
if (!['peaking', 'lowShelf', 'highShelf'].includes(config.mode))
|
|
7
|
+
throw new TypeError('Unknown biquad EQ mode');
|
|
8
|
+
const historyScale = 2 ** 128; // Preserve f32 histories through upstream scalar-state flush.
|
|
9
|
+
const band = state.f64(0).named('band'), low = state.f64(0).named('low');
|
|
10
|
+
const tangent = state.f64(0).named('coefficientG'), amplitude = state.f64(1).named('coefficientA');
|
|
11
|
+
return {
|
|
12
|
+
/** Cutoff [20,min(20000,.45*fs)], Q [.5,10], gain [-24,24] dB. Q is unused by S=1 shelves. */
|
|
13
|
+
tick(input, cutoffHz, q, gainDb, reset) {
|
|
14
|
+
const s1 = select(reset, f64(0), band.read().div(historyScale));
|
|
15
|
+
const s2 = select(reset, f64(0), low.read().div(historyScale));
|
|
16
|
+
amplitude.write(boundedDbAmplitude(gainDb));
|
|
17
|
+
const A = amplitude.read(), baseG = tangentHalfAngle(cutoffHz, config.sampleRate, maximum);
|
|
18
|
+
const sqrtA = boundedDbAmplitude(gainDb, 80);
|
|
19
|
+
tangent.write(config.mode === 'lowShelf' ? baseG.div(sqrtA) : config.mode === 'highShelf' ? baseG.mul(sqrtA) : baseG);
|
|
20
|
+
const g = tangent.read(), x = f64(input);
|
|
21
|
+
const k = config.mode === 'peaking' ? f64(1).div(f64(q).clamp(.5, 10).mul(A)) : f64(Math.SQRT2);
|
|
22
|
+
const v1 = s1.add(g.mul(x.sub(s2))).div(g.mul(g.add(k)).add(1));
|
|
23
|
+
const v2 = s2.add(g.mul(v1));
|
|
24
|
+
band.write(v1.mul(2).sub(s1).mul(historyScale));
|
|
25
|
+
low.write(v2.mul(2).sub(s2).mul(historyScale));
|
|
26
|
+
// x + mixed SVF responses. This avoids a time-varying direct-form
|
|
27
|
+
// realization whose changing coefficients can pump its state to overflow.
|
|
28
|
+
if (config.mode === 'peaking')
|
|
29
|
+
return f32(x.add(k.mul(A.mul(A).sub(1)).mul(v1)));
|
|
30
|
+
if (config.mode === 'lowShelf')
|
|
31
|
+
return f32(x.add(k.mul(A.sub(1)).mul(v1)).add(A.mul(A).sub(1).mul(v2)));
|
|
32
|
+
return f32(A.mul(A).mul(x).add(k.mul(A).mul(f64(1).sub(A)).mul(v1)).add(f64(1).sub(A.mul(A)).mul(v2)));
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Node } from '@unworklet/core';
|
|
2
|
+
export declare function checkedSampleRate(sampleRate: number): number;
|
|
3
|
+
export declare function tangentHalfAngle(frequency: Node<'f32'>, sampleRate: number, maximum: number): Node<"f64">;
|
|
4
|
+
export declare function boundedDbAmplitude(db: Node<'f32'>, divisor?: number): Node<"f64">;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { f64 } from '@unworklet/core';
|
|
2
|
+
export function checkedSampleRate(sampleRate) {
|
|
3
|
+
if (!Number.isFinite(sampleRate) || sampleRate < 8000 || sampleRate > 192000) {
|
|
4
|
+
throw new RangeError('sampleRate must be finite and in [8000, 192000] Hz');
|
|
5
|
+
}
|
|
6
|
+
return Math.min(20000, 0.45 * sampleRate);
|
|
7
|
+
}
|
|
8
|
+
// Bounded half-angle Taylor polynomials avoid f32 transcendental lowering in
|
|
9
|
+
// unworklet 0.4.1. Same formula as the reviewed initial low-pass, no dependency
|
|
10
|
+
// or existing processor/schema change. Domain: [0, .45*pi].
|
|
11
|
+
export function tangentHalfAngle(frequency, sampleRate, maximum) {
|
|
12
|
+
const a = f64(frequency).clamp(20, maximum).mul(Math.PI / sampleRate), z = a.mul(a);
|
|
13
|
+
const sine = a.mul(f64(-1 / 6227020800).mul(z).add(1 / 39916800).mul(z).sub(1 / 362880).mul(z).add(1 / 5040).mul(z).sub(1 / 120).mul(z).add(1 / 6).mul(z).neg().add(1));
|
|
14
|
+
const cosine = f64(-1 / 87178291200).mul(z).add(1 / 479001600).mul(z).sub(1 / 3628800).mul(z).add(1 / 40320).mul(z).sub(1 / 720).mul(z).add(1 / 24).mul(z).sub(1 / 2).mul(z).add(1);
|
|
15
|
+
return sine.div(cosine);
|
|
16
|
+
}
|
|
17
|
+
// exp(x), |x| <= ln(10)*24/40. Degree 16; no arbitrary exp domain promise.
|
|
18
|
+
export function boundedDbAmplitude(db, divisor = 40) {
|
|
19
|
+
const x = f64(db).clamp(-24, 24).mul(Math.LN10 / divisor);
|
|
20
|
+
let factorial = 1;
|
|
21
|
+
const inverse = [1];
|
|
22
|
+
for (let n = 1; n <= 16; n++) {
|
|
23
|
+
factorial *= n;
|
|
24
|
+
inverse.push(1 / factorial);
|
|
25
|
+
}
|
|
26
|
+
let result = f64(inverse[16]);
|
|
27
|
+
for (let n = 15; n >= 0; n--)
|
|
28
|
+
result = result.mul(x).add(inverse[n]);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Node } from '@unworklet/core';
|
|
2
|
+
export interface CharacterFilterConfig {
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
/** Four saturating one-poles, current-sample cascade, one-sample global feedback.
|
|
6
|
+
* poleHz is individual matched-z tuning, not overall -3 dB cutoff or Q.
|
|
7
|
+
* See docs/character-filter.md for the exact topology and convex-state bound.
|
|
8
|
+
*/
|
|
9
|
+
export declare const characterFilter: import("@unworklet/core").SubgraphDecl<[config: CharacterFilterConfig], {
|
|
10
|
+
/** Once per sample. Input [-8,8], poleHz [20,min(20000,fs/5)],
|
|
11
|
+
* resonance [0,1] -> feedback [0,4], linear drive [0,16]. */
|
|
12
|
+
tick(input: Node<"f32">, poleHz: Node<"f32">, resonance: Node<"f32">, drive: Node<"f32">, reset: Node<"bool">): Node<"f32">;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineSubgraph, f32, f64, select, sqrt, state } from '@unworklet/core';
|
|
2
|
+
const HISTORY_SCALE = 2 ** 128;
|
|
3
|
+
function bounded(value, lower, upper, fallback) {
|
|
4
|
+
const wide = f64(value);
|
|
5
|
+
return select(wide.eq(wide), wide, f64(fallback)).clamp(lower, upper);
|
|
6
|
+
}
|
|
7
|
+
// 1 - exp(-x), 0 < x <= 2*pi/5. The degree-18 alternating polynomial
|
|
8
|
+
// avoids unworklet 0.4.1's f32 transcendental lowering. No unbounded domain.
|
|
9
|
+
function coefficient(x) {
|
|
10
|
+
let factorial = 1;
|
|
11
|
+
const terms = [0];
|
|
12
|
+
for (let n = 1; n <= 18; n++) {
|
|
13
|
+
factorial *= n;
|
|
14
|
+
terms.push((n % 2 ? 1 : -1) / factorial);
|
|
15
|
+
}
|
|
16
|
+
let value = f64(terms[18]);
|
|
17
|
+
for (let n = 17; n >= 1; n--)
|
|
18
|
+
value = value.mul(x).add(terms[n]);
|
|
19
|
+
return value.mul(x);
|
|
20
|
+
}
|
|
21
|
+
/** Four saturating one-poles, current-sample cascade, one-sample global feedback.
|
|
22
|
+
* poleHz is individual matched-z tuning, not overall -3 dB cutoff or Q.
|
|
23
|
+
* See docs/character-filter.md for the exact topology and convex-state bound.
|
|
24
|
+
*/
|
|
25
|
+
export const characterFilter = defineSubgraph((config) => {
|
|
26
|
+
const { sampleRate } = config;
|
|
27
|
+
if (!Number.isFinite(sampleRate) || sampleRate < 8000 || sampleRate > 192000) {
|
|
28
|
+
throw new RangeError('characterFilter sampleRate must be finite and in [8000, 192000] Hz');
|
|
29
|
+
}
|
|
30
|
+
const maximumHz = Math.min(20000, sampleRate / 5);
|
|
31
|
+
const stages = Array.from({ length: 4 }, (_, i) => state.f64(0).named(`stage-${i + 1}-scaled`));
|
|
32
|
+
return {
|
|
33
|
+
/** Once per sample. Input [-8,8], poleHz [20,min(20000,fs/5)],
|
|
34
|
+
* resonance [0,1] -> feedback [0,4], linear drive [0,16]. */
|
|
35
|
+
tick(input, poleHz, resonance, drive, reset) {
|
|
36
|
+
const old = stages.map(slot => select(reset, f64(0), slot.read().div(HISTORY_SCALE)));
|
|
37
|
+
// Materialize the coefficient in a captured history slot. All old states
|
|
38
|
+
// are already locals; the normal stage-one history is restored below.
|
|
39
|
+
stages[0].write(coefficient(bounded(poleHz, 20, maximumHz, 20).mul(2 * Math.PI / sampleRate)));
|
|
40
|
+
const a = stages[0].read(), b = f64(1).sub(a);
|
|
41
|
+
let value = bounded(input, -8, 8, 0).mul(bounded(drive, 0, 16, 1))
|
|
42
|
+
.sub(old[3].mul(bounded(resonance, 0, 1, 0)).mul(4));
|
|
43
|
+
for (let i = 0; i < 4; i++) {
|
|
44
|
+
const saturated = value.div(sqrt(value.mul(value).add(1)));
|
|
45
|
+
stages[i].write(old[i].mul(b).add(saturated.mul(a)).mul(HISTORY_SCALE));
|
|
46
|
+
// read() is a materialized local. Avoid recursively duplicating the
|
|
47
|
+
// nonlinear stage expression and preserve tiny audio between stages.
|
|
48
|
+
value = stages[i].read().div(HISTORY_SCALE);
|
|
49
|
+
}
|
|
50
|
+
return f32(value);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Fixed first prepared-convolution capacity. No sample-rate conversion here. */
|
|
2
|
+
export interface PreparedConvolutionConfig {
|
|
3
|
+
blockSize: number;
|
|
4
|
+
partitions: number;
|
|
5
|
+
}
|
|
6
|
+
export interface PreparedConvolutionPacket {
|
|
7
|
+
formatVersion: number;
|
|
8
|
+
blockSize: number;
|
|
9
|
+
partitions: number;
|
|
10
|
+
impulseFrames: number;
|
|
11
|
+
declaredValues: number;
|
|
12
|
+
spectrum: Float32Array;
|
|
13
|
+
}
|
|
14
|
+
export declare const PREPARED_BLOCK = 128;
|
|
15
|
+
export declare const PREPARED_FFT_SIZE = 256;
|
|
16
|
+
export declare const PREPARED_PARTITIONS = 64;
|
|
17
|
+
export declare const PREPARED_VALUES = 32768;
|
|
18
|
+
export declare const PREPARATION_ERROR_LIMIT = 0.000004;
|
|
19
|
+
export declare function validatePreparedConvolutionConfig(config: PreparedConvolutionConfig): void;
|
|
20
|
+
/** Host-only preparation. Do not call from an audio callback.
|
|
21
|
+
* Returns a complete native f32 packet; send it unchanged through the caller's
|
|
22
|
+
* explicitly sized native event. The original IR is not normalized or clipped.
|
|
23
|
+
* Quantization is approximate, with a guarded inverse-DFT error certificate.
|
|
24
|
+
*/
|
|
25
|
+
export declare function prepareConvolutionSpectrum(impulse: readonly number[] | Float32Array | Float64Array, config: PreparedConvolutionConfig): PreparedConvolutionPacket;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const PREPARED_BLOCK = 128;
|
|
2
|
+
export const PREPARED_FFT_SIZE = 256;
|
|
3
|
+
export const PREPARED_PARTITIONS = 64;
|
|
4
|
+
export const PREPARED_VALUES = 32768;
|
|
5
|
+
export const PREPARATION_ERROR_LIMIT = 4e-6;
|
|
6
|
+
const CERTIFICATE_GUARD = 1e-8;
|
|
7
|
+
export function validatePreparedConvolutionConfig(config) {
|
|
8
|
+
if (!config || config.blockSize !== PREPARED_BLOCK || config.partitions !== PREPARED_PARTITIONS) {
|
|
9
|
+
throw new RangeError('preparedConvolution requires fixed blockSize 128 and partitions 64');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Host-only preparation. Do not call from an audio callback.
|
|
13
|
+
* Returns a complete native f32 packet; send it unchanged through the caller's
|
|
14
|
+
* explicitly sized native event. The original IR is not normalized or clipped.
|
|
15
|
+
* Quantization is approximate, with a guarded inverse-DFT error certificate.
|
|
16
|
+
*/
|
|
17
|
+
export function prepareConvolutionSpectrum(impulse, config) {
|
|
18
|
+
validatePreparedConvolutionConfig(config);
|
|
19
|
+
if (!(Array.isArray(impulse) || impulse instanceof Float32Array || impulse instanceof Float64Array) || impulse.length < 1 || impulse.length > 8192) {
|
|
20
|
+
throw new RangeError('prepared convolution IR requires 1..8192 real taps');
|
|
21
|
+
}
|
|
22
|
+
const taps = Array.from(impulse);
|
|
23
|
+
let absoluteSum = 0, compensation = 0;
|
|
24
|
+
for (const tap of taps) {
|
|
25
|
+
if (!Number.isFinite(tap) || Math.abs(tap) > 1)
|
|
26
|
+
throw new RangeError('prepared convolution IR taps must be finite in [-1,1]');
|
|
27
|
+
const increment = Math.abs(tap) - compensation, next = absoluteSum + increment;
|
|
28
|
+
compensation = (next - absoluteSum) - increment;
|
|
29
|
+
absoluteSum = next;
|
|
30
|
+
}
|
|
31
|
+
if (absoluteSum > 4)
|
|
32
|
+
throw new RangeError('prepared convolution IR absolute sum must be <=4');
|
|
33
|
+
const B = PREPARED_BLOCK, N = PREPARED_FFT_SIZE;
|
|
34
|
+
const spectrum = new Float32Array(PREPARED_VALUES);
|
|
35
|
+
const cosine = Float64Array.from({ length: N }, (_, n) => Math.cos(2 * Math.PI * n / N));
|
|
36
|
+
const sine = Float64Array.from({ length: N }, (_, n) => Math.sin(2 * Math.PI * n / N));
|
|
37
|
+
// Independent inverse basis, with modulo-reduced arguments. It checks every
|
|
38
|
+
// reconstructed tap, including the half that is ideally zero padding.
|
|
39
|
+
const inverseCos = Float64Array.from({ length: N * N }, (_, index) => {
|
|
40
|
+
const n = Math.floor(index / N), k = index % N;
|
|
41
|
+
return Math.cos(2 * Math.PI * ((n * k) % N) / N);
|
|
42
|
+
});
|
|
43
|
+
const inverseSin = Float64Array.from({ length: N * N }, (_, index) => {
|
|
44
|
+
const n = Math.floor(index / N), k = index % N;
|
|
45
|
+
return Math.sin(2 * Math.PI * ((n * k) % N) / N);
|
|
46
|
+
});
|
|
47
|
+
let error = CERTIFICATE_GUARD;
|
|
48
|
+
for (let p = 0; p < Math.ceil(taps.length / B); p++) {
|
|
49
|
+
const values = Array.from({ length: B }, (_, n) => taps[p * B + n] ?? 0);
|
|
50
|
+
if (values.every(value => value === 0))
|
|
51
|
+
continue;
|
|
52
|
+
for (let k = 0; k <= N / 2; k++) {
|
|
53
|
+
let real = 0, imag = 0;
|
|
54
|
+
for (let n = 0; n < B; n++) {
|
|
55
|
+
real += values[n] * cosine[(k * n) % N];
|
|
56
|
+
imag -= values[n] * sine[(k * n) % N];
|
|
57
|
+
}
|
|
58
|
+
const re = Math.fround(real), im = k === 0 || k === N / 2 ? 0 : Math.fround(imag);
|
|
59
|
+
if (!Number.isFinite(re) || !Number.isFinite(im) || Math.abs(re) > 4 || Math.abs(im) > 4)
|
|
60
|
+
throw new RangeError('prepared convolution spectrum exceeds finite component bounds');
|
|
61
|
+
spectrum[2 * (p * N + k)] = re;
|
|
62
|
+
spectrum[2 * (p * N + k) + 1] = im;
|
|
63
|
+
if (k > 0 && k < N / 2) {
|
|
64
|
+
spectrum[2 * (p * N + N - k)] = re;
|
|
65
|
+
spectrum[2 * (p * N + N - k) + 1] = -im;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (let n = 0; n < N; n++) {
|
|
69
|
+
let real = 0, imag = 0;
|
|
70
|
+
for (let k = 0; k < N; k++) {
|
|
71
|
+
const re = spectrum[2 * (p * N + k)], im = spectrum[2 * (p * N + k) + 1];
|
|
72
|
+
const c = inverseCos[n * N + k], s = inverseSin[n * N + k];
|
|
73
|
+
real += re * c - im * s;
|
|
74
|
+
imag += re * s + im * c;
|
|
75
|
+
}
|
|
76
|
+
error += Math.abs(real / N - (values[n] ?? 0)) + Math.abs(imag / N);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!Number.isFinite(error) || error > PREPARATION_ERROR_LIMIT)
|
|
80
|
+
throw new RangeError('prepared convolution IR exceeds the guarded 4e-6 quantization certificate');
|
|
81
|
+
return { formatVersion: 1, blockSize: B, partitions: PREPARED_PARTITIONS, impulseFrames: taps.length, declaredValues: PREPARED_VALUES, spectrum };
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type EveryNSamples, type Node } from '@unworklet/core';
|
|
2
|
+
export interface PartitionedConvolutionConfig {
|
|
3
|
+
/** Construction-fixed power of two in [4,32]. FFT size is twice this value. */
|
|
4
|
+
blockSize: number;
|
|
5
|
+
/** Fixed IR, length 1..4*blockSize. Every tap in [-1,1], total absolute gain <=4. */
|
|
6
|
+
impulse: readonly number[];
|
|
7
|
+
}
|
|
8
|
+
/** Bounded uniform-partition convolution candidate, exactly blockSize latency.
|
|
9
|
+
* Call once per sample in stride-1 forSample with its native everyNSamples.
|
|
10
|
+
* Input must be finite normalized audio [-1,1]. No IR loader/swap or dry path.
|
|
11
|
+
* Level reset silences immediately and discards its input without rephasing hops.
|
|
12
|
+
*/
|
|
13
|
+
export declare const partitionedConvolution: import("@unworklet/core").SubgraphDecl<[config: PartitionedConvolutionConfig], {
|
|
14
|
+
tick(input: Node<"f32">, reset: Node<"bool">, everyNSamples: EveryNSamples): Node<"f32">;
|
|
15
|
+
}>;
|