tunelet 0.2.0 → 0.3.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.
@@ -0,0 +1,1279 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * A configuration or MIDI control that applies before a frame in the block.
5
+ *
6
+ * Give controls to a process call as [`TimedEvent`] values. The call borrows
7
+ * the slice only for that call. There is no heap allocation and no deferred
8
+ * queue. A stage event replaces all settings of that stage. To change one
9
+ * field, start from the current configuration of the processor.
10
+ * Configuration changes have the same effects on state as
11
+ * [`crate::Processor::set_config`].
12
+ */
13
+ export type ControlEvent = { type: "configure"; value: ProcessorConfig } | { type: "resynthesis"; value: ResynthesisConfig } | { type: "punch"; value: PunchConfig } | { type: "warm"; value: WarmConfig } | { type: "alien"; value: AlienConfig } | { type: "reverb"; value: ReverbConfig } | { type: "outputGain"; value: number } | { type: "midi"; value: MidiEvent } | { type: "correctionMidi"; value: MidiEvent } | { type: "reset" };
14
+
15
+ /**
16
+ * A control that applies immediately before the zero-based input frame
17
+ * `offset`.
18
+ *
19
+ * Offsets must be less than the current block length. They must not decrease
20
+ * in the event slice. Events with equal offsets execute in slice order. Thus,
21
+ * a later change at the same frame sees the earlier changes. An empty block
22
+ * accepts no events.
23
+ *
24
+ * Offsets are local to this call, not a total count of processed frames.
25
+ * This timing tells when the state changes. Smoothing, the analysis interval
26
+ * and the signal latency also control when the audible result occurs.
27
+ *
28
+ * The processor validates each event before it starts to process the block.
29
+ * If one event is not valid, the processor rejects the full block. This
30
+ * includes the valid events that are earlier in the slice.
31
+ */
32
+ export interface TimedEvent {
33
+ /**
34
+ * The frame offset in the block.
35
+ */
36
+ offset: number;
37
+ /**
38
+ * The control change.
39
+ */
40
+ event: ControlEvent;
41
+ }
42
+
43
+ /**
44
+ * A diatonic chord with its root on a degree of the selected
45
+ * [`HarmonyScale`].
46
+ *
47
+ * Triads use the root, third and fifth scale degrees. Seventh chords also
48
+ * use the seventh. Degrees above the seventh go into higher octaves. The
49
+ * degree names do not set a major or minor quality. The selected scale
50
+ * supplies the tones. The default is the tonic triad, [`Self::I`].
51
+ */
52
+ export type ChordDegree = "i" | "ii" | "iiSeventh" | "iii" | "iiiSeventh" | "iv" | "ivSeventh" | "v" | "vSeventh" | "vi" | "viSeventh" | "vii" | "viiSeventh";
53
+
54
+ /**
55
+ * A named chord for [`HarmonySource::ChordByName`].
56
+ *
57
+ * Each variant lists the semitones above the root. These values do not
58
+ * include the inversion, the key transposition, the register or the voicing
59
+ * spread. Triads use three voices.
60
+ */
61
+ export type ChordName = "major" | "majorSixth" | "majorSeventh" | "majorSeventhSuspendedFourth" | "minor" | "minorSixth" | "minorSeventh" | "minorSeventhFlatFifth" | "diminished" | "diminishedSeventh" | "dominantSeventh" | "dominantSeventhFlatFifth" | "augmented" | "augmentedSeventh" | "suspendedFourth" | "suspendedSecond" | "suspendedSeventh";
62
+
63
+ /**
64
+ * A scale for [`NoteMask::from_key_scale`].
65
+ */
66
+ export type CorrectionScale = "major" | "minor" | "chromatic";
67
+
68
+ /**
69
+ * A snapshot of the pitch analysis and the output level that you can copy.
70
+ *
71
+ * Get it with [`Processor::feedback`] or [`Processor::take_feedback`]. The
72
+ * pitch fields describe the tracked input and the correction target. The
73
+ * peak measures the final clipped stereo output. `Default` gives a snapshot
74
+ * with all zeros and no target. It does not read the nominal latency of a
75
+ * prepared processor.
76
+ */
77
+ export interface Feedback {
78
+ /**
79
+ * The pitch-correction ratio from the last processed frame, where 1 is
80
+ * unity.
81
+ *
82
+ * It does not include the configured pitch shift or the ratios of
83
+ * individual voices. It is zero before processing, after a reset or after
84
+ * a change of stereo output.
85
+ */
86
+ resampleRatio: number;
87
+ /**
88
+ * The reported input pitch period in samples, with fractional samples.
89
+ *
90
+ * It is zero if the input is unvoiced or outside the reporting bounds of
91
+ * [`crate::PitchConfig`].
92
+ */
93
+ periodSamples: number;
94
+ /**
95
+ * The reported input pitch frequency in hertz.
96
+ *
97
+ * The value comes from the sample rate and the current tracked period.
98
+ * It is zero if the estimate is not reported.
99
+ */
100
+ frequencyHz: number;
101
+ /**
102
+ * The correction target or the input pitch, as a MIDI note number.
103
+ *
104
+ * The value is the selected correction pitch class if all of these
105
+ * conditions are true:
106
+ *
107
+ * - Correction is enabled.
108
+ * - The active note table is not empty.
109
+ * - A tracking update selected a target after the last table change,
110
+ * reset or tracking restart.
111
+ *
112
+ * The pitch class is in the octave nearest to the reported input. In
113
+ * other cases, the value is the input pitch as a fractional MIDI note. It
114
+ * is not the final pitch of shifted output or harmony output.
115
+ *
116
+ * The value is `None` if [`voiced`](Self::voiced) is `false`, and only
117
+ * then. This occurs if the input is unvoiced or if its frequency is
118
+ * outside the current reporting bounds. A target table that has no
119
+ * selected target does not give `None`.
120
+ */
121
+ targetMidiNote: number | undefined;
122
+ /**
123
+ * This field is `true` if the current pitch estimate is positive and
124
+ * inside the current reporting bounds.
125
+ *
126
+ * This is not an amplitude gate or a confidence score. A tracking result
127
+ * can stay between detector updates.
128
+ */
129
+ voiced: boolean;
130
+ /**
131
+ * The largest absolute clipped stereo sample, divided by 32768.
132
+ *
133
+ * The peak window starts at construction, at a reset, at a change of
134
+ * stereo output or at a call to [`Processor::take_feedback`]. The value
135
+ * is in 0..=32767/32768. The mono downmix occurs after this measurement.
136
+ * [`Processor::feedback`] does not clear the value.
137
+ */
138
+ peakLevel: number;
139
+ /**
140
+ * The number of frames processed since construction or the last reset,
141
+ * with drain frames included.
142
+ *
143
+ * The count saturates at `u64::MAX`. Drain completion resets it in the
144
+ * last drain call.
145
+ */
146
+ processedFrames: bigint;
147
+ /**
148
+ * The nominal resynthesis latency, as [`Processor::latency_frames`] gives.
149
+ */
150
+ latencyFrames: number;
151
+ }
152
+
153
+ /**
154
+ * A snapshot of the voices, the levels and the effect state that you can
155
+ * copy.
156
+ *
157
+ * Get it with [`Processor::telemetry`] or [`Processor::take_telemetry`]. The
158
+ * telemetry is for meters and displays. No audio calculation reads it.
159
+ * `Default` gives a snapshot with all zeros.
160
+ *
161
+ * The three peak fields measure a window. The window starts at
162
+ * construction, at a reset, at a change of stereo output or at a call to
163
+ * [`Processor::take_telemetry`]. This window is independent of the peak
164
+ * window of [`Feedback`].
165
+ */
166
+ export interface Telemetry {
167
+ /**
168
+ * The number of frames processed since construction or the last reset,
169
+ * as [`Feedback::processed_frames`] gives.
170
+ */
171
+ processedFrames: bigint;
172
+ /**
173
+ * The largest absolute input sample in the window, divided by 32768.
174
+ *
175
+ * The measurement is before Punch and Warm. The value is in 0..=1.
176
+ */
177
+ inputPeak: number;
178
+ /**
179
+ * The largest absolute clipped sample of the left and the right output
180
+ * in the window, divided by 32768.
181
+ *
182
+ * The measurement is after the output gain. Each value is in
183
+ * 0..=32767/32768.
184
+ */
185
+ outputPeak: [number, number];
186
+ /**
187
+ * The largest absolute wet contribution of the reverb in the window,
188
+ * where 1 is full scale.
189
+ *
190
+ * The contribution is the wet signal times the mix, before the output
191
+ * gain. It is the larger of the two channels. While the reverb is
192
+ * disabled, the window gets no new values.
193
+ */
194
+ reverbWetPeak: number;
195
+ /**
196
+ * How periodic the tracked input is, in 0..=1.
197
+ *
198
+ * The value is 1 for a signal that repeats exactly at the tracked
199
+ * period. It is 0 for a signal with no relation between cycles and
200
+ * during pitch acquisition. Use it as a confidence score for
201
+ * [`Feedback::voiced`]. The tracker updates the related sums on each
202
+ * frame.
203
+ */
204
+ clarity: number;
205
+ /**
206
+ * This field is `true` if the pitch tracker follows a period. It is
207
+ * `false` during pitch acquisition.
208
+ */
209
+ tracking: boolean;
210
+ /**
211
+ * The number of valid entries in [`voice_ratios`](Self::voice_ratios)
212
+ * and [`voice_gains`](Self::voice_gains).
213
+ *
214
+ * The value is 5 in Harmony mode. In Choir mode, it is
215
+ * [`crate::ResynthesisConfig::choir_voices`], in 1..=16.
216
+ */
217
+ voiceCount: number;
218
+ /**
219
+ * The pitch ratio of each voice on the last frame, where 1 is the input
220
+ * pitch.
221
+ *
222
+ * Entry zero is the lead voice. In Harmony mode, entries 1 to 4 are the
223
+ * harmony voices. In Choir mode, the entries after the lead are the
224
+ * secondary voices. Each ratio includes the correction, the configured
225
+ * pitch shift and the ratio of the voice. The entries after
226
+ * [`voice_count`](Self::voice_count) are zero.
227
+ */
228
+ voiceRatios: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
229
+ /**
230
+ * The linear gain of each voice, in the order of
231
+ * [`voice_ratios`](Self::voice_ratios).
232
+ *
233
+ * The lead and the choir voices have a gain of 1. The gain of a harmony
234
+ * voice includes the MIDI velocity gain, in 0..=3.98095703125. MIDI
235
+ * velocity 127 gives the maximum, approximately +12 dB. The gain is zero
236
+ * for a voice that does not sound. It does not include the configured
237
+ * harmony level or the pan. The harmony controller updates it every 101
238
+ * frames.
239
+ */
240
+ voiceGains: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
241
+ /**
242
+ * The current drive of Punch, divided by its base drive.
243
+ *
244
+ * The value is the ratio of the two input envelopes times the
245
+ * configured input gain. It is more than 1 at an attack. Punch updates
246
+ * it every 100 frames. The value is 1 while Punch is disabled.
247
+ */
248
+ punchGain: number;
249
+ /**
250
+ * The linear gain that Warm applies before its saturation curve and
251
+ * removes after it.
252
+ *
253
+ * The value is the inverse of the input peak envelope. For input below
254
+ * -30 dB, it is the gain of +30 dB. Warm updates it every 100 frames.
255
+ * The value is 1 while Warm is disabled.
256
+ */
257
+ warmGain: number;
258
+ /**
259
+ * The length of the Alien loop in frames, as
260
+ * [`crate::AlienConfig::loop_frames`] gives.
261
+ */
262
+ alienLoopFrames: number;
263
+ /**
264
+ * The current frame in the Alien loop. It is less than
265
+ * [`alien_loop_frames`](Self::alien_loop_frames).
266
+ *
267
+ * The reverse reader is two times this number of frames behind the
268
+ * recording position. The value advances also while Alien is disabled.
269
+ */
270
+ alienPhaseFrames: number;
271
+ /**
272
+ * The wrapping count of formant analyses since construction.
273
+ *
274
+ * The count increases every 441 frames while the formant stage is
275
+ * enabled. Compare two values to find if
276
+ * [`Processor::formant_envelope`] can give a new result.
277
+ */
278
+ formantGeneration: number;
279
+ }
280
+
281
+ /**
282
+ * Asymmetric input saturation, followed by a 50 Hz high-pass filter.
283
+ *
284
+ * Warm operates after Punch and before pitch detection. Its adaptive
285
+ * normalization updates every 100 enabled frames. When Warm is disabled,
286
+ * the envelope and filter histories do not change. When Warm is enabled
287
+ * again, they continue from their last state, unless the processor was
288
+ * reset.
289
+ */
290
+ export interface WarmConfig {
291
+ /**
292
+ * Enables the saturation stage. The default is `false`.
293
+ */
294
+ enabled: boolean;
295
+ /**
296
+ * The drive in decibels, 0..=6. The default is 3 dB.
297
+ * The output gain changes by -0.35 dB for each dB of drive. At 0 dB, the
298
+ * envelope normalization and the output high-pass filter still operate.
299
+ */
300
+ driveDb: number;
301
+ }
302
+
303
+ /**
304
+ * One of the twelve notes in an octave.
305
+ */
306
+ export type PitchClass = "c" | "cSharp" | "d" | "dSharp" | "e" | "f" | "fSharp" | "g" | "gSharp" | "a" | "aSharp" | "b";
307
+
308
+ /**
309
+ * Reverse playback of recent stereo audio in repeated loops with fades.
310
+ *
311
+ * Alien comes after resynthesis. Its input history and loop phase advance
312
+ * also when Alien is disabled. Thus, when you enable Alien, it can play
313
+ * audio that it recorded during bypass. A change of the loop length keeps
314
+ * the history and clamps the current phase into the new loop. The boundary
315
+ * fades are 200 frames long at all sample rates.
316
+ */
317
+ export interface AlienConfig {
318
+ /**
319
+ * Selects reversed playback instead of the direct input. The default is
320
+ * `false`. The recording and the phase continue to advance in both
321
+ * states.
322
+ */
323
+ enabled: boolean;
324
+ /**
325
+ * The loop length in frames, 1..=96000. The default is 95,999.
326
+ * This value is a frame count at the two rates. Thus, its duration in
327
+ * seconds changes with the sample rate. A short loop can be fully inside
328
+ * the fades.
329
+ */
330
+ loopFrames: number;
331
+ }
332
+
333
+ /**
334
+ * The acquisition sensitivity and the bounds for pitch reports to the host.
335
+ */
336
+ export interface PitchConfig {
337
+ /**
338
+ * The normalized cycle-difference threshold for acquisition, 0.002..=0.2.
339
+ *
340
+ * The default is 0.1. Larger values accept less exact cycle agreement.
341
+ * This value controls acquisition. It is not an output gain or an
342
+ * amplitude gate.
343
+ */
344
+ threshold: number;
345
+ /**
346
+ * The lower bound of the feedback in hertz (inclusive), 40..=2000.
347
+ *
348
+ * The default is 40. It must be strictly less than `max_frequency_hz`.
349
+ * These bounds do not change the tracking, the correction or the
350
+ * resampling. A feedback query applies the current bounds to the kept
351
+ * analysis. It does not process another sample.
352
+ */
353
+ minFrequencyHz: number;
354
+ /**
355
+ * The upper bound of the feedback in hertz (inclusive), 40..=2000.
356
+ *
357
+ * The default is 1100. It must be strictly greater than
358
+ * `min_frequency_hz`. Results outside the bounds are reported as
359
+ * unvoiced, with zero frequency and zero period.
360
+ */
361
+ maxFrequencyHz: number;
362
+ }
363
+
364
+ /**
365
+ * The chord inversion raises the lowest chord tones by one octave.
366
+ *
367
+ * The inversion applies before the register and the spread. It applies
368
+ * only to named chords and degree chords. Root position is the default.
369
+ * The first inversion moves one tone and the second inversion moves two
370
+ * tones. The voicing of MIDI chords uses the played notes, not this control.
371
+ */
372
+ export type Inversion = "root" | "first" | "second";
373
+
374
+ /**
375
+ * The configuration of four harmony voices that follow intervals, chords or
376
+ * MIDI.
377
+ *
378
+ * Positive intervals make the pitch higher. The defaults are:
379
+ *
380
+ * - MIDI channels 0..=3 as the source.
381
+ * - The key of C and the major scale.
382
+ * - Unison intervals.
383
+ * - A tonic major chord in root position.
384
+ * - A register of 50%.
385
+ * - A closed voicing and zero portamento.
386
+ * - Four voices for the interval sources.
387
+ *
388
+ * These settings configure all sources. Only the fields for the selected
389
+ * source change the target notes. Validation always checks all fields.
390
+ *
391
+ * Harmony makes its voices from the tracked input. MIDI controls the pitch
392
+ * and the gain. It is not an independent oscillator. The gain in decibels
393
+ * is linear in the velocity: velocities 1..=127 give approximately -23.72
394
+ * to +12 dB. A velocity of zero releases the note.
395
+ *
396
+ * The gain attack, the gain release and the period portamento advance at
397
+ * the controller cadence. This cadence is usually every 101 frames. A MIDI
398
+ * event can make the next control step occur sooner. The envelopes and the
399
+ * portamento advance only while the input is voiced.
400
+ */
401
+ export interface HarmonyConfig {
402
+ /**
403
+ * The pitch source. The default is [`HarmonySource::MidiChannels`].
404
+ */
405
+ source: HarmonySource;
406
+ /**
407
+ * The pitch class of the tonic. The default is C. Smart intervals, named
408
+ * chords and degree chords use it. It does not transpose direct MIDI
409
+ * notes.
410
+ */
411
+ key: PitchClass;
412
+ /**
413
+ * The scale for smart intervals and degree chords. The default is major.
414
+ */
415
+ scale: HarmonyScale;
416
+ /**
417
+ * Four fixed semitone offsets, each in -24..=24. The default is all
418
+ * zeros. [`HarmonySource::FixedInterval`] uses them. A value of 12 makes
419
+ * the pitch one octave higher.
420
+ */
421
+ chromaticIntervals: [number, number, number, number];
422
+ /**
423
+ * Four offsets in scale steps, each in -14..=14. The default is all
424
+ * zeros. [`HarmonySource::SmartInterval`] uses them. Seven steps make
425
+ * the pitch one octave higher.
426
+ */
427
+ diatonicIntervals: [number, number, number, number];
428
+ /**
429
+ * The named chord for [`HarmonySource::ChordByName`]. The default is
430
+ * major.
431
+ */
432
+ chord: ChordName;
433
+ /**
434
+ * The chord on a scale degree for [`HarmonySource::ChordByDegree`]. The
435
+ * default is I.
436
+ */
437
+ degree: ChordDegree;
438
+ /**
439
+ * The inversion for named chords and degree chords. The default is root
440
+ * position.
441
+ */
442
+ inversion: Inversion;
443
+ /**
444
+ * The chord register from low to high, 0..=100%.
445
+ *
446
+ * The default is 50%. All chord sources use it, which includes MIDI chords.
447
+ * The value is truncated to a whole percentage before it selects the
448
+ * octave shift.
449
+ */
450
+ registerPercent: number;
451
+ /**
452
+ * The chord voicing from close to open, 0..=100%.
453
+ *
454
+ * The default is 0%. All chord sources use it. The value is truncated to a
455
+ * whole percentage. The result selects discrete octave positions, not
456
+ * continuous detuning.
457
+ */
458
+ voicingSpreadPercent: number;
459
+ /**
460
+ * The half-life of the target-period smoothing in milliseconds,
461
+ * 0..=10000. The default is 0. The smoothing applies at each control
462
+ * step. The coefficient assumes 100 frames for each step. At the usual
463
+ * cadence of 101 frames, the half-life is approximately 1% longer. If
464
+ * the value is zero, the voice uses the target period immediately. The
465
+ * gain envelopes still apply. A note on a free voice can start without
466
+ * a glide. In the interval sources, if the input moves more than one
467
+ * semitone bin, each voice starts at its new target without a glide.
468
+ */
469
+ portamentoMs: number;
470
+ /**
471
+ * The number of voices that sound in the interval sources, 0..=4.
472
+ *
473
+ * The default is 4. [`HarmonySource::FixedInterval`] and
474
+ * [`HarmonySource::SmartInterval`] use the first `voices` voices. The
475
+ * other voices release with the usual gain envelope. The chord and MIDI
476
+ * sources ignore this field. In JavaScript, the field is optional and
477
+ * a missing value gives the default.
478
+ */
479
+ voices?: number;
480
+ }
481
+
482
+ /**
483
+ * The controls for pitch correction, pitch shift, voice arrangement and
484
+ * formants.
485
+ *
486
+ * The defaults render one choir voice with these settings:
487
+ * - Chromatic correction.
488
+ * - A pitch shift of 1.0.
489
+ * - Disabled formants.
490
+ * - No harmonic modulation.
491
+ * - No dry mix.
492
+ * - No stereo pan.
493
+ *
494
+ * Validation applies to all controls, also when their stage or voice mode
495
+ * is not active.
496
+ *
497
+ * The dry path takes the audio after Punch and Warm and delays it by 1,543
498
+ * frames. The wet voice readers have more delay, which changes with the
499
+ * pitch. After this stage, the two paths go through Alien, reverb and the
500
+ * final output gain.
501
+ */
502
+ export interface ResynthesisConfig {
503
+ /**
504
+ * The acquisition sensitivity and the reporting bounds. The
505
+ * default is [`PitchConfig::default`].
506
+ */
507
+ pitch: PitchConfig;
508
+ /**
509
+ * The target notes and the retune time. The default is enabled
510
+ * chromatic correction with a retune time of zero.
511
+ */
512
+ correction: CorrectionConfig;
513
+ /**
514
+ * The pitch multiplier, 0.25..=4. The default is 1.
515
+ *
516
+ * A value of 0.5 lowers the pitch by one octave. A value of 2 raises the
517
+ * pitch by one octave. This value multiplies the correction ratio and
518
+ * the ratio of each voice. A value above 1 also enables the anti-alias
519
+ * low-pass filters.
520
+ */
521
+ pitchRatio: number;
522
+ /**
523
+ * The vocal-tract changes and aspiration. They are disabled by default.
524
+ */
525
+ formant: FormantConfig;
526
+ /**
527
+ * The voice arrangement. The default is [`MultiVoiceMode::Choir`].
528
+ *
529
+ * Harmony renders the lead voice and a maximum of four harmony voices.
530
+ */
531
+ mode: MultiVoiceMode;
532
+ /**
533
+ * The total number of choir voices, with the lead voice, 1..=16. The
534
+ * default is 1.
535
+ *
536
+ * The other voices read the delayed lead history with random pitch
537
+ * drift. The code adds the voices and does not divide the sum by the
538
+ * number of voices. Thus, more voices can increase the output level and
539
+ * the clipping. Harmony does not use this value.
540
+ */
541
+ choirVoices: number;
542
+ /**
543
+ * The drift control for secondary voices, 10..=100, without a unit. The
544
+ * default is 50.
545
+ *
546
+ * The unit is not cents. The lead voice has no random choir drift. Thus,
547
+ * a choir with one voice does not get this detune.
548
+ */
549
+ choirDetune: number;
550
+ /**
551
+ * The scale of the choir delay table, 20..=200, without a unit. The
552
+ * default is 60.
553
+ *
554
+ * A value of 200 uses the full fixed table of frame offsets. The unit is
555
+ * not milliseconds. The table offset of the lead voice is zero at all
556
+ * settings.
557
+ */
558
+ choirDelay: number;
559
+ /**
560
+ * The stereo width of the choir, 0..=100%. The default is 100%.
561
+ *
562
+ * The code uses this value only if `stereo_output` enables the voice pan
563
+ * and the choir has more than one voice.
564
+ */
565
+ choirSpreadPercent: number;
566
+ /**
567
+ * Enables a stereo pan for each voice. The default is `false`.
568
+ *
569
+ * This value is independent of the buffer layout of the process method.
570
+ * A change to this value resets some audio histories and the feedback.
571
+ * [`crate::Processor::set_config`] gives the details.
572
+ */
573
+ stereoOutput: boolean;
574
+ /**
575
+ * The controls for the four harmony voices. The default is MIDI-channel
576
+ * allocation.
577
+ *
578
+ * Validation applies to these controls, and they can receive MIDI, also
579
+ * while Choir is selected.
580
+ */
581
+ harmony: HarmonyConfig;
582
+ /**
583
+ * The linear gain of the four harmony voices, 0..=1. The default is 0.5.
584
+ *
585
+ * If `stereo_output` is `true`, the stereo pan gains include this gain.
586
+ * If `stereo_output` is `false`, this gain scales each harmony voice
587
+ * directly. It does not scale the lead voice.
588
+ */
589
+ harmonyGain: number;
590
+ /**
591
+ * The modulation depth, 0..=24, without a unit. The default is 0 (off).
592
+ *
593
+ * The code multiplies the control by two and truncates it to an integer.
594
+ * Then it uses the result for a cosine modulation after the wet voices
595
+ * are mixed. The value is not an interval in semitones.
596
+ */
597
+ harmonicModulation: number;
598
+ /**
599
+ * The dry fraction at the resynthesis stage, 0..=1. The default is 0.
600
+ *
601
+ * The code truncates this value to Q8. The wet weight is 1.0 minus the
602
+ * Q8 dry weight. The dry path starts after Punch and Warm and has a
603
+ * delay of 1,543 frames. Alien, reverb and the output gain still occur
604
+ * after this stage.
605
+ */
606
+ dryMix: number;
607
+ /**
608
+ * The seed for choir drift and aspiration, which use the same stream.
609
+ * The default is `0x1234_abcd`.
610
+ *
611
+ * Only the low 32 bits select the sequence. If a configuration change
612
+ * gives a different 64-bit value, the processor starts the stream again
613
+ * from the low 32 bits. This is also true for a change to only the high
614
+ * bits. Reset keeps the current position in the stream. The enabled
615
+ * stages set the number of random values that the code reads.
616
+ */
617
+ randomSeed: bigint;
618
+ }
619
+
620
+ /**
621
+ * The controls for pitch-class correction, with target selection in the
622
+ * period domain.
623
+ *
624
+ * Correction is enabled by default, with all chromatic notes and a retune
625
+ * time of zero. Target selection and the smoothing of the correction ratio
626
+ * occur at each update of the pitch tracking. When a period is tracked,
627
+ * this update usually occurs every five frames. If the active note table is
628
+ * empty or correction is disabled, the ratio moves toward 1.0 at the same
629
+ * rate.
630
+ *
631
+ * Correction MIDI replaces the active note table. It does not change this
632
+ * configuration. A change to `notes` or to `enabled` loads the configured
633
+ * mask again. Reset releases the correction keys 0..=126. It keeps key 127
634
+ * and the active note table. Key 127 has no effect on the note table.
635
+ *
636
+ * At construction, the chromatic table uses 44.1 kHz periods, also for a
637
+ * 48 kHz processor. Each of these events loads the periods for the prepared
638
+ * rate:
639
+ * - An initial mask that is not chromatic.
640
+ * - A later change to the mask or to `enabled`.
641
+ * - A correction MIDI event.
642
+ */
643
+ export interface CorrectionConfig {
644
+ /**
645
+ * Enables the selection of correction targets. The default is `true`.
646
+ *
647
+ * If you disable correction, the ratio moves toward 1.0 with `retune_ms`
648
+ * at the next tracking updates. The ratio does not change to 1.0
649
+ * immediately.
650
+ */
651
+ enabled: boolean;
652
+ /**
653
+ * The configured target pitch classes. The default is
654
+ * [`NoteMask::CHROMATIC`].
655
+ *
656
+ * All boolean masks are valid. MIDI can replace the active table. This
657
+ * replacement stays until this mask or `enabled` changes.
658
+ */
659
+ notes: NoteMask;
660
+ /**
661
+ * The half-life of the smoothing in milliseconds, 0..=400. The default
662
+ * is 0.
663
+ *
664
+ * If the value is zero, the ratio changes to the target at the next
665
+ * tracking update. A value that is not zero is a half-life. It is not a
666
+ * fixed time to get exactly to the target.
667
+ */
668
+ retuneMs: number;
669
+ }
670
+
671
+ /**
672
+ * The controls for vocal-tract changes and synthesized aspiration during
673
+ * resynthesis.
674
+ *
675
+ * This stage is disabled by default. If it is enabled, it does these steps:
676
+ * 1. It estimates an LPC model.
677
+ * 2. It removes the spectral envelope of the input.
678
+ * 3. It applies a changed model to the resampled audio.
679
+ *
680
+ * If width and stretch are 1, the model dimensions do not change. But the
681
+ * fixed-point analysis and synthesis path does not give a bit-identical
682
+ * copy of the input. Aspiration occurs only if the formant path is enabled.
683
+ */
684
+ export interface FormantConfig {
685
+ /**
686
+ * Enables formant analysis and synthesis. The default is `false`.
687
+ */
688
+ enabled: boolean;
689
+ /**
690
+ * The vocal-tract width factor, 0.5..=2. The default is 1.
691
+ *
692
+ * The square of the width scales the estimated tract areas. The width
693
+ * also scales the amplitude of the synthesized output.
694
+ */
695
+ width: number;
696
+ /**
697
+ * The vocal-tract length factor, 0.5..=2. The default is 1.
698
+ *
699
+ * It controls the interpolation of the area model and thus the filter
700
+ * order.
701
+ */
702
+ stretch: number;
703
+ /**
704
+ * The aspiration level, 0..=1, without a unit. The default is 0.
705
+ *
706
+ * If the value is 0.01 or less, the stage makes no noise. Active
707
+ * aspiration follows the signal amplitude. It uses the random stream of
708
+ * the processor, together with other stages. During each drain call,
709
+ * the processor sets the aspiration to zero. The configuration that the
710
+ * host sees does not change.
711
+ */
712
+ aspirationMix: number;
713
+ /**
714
+ * The high-pass cutoff for aspiration in hertz, 500..=10000. The default
715
+ * is 4000.
716
+ *
717
+ * The stage limits the cutoff to 0.48 × sample rate and truncates it to
718
+ * whole hertz. A change to this value updates the coefficients. The
719
+ * filter history does not change.
720
+ */
721
+ aspirationCutoffHz: number;
722
+ }
723
+
724
+ /**
725
+ * The echo or reverberation network. The default is [`Self::Echo`].
726
+ *
727
+ * All modes share one delay buffer. A mode change uses the same buffer
728
+ * contents and damping filter memories. Thus a transition can play audio
729
+ * from the previous network. The stereo layout of the buffer does not make
730
+ * all modes give different left and right signals. Schroeder gives the same
731
+ * value on the two channels.
732
+ */
733
+ export type ReverbMode = "echo" | "schroeder" | "smallRoom" | "binaural" | "mediumHall" | "largeHall";
734
+
735
+ /**
736
+ * The events for one call that processes audio (`TimedEvent[]` in TypeScript).
737
+ *
738
+ * Each offset is a zero-based frame index in the current block. Each offset
739
+ * must be in the block and must not be less than the offset before it. Events
740
+ * with equal offsets execute in array order. An empty block accepts no
741
+ * events. If there are no events, omit the optional argument. Then the
742
+ * binding does not decode an array.
743
+ */
744
+ export type BlockEvents = TimedEvent[];
745
+
746
+ /**
747
+ * The input gain and the transient enhancement with arctangent saturation.
748
+ *
749
+ * Punch comes before Warm and before pitch detection. It finds the peak of
750
+ * each window of 100 processed frames. Two envelope followers set the drive
751
+ * from these peaks. When Punch is disabled, it does not process audio, and
752
+ * its envelope and window state do not change.
753
+ *
754
+ * A gain change updates the cached drive at the next boundary of the peak
755
+ * window. A reset calculates that drive again immediately from the
756
+ * configured gain.
757
+ */
758
+ export interface PunchConfig {
759
+ /**
760
+ * Enables this input stage. The default is `false`.
761
+ */
762
+ enabled: boolean;
763
+ /**
764
+ * The input gain in decibels, -96..=12.
765
+ *
766
+ * The default is 0 dB. The saturation drive from this gain changes at the
767
+ * next 100-frame peak boundary.
768
+ */
769
+ gainDb: number;
770
+ /**
771
+ * The transient emphasis without a unit, 0..=1.
772
+ *
773
+ * The default is 0.5. It sets the release half-life of the adaptive
774
+ * follower: 5000 ms at 0, 250 ms at 0.5 and 1 ms at 1. The attack uses
775
+ * `attack_ms`.
776
+ */
777
+ impact: number;
778
+ /**
779
+ * The output ceiling of the saturation in dBFS, -96..=0.
780
+ *
781
+ * The default is -3 dBFS. Later stages and the final gain can make the
782
+ * final output higher than this level.
783
+ */
784
+ ceilingDb: number;
785
+ /**
786
+ * The attack half-life of the peak follower in milliseconds, 0.01..=5000.
787
+ *
788
+ * The default is 10 ms. The coefficients include the effect of the
789
+ * 100-frame update interval.
790
+ */
791
+ attackMs: number;
792
+ }
793
+
794
+ /**
795
+ * The method that resynthesis uses to render its voices.
796
+ */
797
+ export type MultiVoiceMode = "choir" | "harmony";
798
+
799
+ /**
800
+ * The permitted correction pitch classes, in the order C, C♯, D, D♯, E, F,
801
+ * F♯, G, G♯, A, A♯, B.
802
+ *
803
+ * A `true` flag enables that pitch class in all octaves.
804
+ *
805
+ * The default is [`Self::CHROMATIC`]. All combinations of flags are valid.
806
+ * This includes [`Self::NONE`]. If the mask is empty, the correction ratio
807
+ * moves toward unity with the configured retune half-life. An empty mask
808
+ * does not clear the histories.
809
+ */
810
+ export type NoteMask = [boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean];
811
+
812
+ /**
813
+ * The reverb after Alien, with controls for the network, the wet mix and the
814
+ * decay.
815
+ *
816
+ * The reverb is disabled by default. In bypass, the stage returns the input
817
+ * and does not advance the delay network or the damping filters. If the
818
+ * stage is enabled and the mix is zero, the network still operates. A reset
819
+ * clears the delay buffer but keeps the memories of the damping filters. The
820
+ * mix, diffusion and decay controls are quantized to Q14. The function of
821
+ * each control changes with the network.
822
+ */
823
+ export interface ReverbConfig {
824
+ /**
825
+ * Enables the selected network. The default is `false`. In bypass, the
826
+ * histories do not change.
827
+ */
828
+ enabled: boolean;
829
+ /**
830
+ * The topology of the delay network. The default is
831
+ * [`ReverbMode::Echo`].
832
+ */
833
+ mode: ReverbMode;
834
+ /**
835
+ * The wet fraction, 0..=1.
836
+ *
837
+ * The default is 0.5. The dry weight is `1 - mix`. Schroeder and Binaural
838
+ * use a mono dry signal. The other modes keep the stereo dry input. If
839
+ * the network is enabled, a zero mix still advances it.
840
+ */
841
+ mix: number;
842
+ /**
843
+ * The diffusion control without a unit, 0..=1.
844
+ *
845
+ * The default is 0.5. MediumHall and LargeHall scale their allpass
846
+ * coefficients with it. Binaural uses it as the gain of its early taps.
847
+ * In Echo, it sets the distance of the feedback tap. Schroeder and
848
+ * SmallRoom do not use it.
849
+ */
850
+ diffusion: number;
851
+ /**
852
+ * The feedback control without a unit, 0..=1.
853
+ *
854
+ * The default is 0.6. The prepared coefficient is approximately
855
+ * `decay / 1.05`. It is less than unity also at the maximum. This value
856
+ * is not a decay time in seconds. Some paths also use fixed feedback
857
+ * coefficients. Binaural does not use this control.
858
+ */
859
+ decay: number;
860
+ /**
861
+ * The low-pass cutoff in hertz for networks with damped paths, 80..=20000.
862
+ *
863
+ * The default is 4000 Hz. The preparation also limits it to 0.49 ×
864
+ * sample rate. A change of the cutoff keeps the sample histories of the
865
+ * filters.
866
+ */
867
+ brightnessHz: number;
868
+ }
869
+
870
+ /**
871
+ * The scale that smart intervals and chords by degree use.
872
+ */
873
+ export type HarmonyScale = "major" | "majorWithoutSeventh" | "majorFlatSeventh" | "minor" | "harmonicMinor" | "minorNaturalSixth" | "minorMajorSeventh";
874
+
875
+ /**
876
+ * The settings for the complete signal chain, in the order of the stages.
877
+ *
878
+ * The default enables chromatic pitch correction, one choir voice and unity
879
+ * output gain. Punch, Warm, formants, Alien and reverb are disabled. This
880
+ * configuration does active pitch processing. It is not a bypass with zero
881
+ * latency.
882
+ *
883
+ * Change a copy, then apply it with [`crate::Processor::set_config`] or
884
+ * [`crate::ControlEvent::Configure`]. The validation examines all fields
885
+ * before a change has an effect. This includes the fields of disabled stages.
886
+ */
887
+ export interface ProcessorConfig {
888
+ /**
889
+ * The input dynamics and saturation stage, which applies first.
890
+ *
891
+ * It is disabled by default.
892
+ */
893
+ punch: PunchConfig;
894
+ /**
895
+ * The asymmetric saturation stage after Punch.
896
+ *
897
+ * It is disabled by default.
898
+ */
899
+ warm: WarmConfig;
900
+ /**
901
+ * The stage for pitch tracking, correction, voice resynthesis and
902
+ * formant control.
903
+ *
904
+ * The default is [`ResynthesisConfig::default`].
905
+ */
906
+ resynthesis: ResynthesisConfig;
907
+ /**
908
+ * The reverse-loop effect after resynthesis.
909
+ *
910
+ * It is disabled by default.
911
+ */
912
+ alien: AlienConfig;
913
+ /**
914
+ * The echo or reverberation stage after Alien.
915
+ *
916
+ * It is disabled by default.
917
+ */
918
+ reverb: ReverbConfig;
919
+ /**
920
+ * The linear gain after all effects, 0..=64.
921
+ *
922
+ * The default is 1 (unity). Zero mutes the output, but the internal
923
+ * processing continues. The gain is quantized in steps of 1/256 before
924
+ * the fixed-point multiplication and the final PCM clipping. Thus, a
925
+ * positive value below 1/256 also mutes the output.
926
+ */
927
+ outputGain: number;
928
+ }
929
+
930
+ /**
931
+ * The source of target periods for the four harmony voices.
932
+ *
933
+ * The default is [`Self::MidiChannels`]. The static interval and chord
934
+ * sources use the related [`HarmonyConfig`] fields. The MIDI sources use
935
+ * [`crate::ControlEvent::Midi`]. The configuration of the sources that are
936
+ * not selected is still validated and kept.
937
+ */
938
+ export type HarmonySource = "fixedInterval" | "smartInterval" | "chordByDegree" | "chordByName" | "chordViaMidi" | "midiOmni" | "midiChannels";
939
+
940
+ /**
941
+ * The supported MIDI note controls, with zero-based channel numbers.
942
+ *
943
+ * Use [`crate::ControlEvent::Midi`] for harmony. Use
944
+ * [`crate::ControlEvent::CorrectionMidi`] for the independent correction
945
+ * keyboard. The typed representation can contain `u8` values that are not
946
+ * valid. [`Self::validate`] and the event preflight of the processor check
947
+ * the MIDI ranges. Note numbers use A4 = 69 at 440 Hz.
948
+ */
949
+ export type MidiEvent = { type: "noteOn"; channel: number; note: number; velocity: number } | { type: "noteOff"; channel: number; note: number } | { type: "allNotesOff" };
950
+
951
+
952
+ /**
953
+ * A stateful PCM processor that JavaScript uses as the `Tunelet` class.
954
+ *
955
+ * The input is signed 16-bit mono PCM. The output is planar stereo or an
956
+ * in-place mono downmix. The quantization, latency and configuration behavior
957
+ * are the same as in the native processor. Buffer lengths count frames, not
958
+ * bytes.
959
+ *
960
+ * These rules apply to the buffers:
961
+ *
962
+ * - Separate stereo output arrays must not overlap.
963
+ * - The input can overlap an output, because the class copies the input
964
+ * first.
965
+ * - All buffers must stay attached until each call is complete.
966
+ *
967
+ * If a call that processes audio fails, it throws a JavaScript `Error` before
968
+ * the audio state or the output changes. The class rejects malformed
969
+ * configuration objects and malformed event objects. It also rejects values
970
+ * that are out of range. The class decodes objects inside the methods that
971
+ * can fail. Thus, if a conversion fails, Rust releases the temporary values
972
+ * as usual.
973
+ */
974
+ export class Tunelet {
975
+ free(): void;
976
+ [Symbol.dispose](): void;
977
+ /**
978
+ * Starts a finite tail budget and returns its frame count as a number.
979
+ *
980
+ * Call this method one time after the final input block. Another call
981
+ * starts the full budget again, but it does not clear the histories. See
982
+ * `beginDrain` for completion.
983
+ */
984
+ beginDrain(): number;
985
+ /**
986
+ * Returns a copy of the active configuration as a new JavaScript object.
987
+ *
988
+ * A change to the object has no effect until `setConfig` or a timed event
989
+ * applies it.
990
+ *
991
+ * # Errors
992
+ *
993
+ * If the conversion to a JavaScript object fails, this method throws.
994
+ */
995
+ config(): ProcessorConfig;
996
+ /**
997
+ * Renders a mono tail block and returns its frame count.
998
+ *
999
+ * The method fills the unused output with zeros. The downmix, completion
1000
+ * and feedback behavior are the same as for `drainMono`.
1001
+ *
1002
+ * # Errors
1003
+ *
1004
+ * If the block is larger than `maxBlockFrames`, this method throws before
1005
+ * the output or the state changes.
1006
+ */
1007
+ drainMono(audio: Int16Array): number;
1008
+ /**
1009
+ * Renders stereo tail frames into `Int16Array` buffers of equal length.
1010
+ *
1011
+ * The method returns the number of rendered frames and fills the unused
1012
+ * output with zeros. If the drain is not active or is complete, the method
1013
+ * returns zero. Empty arrays do not use the budget. Completion resets the
1014
+ * histories and the feedback in the final drain call, also when that call
1015
+ * returns audio.
1016
+ *
1017
+ * # Errors
1018
+ *
1019
+ * The method throws if the channel lengths are not equal or if a block is
1020
+ * larger than `maxBlockFrames`. After an error, both output arrays and the
1021
+ * drain state do not change.
1022
+ */
1023
+ drain(left: Int16Array, right: Int16Array): number;
1024
+ /**
1025
+ * Returns a new feedback object and does not clear the peak window.
1026
+ *
1027
+ * `processedFrames` is a `bigint`, so its 64-bit count stays exact.
1028
+ * `latencyFrames` is a number. See `Feedback` for each measurement.
1029
+ *
1030
+ * `targetMidiNote` is `undefined` in these cases, which are also the
1031
+ * cases where `voiced` is `false`:
1032
+ *
1033
+ * - The kept pitch estimate is unvoiced. This includes the time before
1034
+ * the first detection and after a reset or a drain completion.
1035
+ * - The estimated frequency is outside the inclusive reporting bounds
1036
+ * `minFrequencyHz` and `maxFrequencyHz` of the pitch configuration.
1037
+ *
1038
+ * # Errors
1039
+ *
1040
+ * If the conversion to a JavaScript object fails, this method throws.
1041
+ */
1042
+ feedback(): Feedback;
1043
+ /**
1044
+ * Writes the formant envelopes of the current model into two
1045
+ * `Float32Array` buffers of equal length.
1046
+ *
1047
+ * `input` gets the vocal-tract envelope that the LPC analysis found.
1048
+ * `output` gets the envelope after the width and stretch controls. Point
1049
+ * `k` of `n` is at the frequency `maxFrequencyHz * k / (n - 1)`. The
1050
+ * values are linear magnitudes with no absolute level. Scale them for a
1051
+ * display.
1052
+ *
1053
+ * `maxFrequencyHz` must be finite, more than zero and not more than half
1054
+ * of the sample rate.
1055
+ *
1056
+ * The method returns `true` if the envelopes are valid. It returns
1057
+ * `false` and fills the two arrays with zeros if the formant stage is
1058
+ * disabled or if the current model has no synthesis filter. The audio
1059
+ * does not change.
1060
+ *
1061
+ * The class keeps a buffer for the points. Only the first call and a
1062
+ * call with more points than before reserve memory.
1063
+ *
1064
+ * # Errors
1065
+ *
1066
+ * The method throws if the array lengths are not equal, if the frequency
1067
+ * is not valid or if the reservation of the buffer fails. The arrays
1068
+ * then do not change.
1069
+ */
1070
+ formantEnvelope(max_frequency_hz: number, input: Float32Array, output: Float32Array): boolean;
1071
+ /**
1072
+ * Prepares a processor and its reusable PCM buffers.
1073
+ *
1074
+ * `sample_rate` must be 44100 or 48000. `max_block_frames` must be an
1075
+ * integer in 1..=4294967295. It is a limit for each call, and smaller
1076
+ * blocks and empty blocks are also valid. If you omit `config`, the
1077
+ * processor uses the default configuration. The constructor validates
1078
+ * the settings before it allocates the processor or the PCM buffers. In
1079
+ * TypeScript, use `new Tunelet(sampleRate, maxBlockFrames, config)`.
1080
+ *
1081
+ * # Errors
1082
+ *
1083
+ * The constructor throws if one of these conditions occurs:
1084
+ *
1085
+ * - The rate is not 44100 or 48000.
1086
+ * - The block limit is not an integer or is out of range.
1087
+ * - The configuration object is malformed or a field is missing.
1088
+ * - The configuration is not valid.
1089
+ * - The reservation of a PCM buffer fails.
1090
+ *
1091
+ * The available Wasm memory must also have sufficient space for the DSP
1092
+ * histories.
1093
+ */
1094
+ constructor(sample_rate: number, max_block_frames: number, config?: ProcessorConfig | null);
1095
+ /**
1096
+ * Replaces the audio in a mono `Int16Array` with the stereo downmix.
1097
+ *
1098
+ * The timing, the events and the drain cancellation are the same as for
1099
+ * `process`. Peak feedback measures the stereo output before the downmix,
1100
+ * as in the native processor.
1101
+ *
1102
+ * # Errors
1103
+ *
1104
+ * The method throws if the block is too large or an event is not valid.
1105
+ * It throws before the audio of the caller or the DSP state changes.
1106
+ */
1107
+ processMono(audio: Int16Array, events?: BlockEvents | null): void;
1108
+ /**
1109
+ * Processes mono input into left and right `Int16Array` buffers of equal
1110
+ * length.
1111
+ *
1112
+ * If the call is successful, it writes every output sample. Optional
1113
+ * events apply before their frame, and their offsets obey the rules of
1114
+ * `TimedEvent[]`. An empty block must have no events. A successful call
1115
+ * cancels a drain, also for an empty block. The call uses the existing
1116
+ * JavaScript and Rust PCM buffers again.
1117
+ *
1118
+ * # Errors
1119
+ *
1120
+ * The method throws if the channel lengths are not equal. It also throws
1121
+ * if the block is larger than `maxBlockFrames` or an event is not valid.
1122
+ * The call checks the lengths and the block size before it decodes and
1123
+ * validates the events. If an error occurs, the output buffers and the DSP
1124
+ * state do not change.
1125
+ */
1126
+ process(input: Int16Array, left: Int16Array, right: Int16Array, events?: BlockEvents | null): void;
1127
+ /**
1128
+ * Resets the audio histories and feedback, as the native processor does.
1129
+ *
1130
+ * The configuration, the random stream and some controller and filter
1131
+ * state do not change. This method cancels any active drain. For a fully
1132
+ * new instance, construct a new `Tunelet`.
1133
+ */
1134
+ reset(): void;
1135
+ /**
1136
+ * Decodes and validates a configuration, then replaces the complete
1137
+ * configuration with it.
1138
+ *
1139
+ * State retention and drain cancellation follow the native processor.
1140
+ * The conversion ignores additional properties of the JavaScript object.
1141
+ *
1142
+ * # Errors
1143
+ *
1144
+ * The method throws if an object is not valid or a field is missing.
1145
+ * After an error, all processor state and any active drain stay the same.
1146
+ */
1147
+ setConfig(config: ProcessorConfig): void;
1148
+ /**
1149
+ * Returns the tail budget of the current configuration, not the remaining
1150
+ * drain count.
1151
+ */
1152
+ tailFrames(): number;
1153
+ /**
1154
+ * Returns the feedback and clears only the stereo peak window.
1155
+ *
1156
+ * The other feedback fields and all audio histories do not change.
1157
+ *
1158
+ * # Errors
1159
+ *
1160
+ * If the conversion to a JavaScript object fails, this method throws. The
1161
+ * method clears the peak only after it successfully makes a feedback
1162
+ * object.
1163
+ */
1164
+ takeFeedback(): Feedback;
1165
+ /**
1166
+ * Returns the telemetry and clears only its three peak windows.
1167
+ *
1168
+ * The peak window of the feedback and all audio histories do not change.
1169
+ *
1170
+ * # Errors
1171
+ *
1172
+ * If the conversion to a JavaScript object fails, this method throws. The
1173
+ * method clears the peaks only after it successfully makes a telemetry
1174
+ * object.
1175
+ */
1176
+ takeTelemetry(): Telemetry;
1177
+ /**
1178
+ * Returns a new telemetry object and does not clear its peak windows.
1179
+ *
1180
+ * The telemetry is for meters and displays. It gives the ratio and the
1181
+ * gain of each voice, the input and output peaks, the pitch clarity and
1182
+ * the state of the effects. `processedFrames` is a `bigint`. See
1183
+ * `Telemetry` for each measurement.
1184
+ *
1185
+ * # Errors
1186
+ *
1187
+ * If the conversion to a JavaScript object fails, this method throws.
1188
+ */
1189
+ telemetry(): Telemetry;
1190
+ /**
1191
+ * The nominal resynthesis delay in frames.
1192
+ *
1193
+ * Other signal paths have different timing. See the `latencyFrames`
1194
+ * property for the timing of the dry path and the voices.
1195
+ */
1196
+ readonly latencyFrames: number;
1197
+ /**
1198
+ * The maximum frame count for each call that processes or drains audio.
1199
+ *
1200
+ * The constructor sets this value, and the value does not change.
1201
+ */
1202
+ readonly maxBlockFrames: number;
1203
+ /**
1204
+ * The sample rate of the input and the output in hertz.
1205
+ *
1206
+ * The constructor sets this value, and the value does not change.
1207
+ */
1208
+ readonly sampleRate: number;
1209
+ }
1210
+
1211
+ /**
1212
+ * Returns a complete, independent default configuration for JavaScript.
1213
+ *
1214
+ * Change its fields and give it to `Tunelet` or to `setConfig`. The
1215
+ * `randomSeed` field is a JavaScript `bigint`, so it keeps all 64 bits. After
1216
+ * the binding decodes them, floating-point controls have the precision of the
1217
+ * Rust `f32` type.
1218
+ *
1219
+ * # Errors
1220
+ *
1221
+ * If the conversion to a JavaScript object fails, this function returns a
1222
+ * JavaScript `Error`.
1223
+ */
1224
+ export function defaultConfig(): ProcessorConfig;
1225
+
1226
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1227
+
1228
+ export interface InitOutput {
1229
+ readonly memory: WebAssembly.Memory;
1230
+ readonly __wbg_tunelet_free: (a: number, b: number) => void;
1231
+ readonly defaultConfig: () => [number, number, number];
1232
+ readonly tunelet_beginDrain: (a: number) => number;
1233
+ readonly tunelet_config: (a: number) => [number, number, number];
1234
+ readonly tunelet_drain: (a: number, b: any, c: any) => [number, number, number];
1235
+ readonly tunelet_drainMono: (a: number, b: any) => [number, number, number];
1236
+ readonly tunelet_feedback: (a: number) => [number, number, number];
1237
+ readonly tunelet_formantEnvelope: (a: number, b: number, c: any, d: any) => [number, number, number];
1238
+ readonly tunelet_latencyFrames: (a: number) => number;
1239
+ readonly tunelet_maxBlockFrames: (a: number) => number;
1240
+ readonly tunelet_new: (a: number, b: number, c: number) => [number, number, number];
1241
+ readonly tunelet_process: (a: number, b: any, c: any, d: any, e: number) => [number, number];
1242
+ readonly tunelet_processMono: (a: number, b: any, c: number) => [number, number];
1243
+ readonly tunelet_reset: (a: number) => void;
1244
+ readonly tunelet_sampleRate: (a: number) => number;
1245
+ readonly tunelet_setConfig: (a: number, b: any) => [number, number];
1246
+ readonly tunelet_tailFrames: (a: number) => number;
1247
+ readonly tunelet_takeFeedback: (a: number) => [number, number, number];
1248
+ readonly tunelet_takeTelemetry: (a: number) => [number, number, number];
1249
+ readonly tunelet_telemetry: (a: number) => [number, number, number];
1250
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
1251
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
1252
+ readonly __wbindgen_exn_store: (a: number) => void;
1253
+ readonly __externref_table_alloc: () => number;
1254
+ readonly __wbindgen_externrefs: WebAssembly.Table;
1255
+ readonly __externref_table_dealloc: (a: number) => void;
1256
+ readonly __wbindgen_start: () => void;
1257
+ }
1258
+
1259
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1260
+
1261
+ /**
1262
+ * Instantiates the given `module`, which can either be bytes or
1263
+ * a precompiled `WebAssembly.Module`.
1264
+ *
1265
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1266
+ *
1267
+ * @returns {InitOutput}
1268
+ */
1269
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1270
+
1271
+ /**
1272
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1273
+ * for everything else, calls `WebAssembly.instantiate` directly.
1274
+ *
1275
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1276
+ *
1277
+ * @returns {Promise<InitOutput>}
1278
+ */
1279
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;