@libraz/libsonare 1.7.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/NOTICE +178 -0
  2. package/README.md +26 -203
  3. package/dist/_chain_config.d.ts +14 -0
  4. package/dist/_chain_config.d.ts.map +1 -0
  5. package/dist/_effects_common.d.ts +7 -0
  6. package/dist/_effects_common.d.ts.map +1 -0
  7. package/dist/_feature_validation.d.ts +8 -0
  8. package/dist/_feature_validation.d.ts.map +1 -0
  9. package/dist/_fft_options.d.ts +24 -0
  10. package/dist/_fft_options.d.ts.map +1 -0
  11. package/dist/align_take.d.ts +50 -0
  12. package/dist/align_take.d.ts.map +1 -0
  13. package/dist/analysis.d.ts +29 -5840
  14. package/dist/analysis.d.ts.map +1 -0
  15. package/dist/analysis.js +874 -722
  16. package/dist/analysis.js.map +1 -1
  17. package/dist/analysis_helpers.d.ts +9 -0
  18. package/dist/analysis_helpers.d.ts.map +1 -0
  19. package/dist/audio.d.ts +163 -0
  20. package/dist/audio.d.ts.map +1 -0
  21. package/dist/clip_page_streamer.d.ts +133 -0
  22. package/dist/clip_page_streamer.d.ts.map +1 -0
  23. package/dist/codes.d.ts +44 -0
  24. package/dist/codes.d.ts.map +1 -0
  25. package/dist/effects_mastering.d.ts +23 -0
  26. package/dist/effects_mastering.d.ts.map +1 -0
  27. package/dist/effects_note_ops.d.ts +502 -0
  28. package/dist/effects_note_ops.d.ts.map +1 -0
  29. package/dist/effects_percussive.d.ts +185 -0
  30. package/dist/effects_percussive.d.ts.map +1 -0
  31. package/dist/effects_separation.d.ts +65 -0
  32. package/dist/effects_separation.d.ts.map +1 -0
  33. package/dist/effects_spectral.d.ts +28 -0
  34. package/dist/effects_spectral.d.ts.map +1 -0
  35. package/dist/effects_timepitch.d.ts +134 -0
  36. package/dist/effects_timepitch.d.ts.map +1 -0
  37. package/dist/effects_voice_change.d.ts +53 -0
  38. package/dist/effects_voice_change.d.ts.map +1 -0
  39. package/dist/errors.d.ts +51 -0
  40. package/dist/errors.d.ts.map +1 -0
  41. package/dist/feature_core.d.ts +341 -0
  42. package/dist/feature_core.d.ts.map +1 -0
  43. package/dist/feature_decompose.d.ts +278 -0
  44. package/dist/feature_decompose.d.ts.map +1 -0
  45. package/dist/feature_inverse.d.ts +128 -0
  46. package/dist/feature_inverse.d.ts.map +1 -0
  47. package/dist/feature_loudness.d.ts +66 -0
  48. package/dist/feature_loudness.d.ts.map +1 -0
  49. package/dist/feature_music.d.ts +307 -0
  50. package/dist/feature_music.d.ts.map +1 -0
  51. package/dist/feature_pitch.d.ts +108 -0
  52. package/dist/feature_pitch.d.ts.map +1 -0
  53. package/dist/feature_resample.d.ts +16 -0
  54. package/dist/feature_resample.d.ts.map +1 -0
  55. package/dist/feature_spectral.d.ts +137 -0
  56. package/dist/feature_spectral.d.ts.map +1 -0
  57. package/dist/feature_spectrogram.d.ts +198 -0
  58. package/dist/feature_spectrogram.d.ts.map +1 -0
  59. package/dist/features.d.ts +10 -0
  60. package/dist/features.d.ts.map +1 -0
  61. package/dist/hrtf/default.shrf +0 -0
  62. package/dist/index.d.ts +74 -7431
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +4173 -1621
  65. package/dist/index.js.map +1 -1
  66. package/dist/instrument_types.d.ts +517 -0
  67. package/dist/instrument_types.d.ts.map +1 -0
  68. package/dist/live_audio.d.ts +35 -0
  69. package/dist/live_audio.d.ts.map +1 -0
  70. package/dist/mastering_chain.d.ts +213 -0
  71. package/dist/mastering_chain.d.ts.map +1 -0
  72. package/dist/mastering_core.d.ts +483 -0
  73. package/dist/mastering_core.d.ts.map +1 -0
  74. package/dist/mastering_dynamics.d.ts +80 -0
  75. package/dist/mastering_dynamics.d.ts.map +1 -0
  76. package/dist/metering.d.ts +287 -0
  77. package/dist/metering.d.ts.map +1 -0
  78. package/dist/mixer.d.ts +464 -0
  79. package/dist/mixer.d.ts.map +1 -0
  80. package/dist/mixing_assistant.d.ts +62 -0
  81. package/dist/mixing_assistant.d.ts.map +1 -0
  82. package/dist/mixing_oneshot.d.ts +40 -0
  83. package/dist/mixing_oneshot.d.ts.map +1 -0
  84. package/dist/module_state.d.ts +15 -0
  85. package/dist/module_state.d.ts.map +1 -0
  86. package/dist/opfs_clip_pages.d.ts +28 -0
  87. package/dist/opfs_clip_pages.d.ts.map +1 -0
  88. package/dist/playback_renderer.d.ts +128 -0
  89. package/dist/playback_renderer.d.ts.map +1 -0
  90. package/dist/polyphony.d.ts +202 -0
  91. package/dist/polyphony.d.ts.map +1 -0
  92. package/dist/project.d.ts +8 -0
  93. package/dist/project.d.ts.map +1 -0
  94. package/dist/project_class.d.ts +562 -0
  95. package/dist/project_class.d.ts.map +1 -0
  96. package/dist/project_internal.d.ts +194 -0
  97. package/dist/project_internal.d.ts.map +1 -0
  98. package/dist/project_synth.d.ts +74 -0
  99. package/dist/project_synth.d.ts.map +1 -0
  100. package/dist/project_types.d.ts +654 -0
  101. package/dist/project_types.d.ts.map +1 -0
  102. package/dist/public_types.d.ts +185 -0
  103. package/dist/public_types.d.ts.map +1 -0
  104. package/dist/public_types_acoustic.d.ts +215 -0
  105. package/dist/public_types_acoustic.d.ts.map +1 -0
  106. package/dist/public_types_mastering.d.ts +528 -0
  107. package/dist/public_types_mastering.d.ts.map +1 -0
  108. package/dist/public_types_mixing.d.ts +436 -0
  109. package/dist/public_types_mixing.d.ts.map +1 -0
  110. package/dist/public_types_music.d.ts +619 -0
  111. package/dist/public_types_music.d.ts.map +1 -0
  112. package/dist/public_types_playback.d.ts +165 -0
  113. package/dist/public_types_playback.d.ts.map +1 -0
  114. package/dist/public_types_realtime.d.ts +174 -0
  115. package/dist/public_types_realtime.d.ts.map +1 -0
  116. package/dist/public_types_repair.d.ts +424 -0
  117. package/dist/public_types_repair.d.ts.map +1 -0
  118. package/dist/public_types_spectral.d.ts +697 -0
  119. package/dist/public_types_spectral.d.ts.map +1 -0
  120. package/dist/quick_analysis.d.ts +445 -0
  121. package/dist/quick_analysis.d.ts.map +1 -0
  122. package/dist/realtime_engine.d.ts +893 -0
  123. package/dist/realtime_engine.d.ts.map +1 -0
  124. package/dist/realtime_voice_changer.d.ts +158 -0
  125. package/dist/realtime_voice_changer.d.ts.map +1 -0
  126. package/dist/repair_dereverb.d.ts +187 -0
  127. package/dist/repair_dereverb.d.ts.map +1 -0
  128. package/dist/repair_impulsive.d.ts +186 -0
  129. package/dist/repair_impulsive.d.ts.map +1 -0
  130. package/dist/repair_noise.d.ts +239 -0
  131. package/dist/repair_noise.d.ts.map +1 -0
  132. package/dist/repair_trim.d.ts +123 -0
  133. package/dist/repair_trim.d.ts.map +1 -0
  134. package/dist/sample_bank.d.ts +84 -0
  135. package/dist/sample_bank.d.ts.map +1 -0
  136. package/dist/scale.d.ts +10 -0
  137. package/dist/scale.d.ts.map +1 -0
  138. package/dist/schemas/mixer-scene.schema.json +393 -0
  139. package/dist/schemas/playback-renderer-config.schema.json +392 -0
  140. package/dist/sonare-analysis.d.ts +8 -0
  141. package/dist/sonare-analysis.js +2 -2
  142. package/dist/sonare-analysis.wasm +0 -0
  143. package/dist/sonare.d.ts +3945 -0
  144. package/dist/sonare.js +2 -2
  145. package/dist/sonare.wasm +0 -0
  146. package/dist/stream_analyzer.d.ts +163 -0
  147. package/dist/stream_analyzer.d.ts.map +1 -0
  148. package/dist/stream_types.d.ts +214 -0
  149. package/dist/stream_types.d.ts.map +1 -0
  150. package/dist/streaming_mixing.d.ts +6 -0
  151. package/dist/streaming_mixing.d.ts.map +1 -0
  152. package/dist/streaming_processors.d.ts +340 -0
  153. package/dist/streaming_processors.d.ts.map +1 -0
  154. package/dist/transcribe.d.ts +77 -0
  155. package/dist/transcribe.d.ts.map +1 -0
  156. package/dist/validation.d.ts +140 -0
  157. package/dist/validation.d.ts.map +1 -0
  158. package/dist/web_midi.d.ts +77 -0
  159. package/dist/web_midi.d.ts.map +1 -0
  160. package/dist/worker.d.ts +5 -48
  161. package/dist/worker.d.ts.map +1 -0
  162. package/dist/worker.js +94 -41
  163. package/dist/worker.js.map +1 -1
  164. package/dist/worker_client.d.ts +96 -0
  165. package/dist/worker_client.d.ts.map +1 -0
  166. package/dist/worker_protocol.d.ts +43 -0
  167. package/dist/worker_protocol.d.ts.map +1 -0
  168. package/dist/worklet/audio_types.d.ts +21 -0
  169. package/dist/worklet/audio_types.d.ts.map +1 -0
  170. package/dist/worklet/engine-automation.d.ts +29 -0
  171. package/dist/worklet/engine-automation.d.ts.map +1 -0
  172. package/dist/worklet/engine-capture-facade.d.ts +35 -0
  173. package/dist/worklet/engine-capture-facade.d.ts.map +1 -0
  174. package/dist/worklet/engine-clips.d.ts +23 -0
  175. package/dist/worklet/engine-clips.d.ts.map +1 -0
  176. package/dist/worklet/engine-markers.d.ts +40 -0
  177. package/dist/worklet/engine-markers.d.ts.map +1 -0
  178. package/dist/worklet/engine-mixer-facade.d.ts +164 -0
  179. package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
  180. package/dist/worklet/engine-node.d.ts +83 -0
  181. package/dist/worklet/engine-node.d.ts.map +1 -0
  182. package/dist/worklet/engine-offline.d.ts +81 -0
  183. package/dist/worklet/engine-offline.d.ts.map +1 -0
  184. package/dist/worklet/engine-options.d.ts +12 -0
  185. package/dist/worklet/engine-options.d.ts.map +1 -0
  186. package/dist/worklet/engine-parameter-facade.d.ts +106 -0
  187. package/dist/worklet/engine-parameter-facade.d.ts.map +1 -0
  188. package/dist/worklet/engine-processor.d.ts +72 -0
  189. package/dist/worklet/engine-processor.d.ts.map +1 -0
  190. package/dist/worklet/engine-register.d.ts +2 -0
  191. package/dist/worklet/engine-register.d.ts.map +1 -0
  192. package/dist/worklet/engine-strips.d.ts +75 -0
  193. package/dist/worklet/engine-strips.d.ts.map +1 -0
  194. package/dist/worklet/engine-sync.d.ts +39 -0
  195. package/dist/worklet/engine-sync.d.ts.map +1 -0
  196. package/dist/worklet/engine-tempo-facade.d.ts +48 -0
  197. package/dist/worklet/engine-tempo-facade.d.ts.map +1 -0
  198. package/dist/worklet/engine.d.ts +418 -0
  199. package/dist/worklet/engine.d.ts.map +1 -0
  200. package/dist/worklet/guards.d.ts +53 -0
  201. package/dist/worklet/guards.d.ts.map +1 -0
  202. package/dist/worklet/messages.d.ts +710 -0
  203. package/dist/worklet/messages.d.ts.map +1 -0
  204. package/dist/worklet/mixer-processor.d.ts +46 -0
  205. package/dist/worklet/mixer-processor.d.ts.map +1 -0
  206. package/dist/worklet/playback-processor.d.ts +62 -0
  207. package/dist/worklet/playback-processor.d.ts.map +1 -0
  208. package/dist/worklet/protocol.d.ts +331 -0
  209. package/dist/worklet/protocol.d.ts.map +1 -0
  210. package/dist/worklet/voice-changer-processor.d.ts +41 -0
  211. package/dist/worklet/voice-changer-processor.d.ts.map +1 -0
  212. package/dist/worklet.d.ts +16 -2515
  213. package/dist/worklet.d.ts.map +1 -0
  214. package/dist/worklet.js +3200 -541
  215. package/dist/worklet.js.map +1 -1
  216. package/package.json +23 -12
  217. package/src/_effects_common.ts +47 -0
  218. package/src/_feature_validation.ts +34 -0
  219. package/src/_fft_options.ts +39 -0
  220. package/src/align_take.ts +64 -0
  221. package/src/analysis.ts +56 -3
  222. package/src/analysis_helpers.ts +7 -0
  223. package/src/audio.ts +106 -3
  224. package/src/codes.ts +39 -2
  225. package/src/effects_mastering.ts +101 -22
  226. package/src/effects_note_ops.ts +683 -0
  227. package/src/effects_percussive.ts +217 -0
  228. package/src/effects_separation.ts +150 -0
  229. package/src/effects_spectral.ts +60 -0
  230. package/src/effects_timepitch.ts +388 -0
  231. package/src/errors.ts +23 -1
  232. package/src/feature_core.ts +127 -2
  233. package/src/feature_decompose.ts +633 -0
  234. package/src/feature_inverse.ts +454 -0
  235. package/src/feature_loudness.ts +125 -0
  236. package/src/feature_music.ts +107 -14
  237. package/src/feature_pitch.ts +96 -1
  238. package/src/feature_spectral.ts +16 -611
  239. package/src/feature_spectrogram.ts +63 -450
  240. package/src/features.ts +36 -22
  241. package/src/index.ts +288 -30
  242. package/src/instrument_types.ts +645 -0
  243. package/src/live_audio.ts +27 -1
  244. package/src/mastering_chain.ts +184 -0
  245. package/src/mastering_core.ts +441 -32
  246. package/src/mastering_dynamics.ts +22 -11
  247. package/src/metering.ts +67 -24
  248. package/src/mixer.ts +251 -22
  249. package/src/mixing_assistant.ts +138 -0
  250. package/src/mixing_oneshot.ts +10 -5
  251. package/src/module_state.ts +24 -2
  252. package/src/playback_renderer.ts +252 -0
  253. package/src/polyphony.ts +279 -0
  254. package/src/project.ts +61 -24
  255. package/src/project_class.ts +450 -27
  256. package/src/project_internal.ts +149 -42
  257. package/src/project_synth.ts +67 -1
  258. package/src/project_types.ts +271 -271
  259. package/src/public_types.ts +122 -3
  260. package/src/public_types_acoustic.ts +112 -3
  261. package/src/public_types_mastering.ts +275 -73
  262. package/src/public_types_mixing.ts +363 -1
  263. package/src/public_types_music.ts +312 -2
  264. package/src/public_types_playback.ts +196 -0
  265. package/src/public_types_realtime.ts +39 -7
  266. package/src/public_types_repair.ts +446 -0
  267. package/src/public_types_spectral.ts +491 -5
  268. package/src/quick_analysis.ts +203 -26
  269. package/src/realtime_engine.ts +773 -34
  270. package/src/realtime_voice_changer.ts +55 -1
  271. package/src/repair_dereverb.ts +299 -0
  272. package/src/repair_impulsive.ts +395 -0
  273. package/src/repair_noise.ts +425 -0
  274. package/src/repair_trim.ts +226 -0
  275. package/src/sample_bank.ts +113 -0
  276. package/src/sonare.js.d.ts +1158 -30
  277. package/src/stream_analyzer.ts +36 -4
  278. package/src/stream_types.ts +37 -0
  279. package/src/streaming_mixing.ts +1 -1
  280. package/src/streaming_processors.ts +202 -10
  281. package/src/transcribe.ts +89 -0
  282. package/src/validation.ts +285 -11
  283. package/src/web_midi.ts +1 -6
  284. package/src/worker.ts +18 -2
  285. package/src/worklet/audio_types.ts +37 -0
  286. package/src/worklet/engine-mixer-facade.ts +800 -32
  287. package/src/worklet/engine-node.ts +99 -29
  288. package/src/worklet/engine-offline.ts +14 -8
  289. package/src/worklet/engine-parameter-facade.ts +21 -0
  290. package/src/worklet/engine-processor.ts +332 -93
  291. package/src/worklet/engine-register.ts +32 -18
  292. package/src/worklet/engine-strips.ts +275 -9
  293. package/src/worklet/engine-sync.ts +20 -7
  294. package/src/worklet/engine.ts +394 -48
  295. package/src/worklet/guards.ts +195 -44
  296. package/src/worklet/messages.ts +229 -2
  297. package/src/worklet/mixer-processor.ts +117 -48
  298. package/src/worklet/playback-processor.ts +300 -0
  299. package/src/worklet/protocol.ts +82 -11
  300. package/src/worklet/voice-changer-processor.ts +17 -11
  301. package/src/worklet.ts +17 -0
  302. package/src/effects_transform.ts +0 -718
  303. package/src/mastering_repair.ts +0 -273
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Percussive event editing: locating struck sounds in audio and rendering an
3
+ * edited set of them back.
4
+ */
5
+ import type { PercussiveEvent, PercussiveEventInput } from './public_types';
6
+ import type { ValidateOptions } from './validation';
7
+ /**
8
+ * The separation a percussive event's signal is lifted out with. Extraction
9
+ * measures events against it and rendering has to repeat it, so both calls take
10
+ * the same four fields and a render must be given what the extraction was.
11
+ */
12
+ export interface PercussiveSeparationOptions {
13
+ /**
14
+ * FFT size and hop the separation and the onset detector share. They cannot be
15
+ * set apart: an event measured on one framing and lifted out on another is not
16
+ * the same signal. Default 2048 and 512. The pair must overlap-add — `nFft`
17
+ * even and at least 2, `hopLength` no more than half of it — because the
18
+ * separation inverts an STFT. A negative value is rejected on its own, before
19
+ * the zero-is-default rule could swallow it.
20
+ */
21
+ nFft?: number;
22
+ /** Hop length in samples. Default 512. */
23
+ hopLength?: number;
24
+ /**
25
+ * Median filter lengths the separation runs, along time and along frequency. A
26
+ * longer harmonic kernel calls more of a sustained sound harmonic. Default 31;
27
+ * any other value must be odd and positive, so an even one is rejected rather
28
+ * than rounded. 1 is legal and degenerate rather than an error: a length-1
29
+ * median is the identity, so both components come back as the source.
30
+ */
31
+ hpssKernelHarmonic?: number;
32
+ /** Vertical median filter length, under the same rule. Default 31. */
33
+ hpssKernelPercussive?: number;
34
+ }
35
+ /** Canonical request form for {@link extractPercussiveEvents}. */
36
+ export interface ExtractPercussiveEventsRequest extends PercussiveSeparationOptions, ValidateOptions {
37
+ samples: Float32Array | readonly number[];
38
+ /**
39
+ * Sample rate in Hz. Required: `maxEventMs` is converted to samples with this
40
+ * rate, so a wrong/omitted value caps the spans differently.
41
+ */
42
+ sampleRate: number;
43
+ /**
44
+ * Minimum frames between consecutive onsets. Default 1, and a whole number:
45
+ * 0 is how the default is spelled, so a fractional wait is refused rather
46
+ * than truncated onto it. Negative is rejected.
47
+ */
48
+ onsetWait?: number;
49
+ /**
50
+ * Offset added to the detector's adaptive threshold; raising it finds fewer,
51
+ * stronger hits and lowering it finds more. Default 0.06, so exactly zero is
52
+ * the one value not selectable here — a negative one is accepted and puts the
53
+ * threshold below the default, which is the direction a caller reaching for
54
+ * zero wanted anyway.
55
+ */
56
+ onsetDelta?: number;
57
+ /**
58
+ * Caps a span that no onset follows. It binds at the end of a phrase and at the
59
+ * end of the track; anywhere else the next onset closes the span first. Default
60
+ * 500 ms.
61
+ */
62
+ maxEventMs?: number;
63
+ /**
64
+ * Drops an event whose `percussiveRatio` falls below this; must be in `[0, 1]`.
65
+ * 0 is both the default and the meaningful "keep everything". Raising it is
66
+ * useful on material that is mostly drums and wrong on a dense mix, where it
67
+ * also drops real hits sitting over a loud sustain.
68
+ */
69
+ minPercussiveRatio?: number;
70
+ }
71
+ /** Canonical request form for {@link renderPercussiveEvents}. */
72
+ export interface RenderPercussiveEventsRequest extends PercussiveSeparationOptions, ValidateOptions {
73
+ samples: Float32Array | readonly number[];
74
+ /**
75
+ * Sample rate in Hz. Required: `fadeMs` is converted to samples with this rate,
76
+ * so a wrong/omitted value changes the fade length.
77
+ */
78
+ sampleRate: number;
79
+ /** The events to render, with their edits. Source spans must not overlap. */
80
+ events: readonly PercussiveEventInput[];
81
+ /**
82
+ * Fade-out at the tail of each lifted span. Default 5 ms, so a zero-length
83
+ * fade is unreachable here rather than rejected — and a hard cut is not a thing
84
+ * to want anyway, because what the fade shapes is the signal being subtracted,
85
+ * so squaring it off leaves a step. There is deliberately
86
+ * no matching fade-in: a span opens in front of its transient, where the
87
+ * percussive component is near-silent, so cutting square there costs nothing
88
+ * and keeps a muted hit's attack from surviving inside a fade.
89
+ */
90
+ fadeMs?: number;
91
+ }
92
+ /**
93
+ * Extract editable percussive events from audio alone.
94
+ *
95
+ * Each event is a struck sound located in time: a span in source samples, its
96
+ * detector strength, the percussive peak over the span, the share of the span's
97
+ * energy the separation called percussive, and an identity
98
+ * {@link PercussiveEventEdit}. Edit the events and hand them to
99
+ * {@link renderPercussiveEvents} to apply the result — the source audio is never
100
+ * mutated, and a set whose edits are all identity renders back to the input bit
101
+ * for bit.
102
+ *
103
+ * Onsets are detected on the percussive component rather than on the source, so
104
+ * a harmonic attack is attenuated before the detector sees it instead of being
105
+ * filtered out afterwards. Each onset opens a span that the next one closes,
106
+ * capped by `maxEventMs` and never running past the end of the audio.
107
+ *
108
+ * Each onset is backtracked to the transient's start, which is not optional and
109
+ * is why there is no knob for it: peak-picking lands after the attack, and a span
110
+ * that opened there would report the next hit's peak and leave its own attack
111
+ * behind when muted.
112
+ *
113
+ * An event carries no pitch and is never associated with a {@link NoteObject} —
114
+ * a struck sound has no steady F0 to edit, so the two models are extracted by
115
+ * separate calls.
116
+ *
117
+ * @param request - Audio, its sample rate, and the separation, peak-picking and
118
+ * span options
119
+ * @returns One {@link PercussiveEvent} per detected hit, in time order; an empty
120
+ * array when nothing was detected
121
+ * @throws RangeError when the samples or sample rate fail the shared input checks
122
+ * @throws SonareError (`InvalidParameter`) on a kernel size that is not an
123
+ * integer within the 32-bit range, a framing size that is negative or outside
124
+ * that range, a framing that breaks constant overlap-add, an `onsetWait` that
125
+ * is fractional, negative or non-finite, a negative or non-finite `onsetDelta`
126
+ * / `maxEventMs`, or a `minPercussiveRatio` outside `[0, 1]`
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const events = extractPercussiveEvents({ samples, sampleRate });
131
+ * // Drop the second hit and push the third 10 ms late.
132
+ * events[1].edit.muted = true;
133
+ * events[2].edit.timeOffsetSamples = Math.round(0.01 * sampleRate);
134
+ * const edited = renderPercussiveEvents({ samples, sampleRate, events });
135
+ * ```
136
+ */
137
+ export declare function extractPercussiveEvents(request: ExtractPercussiveEventsRequest): PercussiveEvent[];
138
+ /**
139
+ * Render edited percussive events back over their source audio.
140
+ *
141
+ * Per event the lifted signal is the percussive component over
142
+ * `[onsetSample, offsetSample)` under the tail fade. It is subtracted where it
143
+ * sits and, unless the event is muted, added back at the shifted position scaled
144
+ * by the gain. Only that signal moves, so muting a hit leaves the harmonic
145
+ * content under it sounding and moving one does not drag its neighbours' sustain
146
+ * along.
147
+ *
148
+ * Each event's span and `edit` are read; `strength`, `peakAmplitude` and
149
+ * `percussiveRatio` are ignored, so an extracted event can be passed back as-is,
150
+ * or an event can be built by hand from the span alone. A set whose edits are all
151
+ * identity reproduces the input bit for bit and runs no separation at all.
152
+ *
153
+ * Pass the separation the events were extracted with: a different one lifts a
154
+ * different signal out of the span than the one the events describe. It is
155
+ * validated even when every edit is the identity and no separation runs, so an
156
+ * unusable framing is an error on every set rather than on some of them.
157
+ *
158
+ * Overlap is checked on the source spans only. Where `timeOffsetSamples` lands an
159
+ * event is not, so two moved events may be written over each other, and a shift
160
+ * that pushes the signal past either end is truncated there rather than wrapped.
161
+ *
162
+ * @param request - Source audio, the events to render, the separation and the
163
+ * tail fade
164
+ * @returns The rendered audio, the same length and sample rate as the input
165
+ * @throws RangeError when the samples or sample rate fail the shared input checks
166
+ * @throws SonareError (`InvalidParameter`) on an event whose span is empty,
167
+ * reversed or outside the audio, overlapping source spans, a non-finite
168
+ * `gainDb`, a kernel size that is not an integer within the 32-bit range, a
169
+ * framing that breaks constant overlap-add, or a negative or non-finite
170
+ * `fadeMs`
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const events = extractPercussiveEvents({ samples, sampleRate });
175
+ *
176
+ * // Lift the loudest hit by 3 dB and leave the rest untouched.
177
+ * const loudest = events.reduce((a, b) => (a.strength >= b.strength ? a : b));
178
+ * const edited = events.map((event) =>
179
+ * event === loudest ? { ...event, edit: { ...event.edit, gainDb: 3 } } : event,
180
+ * );
181
+ * const rendered = renderPercussiveEvents({ samples, sampleRate, events: edited });
182
+ * ```
183
+ */
184
+ export declare function renderPercussiveEvents(request: RenderPercussiveEventsRequest): Float32Array;
185
+ //# sourceMappingURL=effects_percussive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects_percussive.d.ts","sourceRoot":"","sources":["../src/effects_percussive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,kEAAkE;AAClE,MAAM,WAAW,8BACf,SAAQ,2BAA2B,EACjC,eAAe;IACjB,OAAO,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAAC;IAC1C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,6BACf,SAAQ,2BAA2B,EACjC,eAAe;IACjB,OAAO,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAAC;IAC1C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACxC;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,eAAe,EAAE,CAKnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,YAAY,CAU3F"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Harmonic/percussive separation: the masked split and the two shortcuts
3
+ * that return a single component.
4
+ */
5
+ import type { HpssResult } from './public_types';
6
+ import type { ValidateOptions } from './validation';
7
+ /** Canonical request form for HPSS. */
8
+ export interface HpssRequest {
9
+ samples: Float32Array;
10
+ sampleRate?: number;
11
+ /**
12
+ * Horizontal median filter size, in STFT frames: a positive odd integer at
13
+ * most 524287. Default 31. The ceiling is 524288 and an even kernel is
14
+ * refused, so 524287 is the largest legal value.
15
+ */
16
+ kernelHarmonic?: number;
17
+ /** Vertical median filter size, in STFT bins, under the same rule. Default 31. */
18
+ kernelPercussive?: number;
19
+ nFft?: number;
20
+ hopLength?: number;
21
+ hardMask?: boolean;
22
+ }
23
+ export interface HarmonicRequest extends ValidateOptions {
24
+ samples: Float32Array;
25
+ sampleRate?: number;
26
+ }
27
+ export interface PercussiveRequest extends ValidateOptions {
28
+ samples: Float32Array;
29
+ sampleRate?: number;
30
+ }
31
+ /**
32
+ * Perform Harmonic-Percussive Source Separation (HPSS).
33
+ *
34
+ * @param samples - Audio samples (mono, float32)
35
+ * @param sampleRate - Sample rate in Hz (default: 22050)
36
+ * @param kernelHarmonic - Horizontal median filter size in STFT frames; a
37
+ * positive odd integer at most 524287 (default: 31)
38
+ * @param kernelPercussive - Vertical median filter size in STFT bins, under the
39
+ * same rule (default: 31)
40
+ * @returns Separated harmonic and percussive components
41
+ * @throws SonareError (`InvalidParameter`) on a kernel that is not an integer
42
+ * within the signed 32-bit range, or one the core rejects as even,
43
+ * non-positive or above its ceiling
44
+ */
45
+ export declare function hpss(request: HpssRequest): HpssResult;
46
+ export declare function hpss(samples: Float32Array, sampleRate?: number, kernelHarmonic?: number, kernelPercussive?: number, nFft?: number, hopLength?: number, hardMask?: boolean): HpssResult;
47
+ /**
48
+ * Extract harmonic component from audio.
49
+ *
50
+ * @param samples - Audio samples (mono, float32)
51
+ * @param sampleRate - Sample rate in Hz
52
+ * @returns Harmonic component
53
+ */
54
+ export declare function harmonic(request: HarmonicRequest): Float32Array;
55
+ export declare function harmonic(samples: Float32Array, sampleRate?: number, options?: ValidateOptions): Float32Array;
56
+ /**
57
+ * Extract percussive component from audio.
58
+ *
59
+ * @param samples - Audio samples (mono, float32)
60
+ * @param sampleRate - Sample rate in Hz
61
+ * @returns Percussive component
62
+ */
63
+ export declare function percussive(request: PercussiveRequest): Float32Array;
64
+ export declare function percussive(samples: Float32Array, sampleRate?: number, options?: ValidateOptions): Float32Array;
65
+ //# sourceMappingURL=effects_separation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects_separation.d.ts","sourceRoot":"","sources":["../src/effects_separation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiBpD,uCAAuC;AACvC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAAC;AACvD,wBAAgB,IAAI,CAClB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,OAAO,GACjB,UAAU,CAAC;AA8Bd;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAAC;AACjE,wBAAgB,QAAQ,CACtB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC;AAWhB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC;AACrE,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,GACxB,YAAY,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Region-based spectral editing: time x frequency rectangles applied over an
3
+ * STFT and resynthesized.
4
+ */
5
+ import type { SpectralEditOptions, SpectralRegionOp } from './public_types';
6
+ import type { ValidateOptions } from './validation';
7
+ export interface SpectralEditRequest extends SpectralEditOptions, ValidateOptions {
8
+ samples: Float32Array;
9
+ sampleRate: number;
10
+ ops?: SpectralRegionOp[];
11
+ }
12
+ /**
13
+ * Apply region-based spectral edits (gain/attenuate/mute/heal) to mono audio.
14
+ *
15
+ * Each op is a time x frequency rectangle applied in array order over a single
16
+ * STFT buffer, so a later op observes the result of earlier ops. The output has
17
+ * the same length and sample rate as the input; an empty `ops` list is an
18
+ * identity transform (within the iSTFT's own tolerance).
19
+ *
20
+ * @param samples - Audio samples (mono, float32)
21
+ * @param sampleRate - Sample rate in Hz
22
+ * @param ops - Region edit ops applied in order ({@link SpectralRegionOp})
23
+ * @param options - STFT + heal configuration ({@link SpectralEditOptions})
24
+ * @returns Edited audio
25
+ */
26
+ export declare function spectralEdit(request: SpectralEditRequest): Float32Array;
27
+ export declare function spectralEdit(samples: Float32Array, sampleRate: number, ops?: SpectralRegionOp[], options?: SpectralEditOptions & ValidateOptions): Float32Array;
28
+ //# sourceMappingURL=effects_spectral.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects_spectral.d.ts","sourceRoot":"","sources":["../src/effects_spectral.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB,EAAE,eAAe;IAC/E,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC;AACzE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAAG,eAAe,GAC9C,YAAY,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Time and pitch transforms over a whole buffer: stretching, shifting, and
3
+ * correction onto a target pitch.
4
+ */
5
+ import type { PitchCorrectOptions, VoicedFlags } from './public_types';
6
+ import type { ValidateOptions } from './validation';
7
+ export interface TimeStretchRequest extends ValidateOptions {
8
+ samples: Float32Array;
9
+ sampleRate?: number;
10
+ rate: number;
11
+ nFft?: number;
12
+ hopLength?: number;
13
+ }
14
+ export interface PitchShiftRequest extends ValidateOptions {
15
+ samples: Float32Array;
16
+ sampleRate?: number;
17
+ semitones: number;
18
+ nFft?: number;
19
+ hopLength?: number;
20
+ }
21
+ export interface PitchCorrectToMidiRequest extends ValidateOptions {
22
+ samples: Float32Array;
23
+ sampleRate?: number;
24
+ currentMidi?: number;
25
+ targetMidi?: number;
26
+ }
27
+ export interface PitchCorrectToMidiTimevaryingRequest extends ValidateOptions {
28
+ samples: Float32Array;
29
+ f0Hz: Float32Array;
30
+ targetMidi: number;
31
+ sampleRate?: number;
32
+ hopLength?: number;
33
+ voiced?: VoicedFlags | null;
34
+ voicedProb?: Float32Array | null;
35
+ }
36
+ export interface PitchCorrectTimevaryingRequest extends PitchCorrectOptions {
37
+ samples: Float32Array;
38
+ f0Hz: Float32Array;
39
+ sampleRate?: number;
40
+ hopLength?: number;
41
+ }
42
+ /**
43
+ * Time-stretch audio without changing pitch.
44
+ *
45
+ * @param samples - Audio samples (mono, float32)
46
+ * @param sampleRate - Sample rate in Hz (default: 22050)
47
+ * @param rate - Time stretch rate (0.5 = double duration, 2.0 = half duration)
48
+ * @param nFft - FFT size: an even integer >= 2 (default 2048)
49
+ * @param hopLength - Hop in samples, in `(0, nFft / 2]` (default 512), so
50
+ * frames overlap by at least half a window
51
+ * @returns Time-stretched audio
52
+ */
53
+ export declare function timeStretch(request: TimeStretchRequest): Float32Array;
54
+ export declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number, options?: ValidateOptions): Float32Array;
55
+ export declare function timeStretch(samples: Float32Array, sampleRate: number, rate: number, nFft?: number, hopLength?: number, options?: ValidateOptions): Float32Array;
56
+ /**
57
+ * Pitch-shift audio without changing duration.
58
+ *
59
+ * @param samples - Audio samples (mono, float32)
60
+ * @param sampleRate - Sample rate in Hz (default: 22050)
61
+ * @param semitones - Pitch shift in semitones (+12 = one octave up, -12 = one octave down)
62
+ * @param nFft - FFT size: an even integer >= 2 (default 2048)
63
+ * @param hopLength - Hop in samples, in `(0, nFft / 2]` (default 512), so
64
+ * frames overlap by at least half a window
65
+ * @returns Pitch-shifted audio
66
+ */
67
+ export declare function pitchShift(request: PitchShiftRequest): Float32Array;
68
+ export declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number, options?: ValidateOptions): Float32Array;
69
+ export declare function pitchShift(samples: Float32Array, sampleRate: number, semitones: number, nFft?: number, hopLength?: number, options?: ValidateOptions): Float32Array;
70
+ /**
71
+ * Pitch-correct audio from a current MIDI note to a target MIDI note.
72
+ *
73
+ * Applies one constant, immediate transpose with no retune glide and preserves
74
+ * the input buffer length. The whole interval is applied however large it is:
75
+ * both endpoints are validated to [0, 127], so a two-octave move such as
76
+ * C3 -> C5 transposes by the full 24 semitones. Use
77
+ * {@link pitchCorrectToMidiTimevarying} for a caller-supplied pitch contour.
78
+ *
79
+ * @param samples - Audio samples (mono, float32)
80
+ * @param sampleRate - Sample rate in Hz
81
+ * @param currentMidi - Detected/current MIDI note number
82
+ * @param targetMidi - Desired MIDI note number
83
+ * @returns Pitch-corrected audio
84
+ */
85
+ export declare function pitchCorrectToMidi(request: PitchCorrectToMidiRequest): Float32Array;
86
+ export declare function pitchCorrectToMidi(samples: Float32Array, sampleRate?: number, currentMidi?: number, targetMidi?: number, options?: ValidateOptions): Float32Array;
87
+ /**
88
+ * Contour-following ("time-varying") pitch correction toward a MIDI target.
89
+ *
90
+ * Unlike {@link pitchCorrectToMidi} (a single constant transpose), this follows
91
+ * the caller-supplied per-frame `f0Hz` contour and retunes every voiced frame
92
+ * toward `targetMidi`, so vibrato/drift in the source is tracked rather than
93
+ * flattened. When `voiced` is supplied (truthy = voiced), it takes precedence
94
+ * over `voicedProb`; omitting it or passing `null` uses the probability array.
95
+ * When both are omitted, every frame is treated as voiced. An `f0Hz` NaN is
96
+ * accepted only for a frame marked unvoiced, matching pYIN output. The
97
+ * `voicedFlag` / `voicedProb` arrays of a {@link PitchResult} can
98
+ * be passed through directly.
99
+ *
100
+ * @param samples - Audio samples (mono, float32)
101
+ * @param f0Hz - Per-frame measured F0 in Hz (one entry per analysis frame)
102
+ * @param targetMidi - Desired MIDI note number
103
+ * @param sampleRate - Sample rate in Hz
104
+ * @param hopLength - F0 frame-center spacing in samples. Frame i is centered at
105
+ * sample i*hopLength; nearest-frame voicing switches halfway between centers.
106
+ * @param voiced - Optional per-frame voiced flags (truthy = voiced); takes
107
+ * precedence over `voicedProb`.
108
+ * @param voicedProb - Optional per-frame voicing probability in [0, 1]; used
109
+ * when `voiced` is omitted or `null`.
110
+ * @returns Pitch-corrected audio
111
+ */
112
+ export declare function pitchCorrectToMidiTimevarying(request: PitchCorrectToMidiTimevaryingRequest): Float32Array;
113
+ export declare function pitchCorrectToMidiTimevarying(samples: Float32Array, f0Hz: Float32Array, targetMidi: number, sampleRate?: number, hopLength?: number, voiced?: VoicedFlags | null, voicedProb?: Float32Array | null, options?: ValidateOptions): Float32Array;
114
+ /**
115
+ * Contour-following pitch correction toward a fixed MIDI note OR a musical
116
+ * scale, with tunable retune strength and vibrato preservation.
117
+ *
118
+ * Generalises {@link pitchCorrectToMidiTimevarying}: the same caller-supplied
119
+ * per-frame `f0Hz` contour drives correction, but `options.mode` selects between
120
+ * a fixed-MIDI target (`'midi'`, default) and scale quantisation (`'scale'`),
121
+ * and the retune knobs shape natural-vs-robotic correction. An `f0Hz` NaN is
122
+ * accepted only for a frame marked unvoiced.
123
+ *
124
+ * @param samples - Audio samples (mono, float32)
125
+ * @param f0Hz - Per-frame measured F0 in Hz (one entry per analysis frame)
126
+ * @param sampleRate - Sample rate in Hz
127
+ * @param hopLength - F0 frame-center spacing in samples. Frame i is centered at
128
+ * sample i*hopLength; nearest-frame voicing switches halfway between centers.
129
+ * @param options - Target mode + retune knobs + optional voiced/voicedProb arrays
130
+ * @returns Pitch-corrected audio
131
+ */
132
+ export declare function pitchCorrectTimevarying(request: PitchCorrectTimevaryingRequest): Float32Array;
133
+ export declare function pitchCorrectTimevarying(samples: Float32Array, f0Hz: Float32Array, sampleRate?: number, hopLength?: number, options?: PitchCorrectOptions): Float32Array;
134
+ //# sourceMappingURL=effects_timepitch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects_timepitch.d.ts","sourceRoot":"","sources":["../src/effects_timepitch.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,53 @@
1
+ import type { RealtimeVoiceChangerConfigInput } from './public_types';
2
+ import type { ValidateOptions } from './validation';
3
+ /** Options for {@link voiceChange}. All fields are optional. */
4
+ export interface VoiceChangeOptions extends ValidateOptions {
5
+ /** Pitch shift in semitones (negative = down). Default 0. */
6
+ pitchSemitones?: number;
7
+ /** Formant scale factor (>1 brightens, <1 darkens). Default 1. */
8
+ formantFactor?: number;
9
+ }
10
+ /** Canonical request form for one-shot voice changing. */
11
+ export interface VoiceChangeRequest extends VoiceChangeOptions {
12
+ samples: Float32Array;
13
+ sampleRate?: number;
14
+ }
15
+ /**
16
+ * Apply a voice change by shifting pitch and formants independently.
17
+ *
18
+ * @param samples - Audio samples (mono, float32)
19
+ * @param sampleRate - Sample rate in Hz
20
+ * @param options - Pitch/formant settings ({@link VoiceChangeOptions})
21
+ * @returns Voice-changed audio
22
+ */
23
+ export declare function voiceChange(request: VoiceChangeRequest): Float32Array;
24
+ export declare function voiceChange(samples: Float32Array, sampleRate?: number, options?: VoiceChangeOptions): Float32Array;
25
+ /** Options for the offline {@link voiceChangeRealtime} convenience wrapper. */
26
+ export interface VoiceChangeRealtimeOptions extends ValidateOptions {
27
+ /** Channel count (1 = mono, 2 = interleaved stereo). */
28
+ channels?: 1 | 2;
29
+ /** @deprecated The shared C-ABI renderer uses a fixed cross-surface block size. */
30
+ blockSize?: number;
31
+ }
32
+ /** Canonical request form for offline realtime voice changing. */
33
+ export interface VoiceChangeRealtimeRequest extends VoiceChangeRealtimeOptions {
34
+ samples: Float32Array;
35
+ sampleRate?: number;
36
+ preset?: RealtimeVoiceChangerConfigInput;
37
+ }
38
+ /**
39
+ * Applies the realtime voice-changer chain to a whole buffer in one call.
40
+ *
41
+ * Uses the shared C-ABI renderer, so Python, Node, and WASM use the same
42
+ * fixed block size and latency compensation. For mono, `samples` is a plain
43
+ * buffer; for stereo, it is interleaved (L0,R0,L1,R1,...).
44
+ *
45
+ * @param samples - Audio samples (mono, or interleaved stereo when channels=2)
46
+ * @param sampleRate - Sample rate in Hz (default 48000, matching Python/Node)
47
+ * @param preset - Voice-changer preset id or full config object
48
+ * @param options - Channel count and block size ({@link VoiceChangeRealtimeOptions})
49
+ * @returns The processed buffer (same layout/length as the input).
50
+ */
51
+ export declare function voiceChangeRealtime(request: VoiceChangeRealtimeRequest): Float32Array;
52
+ export declare function voiceChangeRealtime(samples: Float32Array, sampleRate?: number, preset?: RealtimeVoiceChangerConfigInput, options?: VoiceChangeRealtimeOptions): Float32Array;
53
+ //# sourceMappingURL=effects_voice_change.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects_voice_change.d.ts","sourceRoot":"","sources":["../src/effects_voice_change.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,gEAAgE;AAChE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY,CAAC;AACvE,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,YAAY,CAAC;AAgBhB,+EAA+E;AAC/E,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kEAAkE;AAClE,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;IAC5E,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,+BAA+B,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,YAAY,CAAC;AACvF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,EACrB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,+BAA+B,EACxC,OAAO,CAAC,EAAE,0BAA0B,GACnC,YAAY,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Numeric error codes carried by a {@link SonareError}. Mirrors the C ABI
3
+ * `SonareError` enum (and the Node / Python surfaces), so the same failure
4
+ * reports the same numeric code on every binding.
5
+ */
6
+ export declare enum ErrorCode {
7
+ Ok = 0,
8
+ FileNotFound = 1,
9
+ InvalidFormat = 2,
10
+ DecodeFailed = 3,
11
+ InvalidParameter = 4,
12
+ OutOfMemory = 5,
13
+ NotSupported = 6,
14
+ InvalidState = 7,
15
+ Cancelled = 8,
16
+ EncodeFailed = 9,
17
+ Unknown = 99
18
+ }
19
+ /**
20
+ * Error thrown by libsonare on a native (C++) failure. Carries a numeric
21
+ * {@link ErrorCode} `code` plus its canonical `codeName`, so callers can branch
22
+ * on the cause instead of matching message text.
23
+ *
24
+ * Narrow a caught value with {@link isSonareError} or with `instanceof`; both
25
+ * accept the same values. The Node package exports the same class under the
26
+ * same name.
27
+ */
28
+ export declare class SonareError extends Error {
29
+ /** Numeric error code, equal to an {@link ErrorCode} value. */
30
+ readonly code: number;
31
+ /** Canonical name of `code`, e.g. `'InvalidParameter'`. */
32
+ readonly codeName: string;
33
+ constructor(code: number, codeName: string, message: string);
34
+ /**
35
+ * Brand-based `instanceof`: an error that carries the shape narrows here even
36
+ * when it is not literally an instance of this class. That is not a
37
+ * hypothetical — an error posted from the analysis worker arrives as a
38
+ * structured clone with its prototype gone, which a prototype-based
39
+ * `instanceof` would silently miss. Delegates to {@link isSonareError} so the
40
+ * two never disagree.
41
+ */
42
+ static [Symbol.hasInstance](value: unknown): value is SonareError;
43
+ }
44
+ /**
45
+ * Type guard: whether a caught value is a libsonare {@link SonareError}.
46
+ *
47
+ * Duck-typed on purpose: a value that crossed a worker boundary has lost its
48
+ * prototype, so a prototype check would miss it.
49
+ */
50
+ export declare function isSonareError(value: unknown): value is SonareError;
51
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,SAAS;IACnB,EAAE,IAAI;IACN,YAAY,IAAI;IAChB,aAAa,IAAI;IACjB,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB,WAAW,IAAI;IACf,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,OAAO,KAAK;CACb;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAO3D;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW;CAGlE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAMlE"}