@denaudio/den 0.0.0-stage → 0.2.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.
Files changed (191) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE-APACHE +202 -0
  3. package/LICENSE-MIT +21 -0
  4. package/README.md +107 -2
  5. package/dist/biquad-eq.d.ts +11 -0
  6. package/dist/biquad-eq.js +35 -0
  7. package/dist/catalog-filter-math.d.ts +4 -0
  8. package/dist/catalog-filter-math.js +30 -0
  9. package/dist/character-filter.d.ts +13 -0
  10. package/dist/character-filter.js +53 -0
  11. package/dist/convolution-spectrum.d.ts +25 -0
  12. package/dist/convolution-spectrum.js +82 -0
  13. package/dist/convolution.d.ts +17 -0
  14. package/dist/convolution.js +87 -0
  15. package/dist/crossover.d.ts +11 -0
  16. package/dist/crossover.js +17 -0
  17. package/dist/curve-shaper.d.ts +26 -0
  18. package/dist/curve-shaper.js +73 -0
  19. package/dist/delay-fx.d.ts +37 -0
  20. package/dist/delay-fx.js +84 -0
  21. package/dist/delay-readhead.d.ts +19 -0
  22. package/dist/delay-readhead.js +54 -0
  23. package/dist/delay-settings.d.ts +55 -0
  24. package/dist/delay-settings.js +20 -0
  25. package/dist/drive.d.ts +24 -0
  26. package/dist/drive.js +116 -0
  27. package/dist/dual-head-delay.d.ts +28 -0
  28. package/dist/dual-head-delay.js +77 -0
  29. package/dist/dynamics.d.ts +61 -0
  30. package/dist/dynamics.js +130 -0
  31. package/dist/envelope.d.ts +34 -0
  32. package/dist/envelope.js +62 -0
  33. package/dist/filter.d.ts +9 -0
  34. package/dist/filter.js +34 -0
  35. package/dist/filterbank-vocoder.d.ts +35 -0
  36. package/dist/filterbank-vocoder.js +52 -0
  37. package/dist/formant-bank.d.ts +15 -0
  38. package/dist/formant-bank.js +28 -0
  39. package/dist/freeze-reverb.d.ts +35 -0
  40. package/dist/freeze-reverb.js +61 -0
  41. package/dist/frequency-shifter.d.ts +24 -0
  42. package/dist/frequency-shifter.js +57 -0
  43. package/dist/gate.d.ts +2 -0
  44. package/dist/gate.js +12 -0
  45. package/dist/index.d.ts +7 -0
  46. package/dist/index.js +12 -0
  47. package/dist/instrument-example.d.ts +12 -0
  48. package/dist/instrument-example.js +29 -0
  49. package/dist/instrument-settings.d.ts +95 -0
  50. package/dist/instrument-settings.js +36 -0
  51. package/dist/instrument.d.ts +42 -0
  52. package/dist/instrument.js +166 -0
  53. package/dist/lfo.d.ts +19 -0
  54. package/dist/lfo.js +55 -0
  55. package/dist/live-buffer.d.ts +39 -0
  56. package/dist/live-buffer.js +52 -0
  57. package/dist/live-granular.d.ts +41 -0
  58. package/dist/live-granular.js +64 -0
  59. package/dist/lookahead-limiter.d.ts +31 -0
  60. package/dist/lookahead-limiter.js +67 -0
  61. package/dist/loop-crossfade.d.ts +28 -0
  62. package/dist/loop-crossfade.js +72 -0
  63. package/dist/modulation-fx.d.ts +47 -0
  64. package/dist/modulation-fx.js +58 -0
  65. package/dist/modulation.d.ts +132 -0
  66. package/dist/modulation.js +228 -0
  67. package/dist/mpe-expression.d.ts +36 -0
  68. package/dist/mpe-expression.js +73 -0
  69. package/dist/multiband-dynamics.d.ts +50 -0
  70. package/dist/multiband-dynamics.js +60 -0
  71. package/dist/musical-controls.d.ts +76 -0
  72. package/dist/musical-controls.js +125 -0
  73. package/dist/musical-examples.d.ts +21 -0
  74. package/dist/musical-examples.js +142 -0
  75. package/dist/musical-materials.d.ts +110 -0
  76. package/dist/musical-materials.js +56 -0
  77. package/dist/oscillator.d.ts +10 -0
  78. package/dist/oscillator.js +35 -0
  79. package/dist/oversampled-drive.d.ts +19 -0
  80. package/dist/oversampled-drive.js +99 -0
  81. package/dist/performance.d.ts +61 -0
  82. package/dist/performance.js +241 -0
  83. package/dist/pitch-quantizer.d.ts +26 -0
  84. package/dist/pitch-quantizer.js +88 -0
  85. package/dist/prepared-convolution.d.ts +26 -0
  86. package/dist/prepared-convolution.js +104 -0
  87. package/dist/resident-recorder.d.ts +28 -0
  88. package/dist/resident-recorder.js +68 -0
  89. package/dist/resident-time-stretch.d.ts +46 -0
  90. package/dist/resident-time-stretch.js +136 -0
  91. package/dist/resonator.d.ts +32 -0
  92. package/dist/resonator.js +63 -0
  93. package/dist/reverb.d.ts +27 -0
  94. package/dist/reverb.js +52 -0
  95. package/dist/sample.d.ts +113 -0
  96. package/dist/sample.js +212 -0
  97. package/dist/source.d.ts +58 -0
  98. package/dist/source.js +113 -0
  99. package/dist/spatial-chains.d.ts +50 -0
  100. package/dist/spatial-chains.js +76 -0
  101. package/dist/spectral-fft.d.ts +27 -0
  102. package/dist/spectral-fft.js +84 -0
  103. package/dist/spectral-freeze.d.ts +24 -0
  104. package/dist/spectral-freeze.js +74 -0
  105. package/dist/spectral-gate.d.ts +23 -0
  106. package/dist/spectral-gate.js +58 -0
  107. package/dist/spectral-stft.d.ts +14 -0
  108. package/dist/spectral-stft.js +70 -0
  109. package/dist/spectral-texture.d.ts +46 -0
  110. package/dist/spectral-texture.js +141 -0
  111. package/dist/spectral.d.ts +18 -0
  112. package/dist/spectral.js +10 -0
  113. package/dist/state-variable-filter.d.ts +17 -0
  114. package/dist/state-variable-filter.js +25 -0
  115. package/dist/stereo-delay.d.ts +45 -0
  116. package/dist/stereo-delay.js +70 -0
  117. package/dist/virtual-analog.d.ts +26 -0
  118. package/dist/virtual-analog.js +66 -0
  119. package/dist/voice-policy.d.ts +37 -0
  120. package/dist/voice-policy.js +245 -0
  121. package/dist/wavetable-bands.d.ts +37 -0
  122. package/dist/wavetable-bands.js +145 -0
  123. package/dist/wavetable-read.d.ts +6 -0
  124. package/dist/wavetable-read.js +11 -0
  125. package/dist/wavetable.d.ts +29 -0
  126. package/dist/wavetable.js +49 -0
  127. package/dist/windowed-pitch-shift.d.ts +34 -0
  128. package/dist/windowed-pitch-shift.js +51 -0
  129. package/docs/catalog-audition.md +76 -0
  130. package/docs/catalog-filters.md +125 -0
  131. package/docs/catalog-modulation-fx.md +220 -0
  132. package/docs/catalog-status.md +433 -0
  133. package/docs/character-filter.md +139 -0
  134. package/docs/contracts.md +141 -0
  135. package/docs/control-modulation.md +194 -0
  136. package/docs/convolution.md +50 -0
  137. package/docs/curve-shaper.md +117 -0
  138. package/docs/delay-fx-capture-findings.json +134 -0
  139. package/docs/delay-fx.md +202 -0
  140. package/docs/delay-readhead.md +121 -0
  141. package/docs/delay-settings-candidate.json +333 -0
  142. package/docs/delay-settings.md +111 -0
  143. package/docs/dependency-findings.md +58 -0
  144. package/docs/deployment-status.md +37 -0
  145. package/docs/drive.md +152 -0
  146. package/docs/dual-head-delay.md +131 -0
  147. package/docs/dynamics.md +180 -0
  148. package/docs/envelope-integer-staging.md +64 -0
  149. package/docs/filter-materialization-results.json +71 -0
  150. package/docs/filter-materialization.md +135 -0
  151. package/docs/filter-oscillator.md +126 -0
  152. package/docs/filterbank-vocoder-entry.md +58 -0
  153. package/docs/freeze-reverb.md +179 -0
  154. package/docs/frequency-shifter.md +133 -0
  155. package/docs/frontend-audition.md +22 -0
  156. package/docs/gain-schedule-verification.md +53 -0
  157. package/docs/initial-acceptance.md +79 -0
  158. package/docs/instrument-performance.md +191 -0
  159. package/docs/instrument-settings.md +130 -0
  160. package/docs/instrument.md +204 -0
  161. package/docs/integration-candidate.md +114 -0
  162. package/docs/live-buffer.md +163 -0
  163. package/docs/live-granular.md +179 -0
  164. package/docs/lookahead-multiband.md +183 -0
  165. package/docs/loop-crossfade.md +99 -0
  166. package/docs/mpe-expression.md +65 -0
  167. package/docs/musical-clock-seek-boundary.md +31 -0
  168. package/docs/musical-controls-contract.md +144 -0
  169. package/docs/musical-examples.md +255 -0
  170. package/docs/oversampled-drive.md +153 -0
  171. package/docs/performance.md +53 -0
  172. package/docs/pitch-quantizer.md +55 -0
  173. package/docs/prepared-convolution.md +197 -0
  174. package/docs/realtime-audition.md +63 -0
  175. package/docs/resident-recorder.md +151 -0
  176. package/docs/resident-time-stretch.md +196 -0
  177. package/docs/sample.md +191 -0
  178. package/docs/sound-audition-headroom.md +103 -0
  179. package/docs/sources.md +81 -0
  180. package/docs/spatial-chains-entry.md +251 -0
  181. package/docs/spectral-freeze-entry.md +132 -0
  182. package/docs/spectral-gate-entry.md +134 -0
  183. package/docs/spectral-large-candidate.md +81 -0
  184. package/docs/spectral-texture-entry.md +178 -0
  185. package/docs/spectral.md +127 -0
  186. package/docs/virtual-analog.md +77 -0
  187. package/docs/voice-policy.md +38 -0
  188. package/docs/wavetable-bands.md +138 -0
  189. package/docs/wavetable.md +101 -0
  190. package/docs/windowed-pitch-shift.md +112 -0
  191. package/package.json +269 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,63 @@
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.2.0 — 2026-11-12
9
+
10
+ - **Breaking:** requires `@unworklet/core` **0.6.0**. Update the compiler, offline
11
+ renderer, Vite plugin and test helpers to 0.6.0 together. Node 24 is unchanged.
12
+ - **Breaking:** pass `ctx.renderQuantumSize` to spectral framing, convolution,
13
+ spatial-chain and resident time-stretch construction configs. Their dispatch
14
+ periods now preserve saved hop phase at the actual quantum boundary. Rebuild
15
+ processors for the target context; old or cross-target snapshots are not a
16
+ supported migration path.
17
+ - FFT and spectral work-buffer loops use `forIndex` instead of assuming that an
18
+ audio loop always runs 128 samples. Transform and partition sizes retain their
19
+ existing sample-based meaning.
20
+ - The playground uses the actual AudioContext sample rate and render quantum
21
+ (128 on browsers without `renderQuantumSize`) for worker compilation, metadata
22
+ and schema identity. It no longer forces or requires 48 kHz.
23
+ - The spectral-freeze example waits for input before filling its capture history,
24
+ so delayed source setup cannot freeze an empty startup buffer.
25
+ - Add multi-rate and multi-quantum spectral regression coverage, including
26
+ continuation after snapshots at non-128 boundaries. Dependency regression
27
+ checks now exercise the upstream fixes included in 0.6.0.
28
+ - Audio remains CANDIDATE. This compatibility update does not grant human
29
+ listening approval or clear the existing real-time capacity limitations.
30
+
31
+ ### Migrating construction configs
32
+
33
+ Add `renderQuantumSize: ctx.renderQuantumSize` inside the `defineProcessor(ctx =>
34
+ ...)` callback when constructing `stftIdentity`, `spectralGate`, `spectralFreeze`,
35
+ `spectralBlur`, `spectralCrossSynthesis`, `partitionedConvolution`,
36
+ `preparedConvolution`, `residentTimeStretch`, `hybridReverb` or
37
+ `feedforwardPitchedReverb`. For example:
38
+
39
+ ```ts
40
+ // Inside the existing defineProcessor(ctx => { ... }) callback:
41
+ const stft = instantiate(stftIdentity, {
42
+ size: 256, hopSize: 128, renderQuantumSize: ctx.renderQuantumSize,
43
+ }, { name: 'stft' });
44
+ ```
45
+
46
+ Host-side `prepareConvolutionSpectrum` and its `PreparedConvolutionConfig` keep
47
+ their existing shape; the DSP constructor uses `PreparedConvolutionRuntimeConfig`.
48
+ Frame lengths, partition lengths, latency in samples and control sampling times
49
+ retain their meaning. Native scheduler counters are not snapshot state, so
50
+ dispatch uses a divisor of both hop and quantum; smaller or non-dividing quanta
51
+ can perform more FFT/search work. This is functional support, not a new
52
+ real-time performance guarantee.
53
+
54
+ ## 0.1.0 — 2026-10-09
55
+
56
+ - First public npm release of `@denaudio/den`, with 54 ESM module entry points,
57
+ TypeScript declarations, public DSP documentation and MIT OR Apache-2.0 licensing.
58
+ - Requires the tested `@unworklet/core` peer dependency at `0.4.1`.
59
+ - Add release-PR automation, npm trusted publishing, package-boundary checks and
60
+ version preparation for the package and its locked consumers.
61
+ - The initial DSP catalog remains CANDIDATE. See
62
+ [catalog status](docs/catalog-status.md) and
63
+ [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,108 @@
1
- # Temporary Holding Version
1
+ # den
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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/main/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.6.0** 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
+ Compilation follows the AudioContext's sample rate and render quantum. Spectral
70
+ framing, both convolution modules, spatial chains and resident time stretch
71
+ require the processor's `ctx.renderQuantumSize` in their construction config so
72
+ snapshot restoration preserves hop timing even at short quantum boundaries. See the
73
+ [0.2.0 migration notes](CHANGELOG.md#020--2026-11-12).
74
+ Snapshots require the same processor/schema/sample rate/render quantum. See the
75
+ [instrument contract](docs/instrument.md), [sound settings](docs/instrument-settings.md),
76
+ [Delay FX contract](docs/delay-fx.md), [effect settings](docs/delay-settings.md),
77
+ [shared contracts](docs/contracts.md), and [dependency limitations](docs/dependency-findings.md).
78
+
79
+ ## Extended catalog candidates
80
+
81
+ The [catalog coverage record](docs/catalog-status.md) lists additive clean filter/EQ,
82
+ formant/crossover, dynamics, drive/reduction, modulation/reverb, source/resonator
83
+ control/sequence/arpeggiator, sample/granular, wavetable/VA, sustain/expression
84
+ bounded spectral/convolution, character/frequency-shift, limiter/multiband,
85
+ editable-curve, fixed oversampling, dual-head delay, windowed pitch-shift,
86
+ manual lower-zone expression, framewise spectral gate, prepared convolution,
87
+ 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,
88
+ with their public imports, independent tests and remaining work. These modules
89
+ have separate acceptance evidence; the initial five sounds' feedback does not
90
+ approve new audio automatically.
91
+
92
+ ## Evidence and scope
93
+
94
+ The [integration notes](docs/integration-candidate.md) describe lifecycle and
95
+ 4×3 sound/FX coverage; [headroom evidence](docs/sound-audition-headroom.md) records
96
+ the bounded fixed-input measurements. [Deployment](docs/deployment-status.md)
97
+ uses the same packed consumers as the tests. Candidate audio has independent
98
+ numerical assertions and source/settings/input/audio/static-waveform manifests.
99
+ Golden promotion requires human approval tied to exact source/audio hashes in
100
+ a separate change. CI success does not supply that approval.
101
+
102
+ This is a fresh TS/unworklet implementation. The retired Rust/WASM contents are
103
+ preserved only in Git history. MIT/Apache-2.0 notices and attribution remain.
104
+ Development snapshots may use version `0.0.0`. Releases use reviewed
105
+ `release/vX.Y.Z` pull requests and npm trusted publishing; see the
106
+ [release guide](https://github.com/yuichkun/den/blob/main/RELEASE.md) and
107
+ [changelog](CHANGELOG.md). Before 1.0, breaking changes increment the minor
108
+ 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;