@libraz/libsonare 1.7.1 → 1.8.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 (303) hide show
  1. package/NOTICE +178 -0
  2. package/README.md +26 -170
  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 +6 -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 -5837
  14. package/dist/analysis.d.ts.map +1 -0
  15. package/dist/analysis.js +873 -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 +477 -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 +129 -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 -7329
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +3816 -1359
  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 +457 -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 +652 -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 +510 -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 +164 -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 +850 -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 +3909 -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 +335 -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 +128 -0
  179. package/dist/worklet/engine-mixer-facade.d.ts.map +1 -0
  180. package/dist/worklet/engine-node.d.ts +81 -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 +68 -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 +73 -0
  193. package/dist/worklet/engine-strips.d.ts.map +1 -0
  194. package/dist/worklet/engine-sync.d.ts +37 -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 +397 -0
  199. package/dist/worklet/engine.d.ts.map +1 -0
  200. package/dist/worklet/guards.d.ts +47 -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 +323 -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 -2142
  213. package/dist/worklet.d.ts.map +1 -0
  214. package/dist/worklet.js +2889 -466
  215. package/dist/worklet.js.map +1 -1
  216. package/package.json +23 -12
  217. package/src/_effects_common.ts +17 -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 +97 -22
  226. package/src/effects_note_ops.ts +635 -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 +377 -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 +285 -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 +346 -32
  246. package/src/mastering_dynamics.ts +22 -11
  247. package/src/metering.ts +67 -24
  248. package/src/mixer.ts +212 -3
  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 +64 -24
  255. package/src/project_class.ts +502 -29
  256. package/src/project_internal.ts +151 -42
  257. package/src/project_synth.ts +67 -1
  258. package/src/project_types.ts +302 -270
  259. package/src/public_types.ts +122 -3
  260. package/src/public_types_acoustic.ts +112 -3
  261. package/src/public_types_mastering.ts +254 -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 +195 -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 +487 -1
  268. package/src/quick_analysis.ts +203 -26
  269. package/src/realtime_engine.ts +750 -28
  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 +1125 -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 +212 -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 +444 -10
  287. package/src/worklet/engine-node.ts +85 -28
  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 +307 -71
  291. package/src/worklet/engine-register.ts +32 -18
  292. package/src/worklet/engine-strips.ts +280 -9
  293. package/src/worklet/engine-sync.ts +14 -6
  294. package/src/worklet/engine.ts +365 -31
  295. package/src/worklet/guards.ts +140 -44
  296. package/src/worklet/messages.ts +239 -2
  297. package/src/worklet/mixer-processor.ts +109 -47
  298. package/src/worklet/playback-processor.ts +300 -0
  299. package/src/worklet/protocol.ts +53 -3
  300. package/src/worklet/voice-changer-processor.ts +17 -11
  301. package/src/worklet.ts +22 -0
  302. package/src/effects_transform.ts +0 -718
  303. package/src/mastering_repair.ts +0 -273
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Broadband and tonal noise repair: denoise and dehum, with their detectors.
3
+ */
4
+ import type { HumDetection, MasteringRepairDehumStereoResult, MasteringRepairDenoiseClassicalLinkedResult, MasteringRepairDenoiseClassicalStereoResult, NoiseDetection } from './public_types_repair';
5
+ /** Algorithms accepted by `masteringRepairDenoiseClassical`. */
6
+ export type DenoiseClassicalMode = 'logMmse' | 'mmseStsa' | 'spectralSubtraction';
7
+ /** Noise PSD estimators accepted by `masteringRepairDenoiseClassical`. */
8
+ export type DenoiseClassicalNoiseEstimator = 'quantile' | 'mcra' | 'imcra' | 'spp';
9
+ /** Options for `masteringRepairDenoiseClassical`. */
10
+ export interface DenoiseClassicalOptions {
11
+ mode?: DenoiseClassicalMode;
12
+ noiseEstimator?: DenoiseClassicalNoiseEstimator;
13
+ nFft?: number;
14
+ hopLength?: number;
15
+ ddAlpha?: number;
16
+ reductionDb?: number;
17
+ overSubtraction?: number;
18
+ spectralFloor?: number;
19
+ noiseEstimationQuantile?: number;
20
+ speechPresenceGain?: boolean;
21
+ gainSmoothing?: boolean;
22
+ }
23
+ export interface MasteringRepairDenoiseClassicalRequest extends DenoiseClassicalOptions {
24
+ samples: Float32Array;
25
+ sampleRate: number;
26
+ }
27
+ /** Request form of `masteringRepairDenoiseClassicalStereo`. */
28
+ export interface MasteringRepairDenoiseClassicalStereoRequest extends DenoiseClassicalOptions {
29
+ left: Float32Array;
30
+ right: Float32Array;
31
+ sampleRate?: number;
32
+ }
33
+ /** Request form of `masteringRepairDenoiseClassicalLinked`. */
34
+ export interface MasteringRepairDenoiseClassicalLinkedRequest extends DenoiseClassicalOptions {
35
+ /** At least one channel; all the same length. */
36
+ channels: Float32Array[];
37
+ sampleRate?: number;
38
+ }
39
+ /** Offline STFT-domain classical denoiser (LogMMSE / MMSE-STSA / SpectralSubtraction). */
40
+ export declare function masteringRepairDenoiseClassical(request: MasteringRepairDenoiseClassicalRequest): Float32Array;
41
+ export declare function masteringRepairDenoiseClassical(samples: Float32Array, sampleRate: number, options?: DenoiseClassicalOptions): Float32Array;
42
+ /**
43
+ * Offline STFT-domain classical denoiser for a stereo pair, driven by one channel-linked
44
+ * gain mask.
45
+ *
46
+ * The mask is built from the channel-summed power and applied unchanged to both channels, so
47
+ * the pass cannot move an interchannel level or phase difference. That is also why the result
48
+ * carries a single `report` rather than one per channel: a pair would be two copies of one
49
+ * measurement and would read as though the two could differ.
50
+ *
51
+ * `report.detected` is therefore a *pair-level* measurement, and the only absolute one in the
52
+ * result. Its levels are dBFS on the channel-summed power, so two identical channels read
53
+ * `10*log10(2)` — about 3.01 dB — above the same material through
54
+ * {@link masteringRepairDenoiseClassical}. A stereo floor is comparable only against another
55
+ * stereo floor, never against a mono one.
56
+ *
57
+ * Needs at least `nFft` samples and REJECTS a shorter input, which is the opposite of
58
+ * {@link masteringRepairDereverbClassicalStereo} — that one pads.
59
+ *
60
+ * Which options are live depends on `mode`: `overSubtraction` and `spectralFloor` are read
61
+ * only by `spectralSubtraction`, and `speechPresenceGain` and `gainSmoothing` only by the
62
+ * other two, so at the default `logMmse` the first pair does nothing.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const { left, right, report } = masteringRepairDenoiseClassicalStereo({
67
+ * left: leftSamples,
68
+ * right: rightSamples,
69
+ * sampleRate: 48000,
70
+ * reductionDb: 18,
71
+ * });
72
+ * console.log(report.detected.floorDbfs, report.meanReductionDb);
73
+ * ```
74
+ */
75
+ export declare function masteringRepairDenoiseClassicalStereo(request: MasteringRepairDenoiseClassicalStereoRequest): MasteringRepairDenoiseClassicalStereoResult;
76
+ export declare function masteringRepairDenoiseClassicalStereo(left: Float32Array, right: Float32Array, sampleRate: number, config?: DenoiseClassicalOptions): MasteringRepairDenoiseClassicalStereoResult;
77
+ /**
78
+ * Offline STFT-domain classical denoiser for any number of channels, driven by one
79
+ * channel-linked gain mask.
80
+ *
81
+ * The N-channel form of {@link masteringRepairDenoiseClassicalStereo}, carrying the same
82
+ * guarantee over the whole set: the mask is built from the channel-summed power and applied
83
+ * unchanged to every channel, so no interchannel level or phase difference moves however many
84
+ * channels there are. One `report` for the set, and one output per input channel in input order.
85
+ *
86
+ * A single channel reproduces {@link masteringRepairDenoiseClassical} bit for bit, and two
87
+ * reproduce {@link masteringRepairDenoiseClassicalStereo} plane for plane — `channels[0]` is the
88
+ * left plane and `channels[1]` the right.
89
+ *
90
+ * `report.detected` carries absolute levels and they are the SET's: the floor is referred to the
91
+ * summed mean square of every channel, so N identical channels read `10*log10(N)` above
92
+ * one of them — about 3.01 dB at two channels and 4.77 dB at three. Compare a floor only against
93
+ * one measured over the same number of channels. Every other field of the report is a fraction
94
+ * and does not move with the channel count.
95
+ *
96
+ * Needs at least `nFft` samples and REJECTS a shorter input, which is the opposite of
97
+ * {@link masteringRepairDereverbClassicalLinked} — that one pads.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const { channels, report } = masteringRepairDenoiseClassicalLinked({
102
+ * channels: [frontLeft, frontRight, centre],
103
+ * sampleRate: 48000,
104
+ * reductionDb: 18,
105
+ * });
106
+ * console.log(channels.length, report.detected.floorDbfs);
107
+ * ```
108
+ */
109
+ export declare function masteringRepairDenoiseClassicalLinked(request: MasteringRepairDenoiseClassicalLinkedRequest): MasteringRepairDenoiseClassicalLinkedResult;
110
+ export declare function masteringRepairDenoiseClassicalLinked(channels: Float32Array[], sampleRate: number, config?: DenoiseClassicalOptions): MasteringRepairDenoiseClassicalLinkedResult;
111
+ /**
112
+ * How `masteringRepairDehum` removes the harmonic series.
113
+ *
114
+ * `subtract` tracks each harmonic's amplitude and phase and subtracts the tone they describe,
115
+ * so material sitting at the same frequency but uncorrelated with the tracked series survives.
116
+ * `notch` cascades one RBJ notch per harmonic and removes everything inside each notch's
117
+ * bandwidth, hum or programme alike.
118
+ */
119
+ export type DehumMode = 'subtract' | 'notch';
120
+ /** Options for `masteringRepairDehum`. */
121
+ export interface DehumOptions {
122
+ fundamentalHz?: number;
123
+ harmonics?: number;
124
+ q?: number;
125
+ adaptive?: boolean;
126
+ searchRangeHz?: number;
127
+ adaptation?: number;
128
+ frameSize?: number;
129
+ pllBandwidth?: number;
130
+ /** Defaults to `'subtract'`. */
131
+ mode?: DehumMode;
132
+ }
133
+ export interface MasteringRepairDehumRequest extends DehumOptions {
134
+ samples: Float32Array;
135
+ sampleRate: number;
136
+ }
137
+ /** Request form of `masteringRepairDehumStereo`. */
138
+ export interface MasteringRepairDehumStereoRequest extends DehumOptions {
139
+ left: Float32Array;
140
+ right: Float32Array;
141
+ sampleRate?: number;
142
+ }
143
+ /** Offline mains-hum remover. */
144
+ export declare function masteringRepairDehum(request: MasteringRepairDehumRequest): Float32Array;
145
+ export declare function masteringRepairDehum(samples: Float32Array, sampleRate: number, options?: DehumOptions): Float32Array;
146
+ /**
147
+ * Offline mains-hum remover for a stereo pair.
148
+ *
149
+ * With `adaptive` set, mains hum is one physical source, so the tracker reads the channel
150
+ * mean and both cascades follow the one frequency it finds: `appliedFundamentalHz` and
151
+ * `fundamentalDriftHz` come back identical in both reports by construction, while each
152
+ * report's `detected` still measures that channel's own input and each channel keeps its
153
+ * own filter state, so neither channel's transient rings through the other. With `adaptive`
154
+ * clear, which is the default, nothing is shared and the two channels are filtered
155
+ * independently at the configured frequency.
156
+ */
157
+ export declare function masteringRepairDehumStereo(request: MasteringRepairDehumStereoRequest): MasteringRepairDehumStereoResult;
158
+ export declare function masteringRepairDehumStereo(left: Float32Array, right: Float32Array, sampleRate: number, config?: DehumOptions): MasteringRepairDehumStereoResult;
159
+ /** Request form of `masteringRepairDetectNoiseFloor`. */
160
+ export interface MasteringRepairDetectNoiseFloorRequest extends DenoiseClassicalOptions {
161
+ samples: Float32Array;
162
+ sampleRate: number;
163
+ }
164
+ /** Request form of `masteringRepairNoiseBandBins`. */
165
+ export interface MasteringRepairNoiseBandBinsRequest {
166
+ nFft?: number;
167
+ sampleRate?: number;
168
+ }
169
+ /** Request form of `masteringRepairDetectHum`. */
170
+ export interface MasteringRepairDetectHumRequest extends DehumOptions {
171
+ samples: Float32Array;
172
+ sampleRate: number;
173
+ }
174
+ /**
175
+ * Measures the noise floor without denoising.
176
+ *
177
+ * Runs the STFT and the configured noise estimator — the two stages
178
+ * {@link masteringRepairDenoiseClassical} runs — and stops before the gain mask, which is why
179
+ * no attenuation figure appears here.
180
+ *
181
+ * Needs at least `nFft` samples and THROWS for a shorter buffer, the opposite of
182
+ * {@link masteringRepairDetectReverb}, which pads one.
183
+ *
184
+ * `floorDbfs` is an absolute level, so it is comparable only against another figure measured
185
+ * over the same channel count.
186
+ */
187
+ export declare function masteringRepairDetectNoiseFloor(request: MasteringRepairDetectNoiseFloorRequest): NoiseDetection;
188
+ export declare function masteringRepairDetectNoiseFloor(samples: Float32Array, sampleRate: number, options?: DenoiseClassicalOptions): NoiseDetection;
189
+ /**
190
+ * Bin boundaries of the grid {@link masteringRepairDetectNoiseFloor} reports `bandFloorDbfs` on.
191
+ *
192
+ * Band `k` covers the one-sided STFT bins `[bins[k], bins[k + 1])`, and bin `b` sits at
193
+ * `b * sampleRate / nFft` Hz.
194
+ *
195
+ * The geometric band edges are rounded to bins, so a band narrower than the bin spacing comes
196
+ * out EMPTY — `bins[k] === bins[k + 1]` — and its `bandFloorDbfs[k]` reads as the floor
197
+ * sentinel because no bin landed in it, NOT because that region was quiet. Telling those two
198
+ * apart is what this grid is for, and the rounding cannot be recovered from the band count
199
+ * alone.
200
+ *
201
+ * Nothing but the analysis geometry decides the grid, so no denoise config is taken: one call
202
+ * describes every floor measured at that `nFft` and `sampleRate`, whatever mode or estimator
203
+ * produced it.
204
+ *
205
+ * @param nFft - STFT size the bins belong to; a positive power of two, the same rule
206
+ * {@link masteringRepairDetectNoiseFloor} applies to its config, so every grid returned here
207
+ * is one that entry can report on. Defaults to 1024.
208
+ * @param sampleRate - Sample rate the bins belong to, in Hz; positive. Defaults to 22050.
209
+ * @returns 33 bin indices, low to high — one more than the 32 bands: the first bin of every
210
+ * band plus the one-past-the-end bin of the last, which is `nFft / 2 + 1`. Non-decreasing.
211
+ * @throws If `nFft` is not a positive power of two, or `sampleRate` is not positive.
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * const bins = masteringRepairNoiseBandBins({ nFft: 1024, sampleRate: 48000 });
216
+ * const floor = masteringRepairDetectNoiseFloor({ samples, sampleRate: 48000, nFft: 1024 });
217
+ * floor.bandFloorDbfs.forEach((level, k) => {
218
+ * if (bins[k] === bins[k + 1]) return; // empty band: `level` is the sentinel, not a measurement
219
+ * console.log((bins[k] * 48000) / 1024, level);
220
+ * });
221
+ * ```
222
+ */
223
+ export declare function masteringRepairNoiseBandBins(request?: MasteringRepairNoiseBandBinsRequest): Int32Array;
224
+ export declare function masteringRepairNoiseBandBins(nFft?: number, sampleRate?: number): Int32Array;
225
+ /**
226
+ * Measures hum without filtering.
227
+ *
228
+ * Always runs the estimation path, whatever `adaptive` says: the fixed path notches the
229
+ * configured frequency without ever looking for hum, so a detector following the flag would
230
+ * hand back its own input. `fundamentalProminence` is the winning candidate's projected energy
231
+ * over the median candidate, so `1.0` means no peak was found at all — it is not a lock flag.
232
+ *
233
+ * `harmonicDbfs` is measured at every `k*f0` the sample rate carries, not only the ones a
234
+ * cascade would notch; a `k*f0` at or past Nyquist reads the dB floor because nothing is there
235
+ * to measure.
236
+ */
237
+ export declare function masteringRepairDetectHum(request: MasteringRepairDetectHumRequest): HumDetection;
238
+ export declare function masteringRepairDetectHum(samples: Float32Array, sampleRate: number, options?: DehumOptions): HumDetection;
239
+ //# sourceMappingURL=repair_noise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair_noise.d.ts","sourceRoot":"","sources":["../src/repair_noise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,gCAAgC,EAChC,2CAA2C,EAC3C,2CAA2C,EAC3C,cAAc,EACf,MAAM,uBAAuB,CAAC;AAM/B,gEAAgE;AAChE,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,UAAU,GAAG,qBAAqB,CAAC;AAElF,0EAA0E;AAC1E,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAEnF,qDAAqD;AACrD,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,cAAc,CAAC,EAAE,8BAA8B,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,sCAAuC,SAAQ,uBAAuB;IACrF,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,WAAW,4CAA6C,SAAQ,uBAAuB;IAC3F,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,U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ACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,sCAAsC,GAC9C,cAAc,CAAC;AAClB,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,uBAAuB,GAChC,cAAc,CAAC;AAiBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,CAAC,EAAE,mCAAmC,GAC5C,UAAU,CAAC;AACd,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;AAe7F;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,YAAY,CAAC;AACjG,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,YAAY,GACrB,YAAY,CAAC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Silence trimming, with the range detector it shares its geometry with.
3
+ */
4
+ import type { MasteringRepairTrimSilenceStereoResult, TrimRange } from './public_types_repair';
5
+ /** Trimming modes accepted by `masteringRepairTrimSilence`. */
6
+ export type TrimSilenceMode = 'peak' | 'lufsGated';
7
+ /** Options for `masteringRepairTrimSilence`. */
8
+ export interface TrimSilenceOptions {
9
+ threshold?: number;
10
+ paddingSamples?: number;
11
+ mode?: TrimSilenceMode;
12
+ gateLufs?: number;
13
+ windowMs?: number;
14
+ }
15
+ export interface MasteringRepairTrimSilenceRequest extends TrimSilenceOptions {
16
+ samples: Float32Array;
17
+ sampleRate: number;
18
+ }
19
+ /** Request form of `masteringRepairTrimSilenceStereo`. */
20
+ export interface MasteringRepairTrimSilenceStereoRequest extends TrimSilenceOptions {
21
+ left: Float32Array;
22
+ right: Float32Array;
23
+ sampleRate?: number;
24
+ }
25
+ /** Offline silence trimmer (peak threshold or LUFS-gated). */
26
+ export declare function masteringRepairTrimSilence(request: MasteringRepairTrimSilenceRequest): Float32Array;
27
+ export declare function masteringRepairTrimSilence(samples: Float32Array, sampleRate: number, options?: TrimSilenceOptions): Float32Array;
28
+ /**
29
+ * Offline silence trimmer for a stereo pair, cutting both channels to one shared range.
30
+ *
31
+ * Each channel is scanned on its own and the two ranges are UNIONED, so the pair keeps
32
+ * whatever either channel calls signal and both outputs come back the same length. The scan
33
+ * never reads a downmix: `0.5 * (left + right)` halves material carried by one channel alone,
34
+ * which can drop it under the gate, and cancels an antiphase pair to exactly zero, which would
35
+ * read full-level audio in both channels as silence. Trimming is destructive, so the rule errs
36
+ * toward keeping.
37
+ *
38
+ * The only repair stereo entry that SHORTENS its input: `result.left.length` is the output
39
+ * length, and the input's says nothing about it. A pair in which neither channel carries signal
40
+ * returns two EMPTY arrays and succeeds — it does not throw and does not return null.
41
+ *
42
+ * `report.range` is the union that was applied to both channels. `leftRange` and `rightRange`
43
+ * are the per-channel scans it was formed from, so a caller can see which channel decided each
44
+ * edge; a channel carrying nothing reports an empty range and contributes nothing to the union.
45
+ * With nothing kept, `report.range` is `(inputLength, inputLength)`, so `removedHeadSamples` is
46
+ * the whole input and `removedTailSamples` is 0 — the two still sum to the input length and
47
+ * only the split between the ends is arbitrary.
48
+ *
49
+ * Which option is live depends on `mode`: `threshold` is read ONLY by `'peak'`, and `gateLufs`
50
+ * and `windowMs` ONLY by `'lufsGated'`. Changing an option the active mode does not read is
51
+ * silently inert rather than an error.
52
+ *
53
+ * That gated mode compares an UNWEIGHTED RMS over a window centred on each sample against
54
+ * `gateLufs`, so the figure it gates on is dBFS rather than a BS.1770 loudness, and `windowMs`
55
+ * sizes that window and does nothing else. The window is clipped at the buffer ends, so a
56
+ * sample near either edge is judged on a shorter one.
57
+ *
58
+ * `paddingSamples` widens the kept range in both directions and is clamped to the buffer, so it
59
+ * can never reach past either end; a pass that kept nothing is not padded. A NEGATIVE count is
60
+ * refused by name rather than absorbed into 0 or into the default — the underlying field is
61
+ * unsigned, and a negative one would arrive as an enormous count instead.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const { left, right, report, leftRange, rightRange } = masteringRepairTrimSilenceStereo({
66
+ * left: leftSamples,
67
+ * right: rightSamples,
68
+ * sampleRate: 48000,
69
+ * mode: 'peak',
70
+ * threshold: 0.01,
71
+ * });
72
+ * console.log(left.length, report.removedHeadSamples, leftRange.first, rightRange.first);
73
+ * ```
74
+ */
75
+ export declare function masteringRepairTrimSilenceStereo(request: MasteringRepairTrimSilenceStereoRequest): MasteringRepairTrimSilenceStereoResult;
76
+ export declare function masteringRepairTrimSilenceStereo(left: Float32Array, right: Float32Array, sampleRate: number, config?: TrimSilenceOptions): MasteringRepairTrimSilenceStereoResult;
77
+ /** Request form of `masteringRepairDetectTrimRange`. */
78
+ export interface MasteringRepairDetectTrimRangeRequest extends TrimSilenceOptions {
79
+ samples: Float32Array;
80
+ sampleRate: number;
81
+ }
82
+ /** Request form of `masteringRepairDetectTrimRangeStereo`. */
83
+ export interface MasteringRepairDetectTrimRangeStereoRequest extends TrimSilenceOptions {
84
+ left: Float32Array;
85
+ right: Float32Array;
86
+ sampleRate?: number;
87
+ }
88
+ /**
89
+ * Measures the range {@link masteringRepairTrimSilence} would keep, without trimming.
90
+ *
91
+ * The padding `paddingSamples` asks for is already INSIDE the returned range, so this is the
92
+ * range the repair would cut to rather than the detected extent of the signal. A buffer with
93
+ * nothing above the threshold reports `(length, length)`.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const range = masteringRepairDetectTrimRange({ samples, sampleRate: 48000, threshold: 0.01 });
98
+ * const keptSeconds = (range.lastExclusive - range.first) / 48000;
99
+ * ```
100
+ */
101
+ export declare function masteringRepairDetectTrimRange(request: MasteringRepairDetectTrimRangeRequest): TrimRange;
102
+ export declare function masteringRepairDetectTrimRange(samples: Float32Array, sampleRate: number, options?: TrimSilenceOptions): TrimRange;
103
+ /**
104
+ * Measures the one range a stereo trim pass would cut both channels to.
105
+ *
106
+ * Each channel is scanned on its own and the two ranges are UNIONED, so the pair keeps whatever
107
+ * either channel calls signal. A channel with nothing above the threshold contributes NO EDGE
108
+ * rather than an edge at the buffer's end: the union of a silent channel and an active one is
109
+ * the active channel's range exactly, where a naive `min`/`max` would push `lastExclusive` out
110
+ * to the buffer end and keep the whole tail.
111
+ *
112
+ * A downmix is not read: summing to mono halves material carried by one channel alone and
113
+ * cancels an antiphase pair outright, either of which would read full-level audio as silence.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const range = masteringRepairDetectTrimRangeStereo({ left, right, sampleRate: 48000 });
118
+ * console.log(range.first, range.lastExclusive);
119
+ * ```
120
+ */
121
+ export declare function masteringRepairDetectTrimRangeStereo(request: MasteringRepairDetectTrimRangeStereoRequest): TrimRange;
122
+ export declare function masteringRepairDetectTrimRangeStereo(left: Float32Array, right: Float32Array, sampleRate: number, config?: TrimSilenceOptions): TrimRange;
123
+ //# sourceMappingURL=repair_trim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair_trim.d.ts","sourceRoot":"","sources":["../src/repair_trim.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,sCAAsC,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAM/F,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;AAEnD,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iCAAkC,SAAQ,kBAAkB;IAC3E,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0DAA0D;AAC1D,MAAM,WAAW,uC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oCAAoC,CAClD,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,SAAS,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { SampleDesc, SampleZoneDesc } from './instrument_types';
2
+ /**
3
+ * Host-supplied PCM for the sample synthesis engine: a bank of float samples
4
+ * plus key/velocity keymaps, bound alongside a {@link SynthPatch} whose
5
+ * `engineMode` is `'sample'`.
6
+ *
7
+ * {@link Project.loadSoundFont} is the other door into sampled playback — it
8
+ * parses a container and brings its own generator model. This one takes
9
+ * waveforms a host already has, described by nothing but a keymap, so playing
10
+ * them does not require authoring an SF2. Decoding is the caller's job, and
11
+ * WASM has no host filesystem: the bank takes mono float frames from memory.
12
+ *
13
+ * A bank is built on the control thread and then read as immutable data. Add
14
+ * every sample and zone BEFORE the bounce that binds it starts: the pool is
15
+ * contiguous and moves as it grows, so a sample added while something sounds
16
+ * invalidates the voices reading it.
17
+ *
18
+ * The embind handle is not garbage-collected, so release it with
19
+ * {@link SampleBank.delete} once every bounce that names it has finished.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const bank = new SampleBank();
24
+ * try {
25
+ * const index = bank.addSample(pcm, { rootKey: 60, sourceRate: 44100 });
26
+ * bank.addZone({ sampleIndex: index }); // the whole keyboard
27
+ * const audio = project.bounceWithSynthInstrument(
28
+ * { engineMode: 'sample', sampleSet: 0, sampleBank: bank },
29
+ * { totalFrames: 24000 },
30
+ * );
31
+ * } finally {
32
+ * bank.delete();
33
+ * }
34
+ * ```
35
+ */
36
+ export declare class SampleBank {
37
+ private readonly native;
38
+ private released;
39
+ /**
40
+ * Identity a binding names this bank by, so no raw pointer crosses into JS.
41
+ * Hosts pass the `SampleBank` itself as `sampleBank`.
42
+ *
43
+ * @internal
44
+ */
45
+ readonly nativeId: number;
46
+ /** Create an empty bank. */
47
+ constructor();
48
+ /**
49
+ * Copy mono float frames into the bank and return the new sample's index,
50
+ * which {@link SampleZoneDesc.sampleIndex} names. The frames are copied, so
51
+ * the array may be reused afterwards.
52
+ *
53
+ * Loop points are clamped inside the sample and a loop mode whose loop
54
+ * survives the clamp empty is dropped, so a malformed loop plays as an
55
+ * unlooped sample rather than as a wrap over nothing. An empty array, and a
56
+ * bank that would exceed 67,108,864 sample points, throw.
57
+ *
58
+ * A NaN or Inf frame, `fineTuneCents` or `sourceRate` throws too, and the
59
+ * bank is left unchanged. Such a value is unattributable once stored: the
60
+ * reader's interpolation spreads one bad frame across the whole sustain, and
61
+ * a bad tuning offset renders the voice silent with no error raised.
62
+ */
63
+ addSample(data: Float32Array, desc?: SampleDesc): number;
64
+ /**
65
+ * Append a key/velocity rectangle to a keymap set, creating any sets below
66
+ * it. A patch names a set; the first zone in it covering a note is the one
67
+ * that sounds.
68
+ *
69
+ * Every bound defaults on its own (see {@link SampleZoneDesc}), so an empty
70
+ * rectangle is the whole keyboard at every velocity and narrowing one axis
71
+ * leaves the other whole. A `sampleIndex` the bank does not have, an inverted
72
+ * key or velocity range, and a `setIndex` at or above 4096 all throw.
73
+ */
74
+ addZone(zone?: SampleZoneDesc): void;
75
+ /** Samples added so far. */
76
+ sampleCount(): number;
77
+ /** Keymap sets the bank has (one past the highest index used). */
78
+ setCount(): number;
79
+ /** Release the underlying WASM object. Idempotent, as the Node facade is. */
80
+ delete(): void;
81
+ /** Alias for {@link SampleBank.delete}, provided for cross-binding (Node) compatibility. */
82
+ destroy(): void;
83
+ }
84
+ //# sourceMappingURL=sample_bank.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample_bank.d.ts","sourceRoot":"","sources":["../src/sample_bank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,4BAA4B;;IAM5B;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,GAAE,UAAe,GAAG,MAAM;IAI5D;;;;;;;;;OASG;IACH,OAAO,CAAC,IAAI,GAAE,cAAmB,GAAG,IAAI;IAKxC,4BAA4B;IAC5B,WAAW,IAAI,MAAM;IAIrB,kEAAkE;IAClE,QAAQ,IAAI,MAAM;IAIlB,6EAA6E;IAC7E,MAAM,IAAI,IAAI;IAQd,4FAA4F;IAC5F,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Snap a MIDI value to the nearest pitch class enabled by `modeMask`.
3
+ *
4
+ * `modeMask` is a 12-bit mask. For natural C major use `0b101010110101`.
5
+ * `referenceMidi` defaults to A4 (69) when passed as 0.
6
+ */
7
+ export declare function scaleQuantizeMidi(root: number, modeMask: number, midi: number, referenceMidi?: number): number;
8
+ export declare function scaleCorrectionSemitones(root: number, modeMask: number, midi: number, referenceMidi?: number): number;
9
+ export declare function scalePitchClassEnabled(root: number, modeMask: number, pitchClass: number): boolean;
10
+ //# sourceMappingURL=scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../src/scale.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,aAAa,SAAI,GAChB,MAAM,CAIR;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,aAAa,SAAI,GAChB,MAAM,CAIR;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAET"}