@audio/denoise 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -6
- package/members/debleed/audio.d.ts +1 -0
- package/members/debleed/audio.js +1 -0
- package/members/debleed.d.ts +2 -0
- package/members/debleed.js +2 -0
- package/members/debreath/audio.d.ts +1 -0
- package/members/debreath/audio.js +1 -0
- package/members/debreath.d.ts +2 -0
- package/members/debreath.js +2 -0
- package/members/declick/audio.d.ts +1 -0
- package/members/declick/audio.js +1 -0
- package/members/declick.d.ts +2 -0
- package/members/declick.js +2 -0
- package/members/declip/audio.d.ts +1 -0
- package/members/declip/audio.js +1 -0
- package/members/declip.d.ts +2 -0
- package/members/declip.js +2 -0
- package/members/decrackle/audio.d.ts +1 -0
- package/members/decrackle/audio.js +1 -0
- package/members/decrackle.d.ts +2 -0
- package/members/decrackle.js +2 -0
- package/members/dehum/audio.d.ts +1 -0
- package/members/dehum/audio.js +1 -0
- package/members/dehum.d.ts +2 -0
- package/members/dehum.js +2 -0
- package/members/deplosive/audio.d.ts +1 -0
- package/members/deplosive/audio.js +1 -0
- package/members/deplosive.d.ts +2 -0
- package/members/deplosive.js +2 -0
- package/members/dereverb/audio.d.ts +1 -0
- package/members/dereverb/audio.js +1 -0
- package/members/dereverb.d.ts +2 -0
- package/members/dereverb.js +2 -0
- package/members/desilence/audio.d.ts +1 -0
- package/members/desilence/audio.js +1 -0
- package/members/desilence.d.ts +2 -0
- package/members/desilence.js +2 -0
- package/members/desqueak/audio.d.ts +1 -0
- package/members/desqueak/audio.js +1 -0
- package/members/desqueak.d.ts +2 -0
- package/members/desqueak.js +2 -0
- package/members/detect.d.ts +2 -0
- package/members/detect.js +2 -0
- package/members/dewind/audio.d.ts +1 -0
- package/members/dewind/audio.js +1 -0
- package/members/dewind.d.ts +2 -0
- package/members/dewind.js +2 -0
- package/members/dewow/audio.d.ts +1 -0
- package/members/dewow/audio.js +1 -0
- package/members/dewow.d.ts +2 -0
- package/members/dewow.js +2 -0
- package/members/omlsa/audio.d.ts +1 -0
- package/members/omlsa/audio.js +1 -0
- package/members/omlsa.d.ts +2 -0
- package/members/omlsa.js +2 -0
- package/members/repair.d.ts +2 -0
- package/members/repair.js +2 -0
- package/members/spectral/audio.d.ts +1 -0
- package/members/spectral/audio.js +1 -0
- package/members/spectral.d.ts +2 -0
- package/members/spectral.js +2 -0
- package/members/wiener/audio.d.ts +1 -0
- package/members/wiener/audio.js +1 -0
- package/members/wiener.d.ts +2 -0
- package/members/wiener.js +2 -0
- package/package.json +21 -14
package/README.md
CHANGED
|
@@ -176,7 +176,7 @@ Hum is found by `measure()`, one Fourier transform over the signal (its first 80
|
|
|
176
176
|
|
|
177
177
|
The mains phase is tracked first from the harmonics to 1 kHz (each harmonic's phasor per Hann frame four mains cycles long, fitted over 2 s, their turn combined by h²·SNR over 8 s: Hajj-Ahmad, Garg & Wu 2013), then the signal is resampled so that the tracked mains period spans 2^k samples (computed order tracking: Fyfe & Munck 1997). There every harmonic sits on one bin of a 2^k-point transform of each frame however the mains wander, and the phase is refined from the turn between frames of the harmonics, to 16, 64, … 8 kHz, whose lines stand out alone (a partial beside a line turns it with the program), each weighted by its line's power over the program's there and smoothed by Rauch–Tung–Striebel at the likeliest rate of wander and noise scale; a refinement is kept only if it draws the lines tighter (their coherent power grows). Each harmonic's phasors are fitted over 2 s by weighted local-linear least squares (normalized convolution, Knutsson & Westin 1993), each frame weighted by the inverse of the program's power around the line there, so a passing voice or note is bridged from the frames around it rather than averaged in. Under a dense mix there is no frame to bridge from, and a fit over 2 s takes the music near every line, more of it than a faint hum (0.5.0: buzz 30 dB under music came out 7 dB worse than it went in); so the fit is kept within 30 % of the hum bridged through the program: the line's phasors, with any steady tone beside it taken out, followed as a slow random walk by Rauch–Tung–Striebel with the program's power in each frame as its noise, which carries the hum across a loud passage from where it stands alone instead of taking the music in. A line counts only if it persists where the program falls silent, at a tenth of its power elsewhere at least (a note held on a line goes quiet with the music; a held synth note at exactly 50 Hz was taken for hum). The sinusoids are resynthesized period by period, brought back to the original samples (Kaiser-windowed sinc) and subtracted (harmonic subtraction, as power-line interference is taken out of ECG: Levkov et al. 2005).
|
|
178
178
|
|
|
179
|
-
Where the hum itself jumps (an edit's splice turns its phase, a level step, hum switched on or off), every line's phasors before and after a frame differ beyond their spread at once, a note beside one line moving that line alone: the tracking does not integrate across the jump, each stretch is fitted on its own frames, and the hum switches from one stretch's to the next at the sample that best splits the signal between them. A note within ~0.5 Hz of a line for seconds is taken for hum. Whole clip (`streaming: false`), a second at least to find hum; shorter, it removes the harmonics of a given `freq` as told and passes the audio through without one. About a tenth of real time (0.4.0: a hundredth), most of it in the 2 s fits.
|
|
179
|
+
Where the hum itself jumps (an edit's splice turns its phase, a level step, hum switched on or off), every line's phasors before and after a frame differ beyond their spread at once, a note beside one line moving that line alone: the tracking does not integrate across the jump, each stretch is fitted on its own frames, and the hum switches from one stretch's to the next at the sample that best splits the signal between them. A run of exact zeros a period of a line long or more (the take's end, an edit's gap, a gate's) held no line, and nothing is taken away there: a hum of one line switching off moves that line alone, is read as no jump, and was bridged into the run from the sound around and written there inverted (1.5 s of noise over a 50 Hz hum, then silence: 1.7·10⁻² RMS in the silence's first 0.1 s, the hum 3.5·10⁻²; `steady`'s held lines alike through a short silence after the take). Outside such runs every sample is as 0.7.1 gave it in 298 of 300 random settings; in the other 2 (a series told by `freq`, the take ending in such a run, a steady tone off the series found) every sample moves, by up to 3.8·10⁻⁶, the input at 7–8·10⁻² RMS: the tone is fitted after the series is taken away, over the run too, which held the series' estimate then and holds zeros now. A note within ~0.5 Hz of a line for seconds is taken for hum. Whole clip (`streaming: false`), a second at least to find hum; shorter, it removes the harmonics of a given `freq` as told and passes the audio through without one. About a tenth of real time (0.4.0: a hundredth), most of it in the 2 s fits.
|
|
180
180
|
|
|
181
181
|
`steady` (0.6.0) is for a hum that holds still through the take: an amp's ground loop under a guitar. A fit over 2 s takes in what the program puts near a line for seconds, and a chord's attack, moving many lines at once, reads as the hum's jump: on GuitarSet takes under a buzz 35 dB down (audio's `bench/rx/guitar.mjs`, players 00–02), 0.5.2 took the buzz 4.3 dB down and the guitar to 39.3 dB SDR. Steady, each line is one phasor through the take, its mean weighted to where the program around the line is quiet; the program's power there is read from the line's magnitude, not its phase, so a phase still off does not pass for program. Held, the lines show the mains phase's error frame by frame against them, all at once (Newton's steps on the held comb's correlation, smoothed by Rauch–Tung–Striebel at the likeliest rate of wander): from the trace, the phase is refined against the comb to harmonics 2, 4, … 64, then to 8 kHz twice, each step holding the higher lines tighter (on one of those takes, from 0.5 rad off the true phase at its start to under 0.001 rad throughout). A line goes when its held phasor stands 10 dB over its own spread and holds no more than twice the power the line has where the program falls silent (a note on the line, which the take's quiet does not hold), each frame's by its expected coherence, e^(−h²σ²/2) with σ² the phase's variance there: where the program masked the hum and the phase was bridged, the upper lines go less. The dense mix of the test suite under that buzz, wandering ±0.02 Hz: 48.0 dB of it down, the music at 78.4 dB SDR (by default 3.7 and 32.6).
|
|
182
182
|
|
|
@@ -329,6 +329,21 @@ STOI barely moves: its bands begin at 150 Hz, above most of the wind. Wind on a
|
|
|
329
329
|
|
|
330
330
|
The wind goes under the words too, between and under the harmonics; what a voice loses is mostly the harmonics the wind buries (its low end at −10 dB), and onsets.
|
|
331
331
|
|
|
332
|
+
**Allocation in a process's first stream**: until V8 has compiled the code a stream runs each frame, that code runs interpreted and allocates as it goes, and a path the stream first takes later stops the compiled code once. The `audio.js` processor, stereo at 44.1 kHz in blocks of 128 frames at its defaults, on noise and on speech in noise, what V8's heap and the typed arrays' stores take each second of sound, under the flags of @audio/compile's validator (compilation on the main thread) and under Node's own ([how](#allocation-in-a-first-stream); `node scripts/firststream.js`; Node 18, 20 and 22 on Linux, 20, 22 and 25 on macOS):
|
|
333
|
+
|
|
334
|
+
| Node | 0–1 s | 1–3 s | 7–8 s | 3–16 s, the most a second | 16–90 s, the most a second | a second instance: 0–1 s, then the most a second |
|
|
335
|
+
|---|---|---|---|---|---|---|
|
|
336
|
+
| 18 | 28.6–28.7 MB | 1.5 MB | 104 B | 269 KB | 104 B | 47–99 KB, 209 KB |
|
|
337
|
+
| 18, own flags | 67.2–97.3 MB | 17.8 MB | 104 B | 305 KB | 272 B | 3.8 MB, 22 KB |
|
|
338
|
+
| 20 | 28.8–28.9 MB | 2.6 MB | 104 B | 41 KB | 536 B | 1.3 MB, 104 KB |
|
|
339
|
+
| 20, own flags | 57.5–82.0 MB | 11.7 MB | 104 B | 1.8 MB | 536 B | 62 KB to 2.6 MB, 5.0 MB |
|
|
340
|
+
| 22 | 33.9–40.1 MB | 5.1 MB | 104 B | 65 KB | 1008 B | 2.5–3.2 MB, 27 KB |
|
|
341
|
+
| 22, own flags | 76.2–81.1 MB | 17.8 MB | 104 B | 71 KB | 776 B | 3.2–5.1 MB, 22 KB |
|
|
342
|
+
| 25 | 90.3–90.4 MB | 4.7 MB | 104 B | 104 B | 2.3 KB | 2.0 MB, 336 B |
|
|
343
|
+
| 25, own flags | 36.4–40.1 MB | 7.3 MB | 104 B | 104 B | 2.7 KB | 17 KB to 11.9 MB, 672 B |
|
|
344
|
+
|
|
345
|
+
A processor that copies its input reads up to 1.7 KB a second through the same harness after 16 s. `dewind` runs no tracker of noise-estimate's: in 20 runs on Node 20 under its own flags (`--runs=5`) it took at most 1.2 KB in seconds 20 to 30, and on Node 18, 22 and 25 at most 4.0 KB, the copying processor 1.0 KB. So a first stream allocates for its first 16 s, most of it in its first second, and a second instance in the same process up to 3.2 MB in its first second (11.9 MB under Node 25's own flags), then up to 209 KB (5.0 MB under Node 20's own).
|
|
346
|
+
|
|
332
347
|
**Use when:** wind on a microphone under a voice or an instrument, gusting or steady; a recording's low rumble (traffic, a fan) where it outweighs the mid band in the pauses.<br>
|
|
333
348
|
**Not for:** a lone thump (`deplosive`), a steady low tone or hum, which has a period (`dehum`, `highpass`), or broadband noise (`omlsa`, `wiener`). Air rushing over the whole band is taken only under `cutoff`. A neural model (`@audio/neural-denoise`'s DeepFilterNet3) takes more of the wind and keeps more of the voice; dewind leaves a sound with no aperiodic low end as it is (music, a voice with no rumble under it), streams at a frame's delay, and needs no model.
|
|
334
349
|
|
|
@@ -413,7 +428,7 @@ deesser(data, { fs, mode: 'band', fc: 7500, Q: 1 }) // a bell at 7.5
|
|
|
413
428
|
|
|
414
429
|
### `specsub`
|
|
415
430
|
|
|
416
|
-
Power spectral subtraction with over-subtraction and a spectral floor (Berouti, Schwartz & Makhoul 1979): |Ŝ|² = |Y|² − α·N̂ where that stays above β·N̂, else β·N̂. Over-subtraction takes out the noise's peaks that plain subtraction leaves as musical tones; the floor, a fraction of the noise estimate, fills the valleys with a steady bed that masks what is left. α follows the frame's SNR (4 − 3/20·SNR: 4.75 at −5 dB down to 1 at 20 dB) unless fixed. The noise PSD is tracked by minimum statistics (Martin 2001) over a 1.5 s window, in batch and stream alike, unless a profile or a noise-only stretch is given; a held note, a sustained vowel or a chord is kept out of it (@audio/noise-estimate's `partials`, as [`omlsa`](https://github.com/audiojs/denoise#omlsa) has it: clean music cut by more than 3 dB 10.3 → 3.2 %, sung long tones 36.9 → 0.0 %, Slakh mixes 13.1 → 0.8 %; `estimator: { partials: false }` turns it off). `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames.
|
|
431
|
+
Power spectral subtraction with over-subtraction and a spectral floor (Berouti, Schwartz & Makhoul 1979): |Ŝ|² = |Y|² − α·N̂ where that stays above β·N̂, else β·N̂. Over-subtraction takes out the noise's peaks that plain subtraction leaves as musical tones; the floor, a fraction of the noise estimate, fills the valleys with a steady bed that masks what is left. α follows the frame's SNR (4 − 3/20·SNR: 4.75 at −5 dB down to 1 at 20 dB) unless fixed. The noise PSD is tracked by minimum statistics (Martin 2001) over a 1.5 s window, in batch and stream alike, unless a profile or a noise-only stretch is given; a held note, a sustained vowel or a chord is kept out of it (@audio/noise-estimate's `partials`, as [`omlsa`](https://github.com/audiojs/denoise#omlsa) has it: clean music cut by more than 3 dB 10.3 → 3.2 %, sung long tones 36.9 → 0.0 %, Slakh mixes 13.1 → 0.8 %; `estimator: { partials: false }` turns it off). `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames. The stream form reads `alpha` and `beta` from its options object each frame: changed between writes, they change from the next frame (so the `audio.js` processor's are live).
|
|
417
432
|
|
|
418
433
|
```js
|
|
419
434
|
specsub(data, { fs }) // α(SNR), β 0.05, noise tracked
|
|
@@ -431,13 +446,28 @@ specsub(data, { fs, noiseFrames: 6 }) // noise from the
|
|
|
431
446
|
| `estimator` | | Minimum statistics options (@audio/noise-estimate `minStats`); `{ partials: false }`: held notes learned as noise, as before |
|
|
432
447
|
| `noiseFrames` / `profileFrom` / `profileTo` | | A noise-only stretch to average for the profile |
|
|
433
448
|
|
|
449
|
+
**Allocation in a process's first stream**: until V8 has compiled the code a stream runs each frame, that code runs interpreted and allocates as it goes, and a path the stream first takes later stops the compiled code once (the noise tracker's guard of held partials closing its first window, 7.5 s in; later ones the sound decides). The `audio.js` processor, stereo at 44.1 kHz in blocks of 128 frames at its defaults, on noise and on speech in noise, what V8's heap and the typed arrays' stores take each second of sound, under the flags of @audio/compile's validator (compilation on the main thread) and under Node's own ([how](#allocation-in-a-first-stream); `node scripts/firststream.js`; Node 18, 20 and 22 on Linux, 20, 22 and 25 on macOS):
|
|
450
|
+
|
|
451
|
+
| Node | 0–1 s | 1–3 s | 7–8 s | 3–16 s, the most a second | 16–90 s, the most a second | a second instance: 0–1 s, then the most a second |
|
|
452
|
+
|---|---|---|---|---|---|---|
|
|
453
|
+
| 18 | 11.2–11.9 MB | 2.1 MB | 551 KB | 270 KB | 752 B | 1.2 MB, 54 KB |
|
|
454
|
+
| 18, own flags | 22.7–34.7 MB | 2.4 MB | 7.9 MB | 248 KB | 248 B | 1.8–2.1 MB, 55 KB |
|
|
455
|
+
| 20 | 11.6–12.7 MB | 1.5 MB | 655 KB | 45 KB | 872 B | 1.2–1.3 MB, 121 KB |
|
|
456
|
+
| 20, own flags | 22.4–41.9 MB | 15.9 MB | 7.2 MB | 135 KB | 135 KB | 2.0–10.9 MB, 36 KB |
|
|
457
|
+
| 22 | 22.2–24.6 MB | 4.0 MB | 1.2 MB | 67 KB | 2.0 KB | 701 KB to 2.3 MB, 9.3 KB |
|
|
458
|
+
| 22, own flags | 34.6–47.0 MB | 13.8 MB | 11.9 MB | 43 KB | 1.3 KB | 3.1–4.3 MB, 8.4 KB |
|
|
459
|
+
| 25 | 12.5–14.8 MB | 6.7 MB | 1.1 MB | 104 B | 1.7 KB | 505–508 KB, 120 B |
|
|
460
|
+
| 25, own flags | 21.2–29.5 MB | 14.4 MB | 8.9 MB | 104 B | 912 B | 805–991 KB, 120 B |
|
|
461
|
+
|
|
462
|
+
A processor that copies its input reads up to 1.7 KB a second through the same harness after 16 s. On Node 20 under its own flags the stream went on allocating, to its end, in 9 of 20 runs (`--runs=5`, noise and speech, Linux and macOS; 118 to 135 KB a second through 90 s, 1.27 MB in seconds 20 to 30): V8 11.3, compiling on the compiler's thread, can leave the noise tracker's update (noise-estimate's minimum statistics, or its guard of held partials) entering its on-stack-replacement code from the interpreter every frame, its own compiled code never taking over. With `--no-concurrent-recompilation`, as the validator runs, it did not in 10 runs on Linux (`--own --flags=--no-concurrent-recompilation --runs=5`), at most 1.2 KB in seconds 20 to 30. Node 18, 22 and 25 took at most 5.7 KB in seconds 20 to 30 in every run, the copying processor 1.0 KB. So a first stream allocates for its first 16 s, most of it in its first second, and a second instance in the same process up to 2.3 MB in its first second (10.9 MB under Node 20's own flags), then up to 121 KB.
|
|
463
|
+
|
|
434
464
|
**Use when:** quick baseline; offline cleanup with a known noise-only preamble.<br>
|
|
435
465
|
**Not for:** musical-noise-sensitive material — use `wiener` or `omlsa`.
|
|
436
466
|
|
|
437
467
|
|
|
438
468
|
### `wiener`
|
|
439
469
|
|
|
440
|
-
MMSE log-spectral amplitude (Ephraim & Malah 1985) or Wiener (Scalart & Filho 1996) gain on the decision-directed a priori SNR ξ = α·Â²(l−1)/λ(l−1) + (1−α)·max(γ−1, 0) (Ephraim & Malah 1984, eq. 51). α = 0.98 is theirs for an 8 ms frame step (§VI: 256 samples at 8 kHz, a new frame every 64) and is rescaled to the actual step as α<sup>Δt/8 ms</sup>, so the a priori SNR's memory holds in seconds; applied per frame until 0.3, it ran 1.8× longer at 48 kHz (10.7 ms steps) than at 44.1 kHz (5.8 ms). The floor ξ<sub>min</sub> stays −15 dB: −25 dB, Cohen's and Loizou's, left more musical noise on steady white and pink noise (log kurtosis ratio 0.98 and 1.49, against 0.53 and 1.01) and cost PESQ and SIG on the training speech (`scripts/speech.mjs`). The noise PSD λ is tracked by minimum statistics (Martin 2001) over a 1.5 s window, in batch and stream alike, unless a profile or a noise-only stretch is given; a held note, a sustained vowel or a chord is kept out of it (@audio/noise-estimate's `partials`, as [`omlsa`](https://github.com/audiojs/denoise#omlsa) has it: clean music cut by more than 3 dB 14.5 → 3.4 %, sung long tones 36.3 → 0.0 %, Slakh mixes 26.6 → 3.3 %; `estimator: { partials: false }` turns it off). `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames.
|
|
470
|
+
MMSE log-spectral amplitude (Ephraim & Malah 1985) or Wiener (Scalart & Filho 1996) gain on the decision-directed a priori SNR ξ = α·Â²(l−1)/λ(l−1) + (1−α)·max(γ−1, 0) (Ephraim & Malah 1984, eq. 51). α = 0.98 is theirs for an 8 ms frame step (§VI: 256 samples at 8 kHz, a new frame every 64) and is rescaled to the actual step as α<sup>Δt/8 ms</sup>, so the a priori SNR's memory holds in seconds; applied per frame until 0.3, it ran 1.8× longer at 48 kHz (10.7 ms steps) than at 44.1 kHz (5.8 ms). The floor ξ<sub>min</sub> stays −15 dB: −25 dB, Cohen's and Loizou's, left more musical noise on steady white and pink noise (log kurtosis ratio 0.98 and 1.49, against 0.53 and 1.01) and cost PESQ and SIG on the training speech (`scripts/speech.mjs`). The noise PSD λ is tracked by minimum statistics (Martin 2001) over a 1.5 s window, in batch and stream alike, unless a profile or a noise-only stretch is given; a held note, a sustained vowel or a chord is kept out of it (@audio/noise-estimate's `partials`, as [`omlsa`](https://github.com/audiojs/denoise#omlsa) has it: clean music cut by more than 3 dB 14.5 → 3.4 %, sung long tones 36.3 → 0.0 %, Slakh mixes 26.6 → 3.3 %; `estimator: { partials: false }` turns it off). `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames. The stream form reads `rule`, `alphaDD` (`alpha`) and `xiMin` from its options object each frame: changed between writes, they change from the next frame (so the `audio.js` processor's are live).
|
|
441
471
|
|
|
442
472
|
```js
|
|
443
473
|
wiener(data, { fs }) // LSA gain, noise tracked
|
|
@@ -456,6 +486,21 @@ wiener(data, { fs, noiseFrames: 6 }) // noise from the
|
|
|
456
486
|
| `estimator` | | Minimum statistics options (@audio/noise-estimate `minStats`); `{ partials: false }`: held notes learned as noise, as before |
|
|
457
487
|
| `noiseFrames` / `profileFrom` / `profileTo` | | A noise-only stretch to average for the profile |
|
|
458
488
|
|
|
489
|
+
**Allocation in a process's first stream**: until V8 has compiled the code a stream runs each frame, that code runs interpreted and allocates as it goes, and a path the stream first takes later stops the compiled code once (the noise tracker's guard of held partials closing its first window, 7.5 s in; later ones the sound decides). The `audio.js` processor, stereo at 44.1 kHz in blocks of 128 frames at its defaults, on noise and on speech in noise, what V8's heap and the typed arrays' stores take each second of sound, under the flags of @audio/compile's validator (compilation on the main thread) and under Node's own ([how](#allocation-in-a-first-stream); `node scripts/firststream.js`; Node 18, 20 and 22 on Linux, 20, 22 and 25 on macOS):
|
|
490
|
+
|
|
491
|
+
| Node | 0–1 s | 1–3 s | 7–8 s | 3–16 s, the most a second | 16–90 s, the most a second | a second instance: 0–1 s, then the most a second |
|
|
492
|
+
|---|---|---|---|---|---|---|
|
|
493
|
+
| 18 | 12.5–13.8 MB | 2.4 MB | 416 KB | 116 KB | 440 B | 1.2–1.3 MB, 76 KB |
|
|
494
|
+
| 18, own flags | 24.1–39.4 MB | 2.3 MB | 5.7 MB | 14 KB | 248 B | 2.0–2.8 MB, 76 KB |
|
|
495
|
+
| 20 | 13.6–14.8 MB | 1.8 MB | 586 KB | 68 KB | 608 B | 1.2 MB, 51 KB |
|
|
496
|
+
| 20, own flags | 25.8–49.7 MB | 15.9 MB | 7.6 MB | 171 KB | 171 KB | 2.0–13.4 MB, 116 KB |
|
|
497
|
+
| 22 | 26.6–29.1 MB | 4.0 MB | 1.2 MB | 70 KB | 1008 B | 545 KB to 2.3 MB, 171 KB |
|
|
498
|
+
| 22, own flags | 39.0–54.1 MB | 12.8 MB | 8.2 MB | 84 KB | 1.6 KB | 3.1–6.8 MB, 19 KB |
|
|
499
|
+
| 25 | 17.2–19.5 MB | 6.7 MB | 1.1 MB | 104 B | 2.6 KB | 506–509 KB, 336 B |
|
|
500
|
+
| 25, own flags | 25.4–33.2 MB | 16.0 MB | 7.2 MB | 104 B | 2.7 KB | 1.6–1.9 MB, 104 B |
|
|
501
|
+
|
|
502
|
+
A processor that copies its input reads up to 1.7 KB a second through the same harness after 16 s. On Node 20 under its own flags the stream went on allocating, to its end, in 12 of 20 runs (`--runs=5`, noise and speech, Linux and macOS; 118 to 171 KB a second through 90 s, 1.27 to 2.93 MB in seconds 20 to 30): V8 11.3, compiling on the compiler's thread, can leave the noise tracker's update (noise-estimate's minimum statistics, or its guard of held partials) entering its on-stack-replacement code from the interpreter every frame, its own compiled code never taking over. With `--no-concurrent-recompilation`, as the validator runs, it did not in 10 runs on Linux (`--own --flags=--no-concurrent-recompilation --runs=5`), at most 1.5 KB in seconds 20 to 30. Node 18, 22 and 25 took at most 5.7 KB in seconds 20 to 30 in every run, the copying processor 1.0 KB. So a first stream allocates for its first 16 s, most of it in its first second, and a second instance in the same process up to 2.3 MB in its first second (13.4 MB under Node 20's own flags), then up to 171 KB.
|
|
503
|
+
|
|
459
504
|
**Use when:** transparent broadband denoise; the "safe default" for stationary noise.
|
|
460
505
|
|
|
461
506
|
|
|
@@ -469,7 +514,7 @@ The a priori SNR the speech absence is read from is smoothed in the cepstrum (Br
|
|
|
469
514
|
|
|
470
515
|
A held note, a sustained vowel or a chord is not learned as the noise. IMCRA, as minimum statistics, takes whatever holds a bin for about a second as noise: clean music through `omlsa` lost 9.9 % of its time-frequency energy by more than 3 dB, a sung long tone 8.8 %, a synthesized band 22.6 %. @audio/noise-estimate's `partials` reads, each frame, where a partial stands, a peak over the spectrum's morphological floor (the inverse harmonic mask of Nelke, Naylor & Vary, ICASSP 2015) held 0.3 s within ±1 bin and 10 dB over what its bin held while free, and there holds the noise at that memory; elsewhere, and on noise alone, the tracker's estimate is as it was, to the bit. A line steady from the take's start (hum, a fan, an engine) has no free frame and stays noise; one that starts mid-take is held up to 60 s, then learned, as is a note held longer; a note sounding from the first frame is learned until its bin is once free of it. Music cut 9.9 → 3.0 %, sung long tones 8.8 → 0.0 %, Slakh mixes 22.6 → 2.3 %; on the training speech PESQ 1.825 → 1.823, OVRL 2.543 → 2.542, musical noise 0.80 → 0.81 ([Speech](#speech) has the test set). `estimator: { partials: false }` turns it off.
|
|
471
516
|
|
|
472
|
-
A noise that holds still can be learned instead: `profile`, the noise's PSD (`noiseProfile` of a stretch where it plays alone), or, in the batch form, `noiseFrames`/`profileFrom`/`profileTo` naming that stretch. The noise is then held (`known` of @audio/noise-estimate), and p reads the observation: γ averaged over 105.5 Hz and over 543 Hz of the frame, at fixed priors (Gerkmann, Breithaupt & Martin 2008: the averaged γ is χ² with r degrees of freedom from the Hann window's correlation across bins, ξ<sub>fix</sub> the a priori SNR that minimizes false alarms plus misses, eq. 13; at 48 kHz r 5.7 and 24, ξ<sub>fix</sub> 9.4 and 5.1 dB), and 0 where the estimated q reaches 0.9, as before. Until 0.4 it read γ in each bin alone, at ξ<sub>H1</sub> = 15 dB (Gerkmann & Hendriks 2012), and speech 0–5 dB over the noise lost 7.8 dB on the training speech, where the MMSE Wiener gain keeps 3.9. The paper averages over 64 ms of frames as well; presence then outlasted a sound by those frames, and in the half second after music stopped the noise came through in tones (log kurtosis ratio 0.45 at G<sub>min</sub> −12 dB, 1.77 at −20): over the frame alone. On the training speech, G<sub>min</sub> −12 dB: PESQ 1.861 → 1.867, OVRL 2.564 → 2.572, BAK 3.05 → 3.08, musical noise 0.53 → 0.46, speech 0–5 dB over the noise −7.8 → −5.1 dB, the noise taken in pauses 9.7 → 10.1 dB. Steady noise under speech and music goes exactly G<sub>min</sub> down, with no musical noise from −12 to −20 dB (log kurtosis ratio 0.00); in the half second after music stops, 0.04 at −12 dB and 0.40 at −20 (0.5: 0.05 and 0.61, 0.3: 0.11 and 1.00; `scripts/broadband.mjs`). Held, the frame is the power of two at or above 32 ms (`frame(fs, true)`; a `profile` without a `frameSize` brings its own, 2(K − 1) for K bins): 2048 at 44.1 kHz as at 48, where the nearest power of two, the tracked frame, left 1024 and 43 Hz bins, half the resolution 48 kHz gets. Nothing is tracked on a held noise, so the frame's length goes to frequency, and a partial under the noise is parted from it. 0.5 → 0.6, music under steady noise at 44.1 kHz (audio's `bench/rx/denoise.mjs`: ten MUSDB18 test mixtures, strings and jazz, under white, pink and two DEMAND noises 10 and 25 dB down, 96 takes): SDR 20.16 → 20.94 dB, noise-to-mask ratio −9.6 → −10.0 dB, music cut by more than 3 dB 2.2 → 1.3 %, above 8 kHz −2.8 → −2.6 dB, musical noise under the music 0.44 → 0.38; VoiceBank training speech at 44.1 kHz, its lead-in learned: PESQ 1.875 → 1.872, STOI 0.830 → 0.835, OVRL 2.549 → 2.574. Tracking, the shorter frame stays: 2048 at 44.1 kHz cost that speech PESQ 0.053 and BAK 0.08. Tracking the noise from the print (Gerkmann & Hendriks 2012's MMSE tracker started on it, RX's "adaptive") lost OVRL 0.04 and left musical noise (0.40 on pink): the print is held. `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames: audio's `denoise` op learns a print from a range and runs it so.
|
|
517
|
+
A noise that holds still can be learned instead: `profile`, the noise's PSD (`noiseProfile` of a stretch where it plays alone), or, in the batch form, `noiseFrames`/`profileFrom`/`profileTo` naming that stretch. The noise is then held (`known` of @audio/noise-estimate), and p reads the observation: γ averaged over 105.5 Hz and over 543 Hz of the frame, at fixed priors (Gerkmann, Breithaupt & Martin 2008: the averaged γ is χ² with r degrees of freedom from the Hann window's correlation across bins, ξ<sub>fix</sub> the a priori SNR that minimizes false alarms plus misses, eq. 13; at 48 kHz r 5.7 and 24, ξ<sub>fix</sub> 9.4 and 5.1 dB), and 0 where the estimated q reaches 0.9, as before. Until 0.4 it read γ in each bin alone, at ξ<sub>H1</sub> = 15 dB (Gerkmann & Hendriks 2012), and speech 0–5 dB over the noise lost 7.8 dB on the training speech, where the MMSE Wiener gain keeps 3.9. The paper averages over 64 ms of frames as well; presence then outlasted a sound by those frames, and in the half second after music stopped the noise came through in tones (log kurtosis ratio 0.45 at G<sub>min</sub> −12 dB, 1.77 at −20): over the frame alone. On the training speech, G<sub>min</sub> −12 dB: PESQ 1.861 → 1.867, OVRL 2.564 → 2.572, BAK 3.05 → 3.08, musical noise 0.53 → 0.46, speech 0–5 dB over the noise −7.8 → −5.1 dB, the noise taken in pauses 9.7 → 10.1 dB. Steady noise under speech and music goes exactly G<sub>min</sub> down, with no musical noise from −12 to −20 dB (log kurtosis ratio 0.00); in the half second after music stops, 0.04 at −12 dB and 0.40 at −20 (0.5: 0.05 and 0.61, 0.3: 0.11 and 1.00; `scripts/broadband.mjs`). Held, the frame is the power of two at or above 32 ms (`frame(fs, true)`; a `profile` without a `frameSize` brings its own, 2(K − 1) for K bins): 2048 at 44.1 kHz as at 48, where the nearest power of two, the tracked frame, left 1024 and 43 Hz bins, half the resolution 48 kHz gets. Nothing is tracked on a held noise, so the frame's length goes to frequency, and a partial under the noise is parted from it. 0.5 → 0.6, music under steady noise at 44.1 kHz (audio's `bench/rx/denoise.mjs`: ten MUSDB18 test mixtures, strings and jazz, under white, pink and two DEMAND noises 10 and 25 dB down, 96 takes): SDR 20.16 → 20.94 dB, noise-to-mask ratio −9.6 → −10.0 dB, music cut by more than 3 dB 2.2 → 1.3 %, above 8 kHz −2.8 → −2.6 dB, musical noise under the music 0.44 → 0.38; VoiceBank training speech at 44.1 kHz, its lead-in learned: PESQ 1.875 → 1.872, STOI 0.830 → 0.835, OVRL 2.549 → 2.574. Tracking, the shorter frame stays: 2048 at 44.1 kHz cost that speech PESQ 0.053 and BAK 0.08. Tracking the noise from the print (Gerkmann & Hendriks 2012's MMSE tracker started on it, RX's "adaptive") lost OVRL 0.04 and left musical noise (0.40 on pink): the print is held. `processor(opts)` is the gain as an @audio/stft frame process, for a host running its own frames: audio's `denoise` op learns a print from a range and runs it so. The stream form reads `alphaDD` (`alpha`), `xiMin`, `gMin`, `qPrior` and `threshold` from its options object each frame: changed between writes, they change from the next frame, the noise tracker retuned with its memory kept (so the `audio.js` processor's are live).
|
|
473
518
|
|
|
474
519
|
```js
|
|
475
520
|
omlsa(data, { fs })
|
|
@@ -493,6 +538,21 @@ omlsa(data, { fs, profileFrom: 0, profileTo: fs / 2, gMin: -12 }) // the noise
|
|
|
493
538
|
|
|
494
539
|
Against iZotope RX 12's Voice De-noise and Spectral De-noise on the same speech, narrations and music: [Speech](#speech).
|
|
495
540
|
|
|
541
|
+
**Allocation in a process's first stream**: until V8 has compiled the code a stream runs each frame, that code runs interpreted and allocates as it goes, and a path the stream first takes later stops the compiled code once (the noise tracker's guard of held partials closing its first window, 7.5 s in; later ones the sound decides). The `audio.js` processor, stereo at 44.1 kHz in blocks of 128 frames at its defaults, on noise and on speech in noise, what V8's heap and the typed arrays' stores take each second of sound, under the flags of @audio/compile's validator (compilation on the main thread) and under Node's own ([how](#allocation-in-a-first-stream); `node scripts/firststream.js`; Node 18, 20 and 22 on Linux, 20, 22 and 25 on macOS):
|
|
542
|
+
|
|
543
|
+
| Node | 0–1 s | 1–3 s | 7–8 s | 3–16 s, the most a second | 16–90 s, the most a second | a second instance: 0–1 s, then the most a second |
|
|
544
|
+
|---|---|---|---|---|---|---|
|
|
545
|
+
| 18 | 21.5–21.6 MB | 798 KB | 416 KB | 108 KB | 1.2 KB | 1.2 MB, 177 KB |
|
|
546
|
+
| 18, own flags | 84.3–92.8 MB | 6.1 MB | 6.0 MB | 216 B | 776 B | 1.1–5.1 MB, 108 KB |
|
|
547
|
+
| 20 | 24.6–25.6 MB | 1.7 MB | 416 KB | 108 KB | 248 B | 1.2 MB, 202 KB |
|
|
548
|
+
| 20, own flags | 86.8–94.4 MB | 5.6 MB | 10.4 MB | 108 KB | 392 B | 1.2–2.9 MB, 170 KB |
|
|
549
|
+
| 22 | 43.0–46.2 MB | 3.6 MB | 1.2 MB | 89 KB | 1.5 KB | 584 KB to 2.3 MB, 11 KB |
|
|
550
|
+
| 22, own flags | 82.9–121.0 MB | 11.2 MB | 5.2 MB | 98 KB | 1.3 KB | 2.9–7.0 MB, 8.8 KB |
|
|
551
|
+
| 25 | 63.1–86.7 MB | 31.8 MB | 1.2 MB | 104 B | 2.1 KB | 510–511 KB, 120 B |
|
|
552
|
+
| 25, own flags | 72.6–80.7 MB | 21.4 MB | 4.9 MB | 120 B | 1.3 KB | 966 KB to 2.5 MB, 272 B |
|
|
553
|
+
|
|
554
|
+
A processor that copies its input reads up to 1.7 KB a second through the same harness after 16 s. On Node 20 under its own flags the stream went on allocating, to its end, in 1 of 20 runs (`--runs=5`, noise and speech, Linux and macOS; 379 KB in seconds 20 to 30): V8 11.3, compiling on the compiler's thread, can leave the noise tracker's update (noise-estimate's minimum statistics, or its guard of held partials) entering its on-stack-replacement code from the interpreter every frame, its own compiled code never taking over. With `--no-concurrent-recompilation`, as the validator runs, it did not in 10 runs on Linux (`--own --flags=--no-concurrent-recompilation --runs=5`), at most 1.2 KB in seconds 20 to 30. Node 18, 22 and 25 took at most 5.7 KB in seconds 20 to 30 in every run, the copying processor 1.0 KB. So a first stream allocates for its first 16 s, most of it in its first second, and a second instance in the same process up to 2.3 MB in its first second (7.0 MB under Node 22's own flags), then up to 202 KB.
|
|
555
|
+
|
|
496
556
|
**Use when:** speech in non-stationary noise (street, café, car); generally the highest-quality choice for noisy speech. A steady noise with a stretch of it alone (hiss, hum, a fan, room tone): learn it, `profile`.
|
|
497
557
|
|
|
498
558
|
|
|
@@ -590,9 +650,9 @@ Finds where a sound was cut and rebuilds what the cut took off. A hard clip pile
|
|
|
590
650
|
|
|
591
651
|
Lossy coding (MP3, AAC, Opus) leaves no flat top: it spreads the rail into a band, the coder's noise around the level the runs were cut at, a mode of the amplitude density with mass on both sides of it. A waveform's own peaks, a sine's top, a limiter's ceiling, only approach a level from below. So, where no side has a flat rail, each side's band is its highest mode standing 4 times over the density 2–6 % of the extreme below it (at 1, 2 and 4 times that scale, for coarser coders), with samples over it reaching 3 of its spreads σ (the RMS of the samples over the mode) and beyond; the sound is cut again 6σ under the mode and rebuilt as a clip there (κ = 6 chosen on VoiceBank and MUSDB18 training material through LAME at 128 kbit/s: 0.6 dB over 4 on average, speech +0.9, music −0.1; 5 and 8 within 0.2 on speech).
|
|
592
652
|
|
|
593
|
-
Soft saturation, a valve, transistor or tape stage driven hot, leaves no rail and no band: a memoryless curve bends the peaks over toward a ceiling. Where neither is found, the curve is fitted blind, by maximum likelihood, the sound before it taken for locally AR Gaussian: for a curve f, z = f⁻¹(x) is the sound it bent, and the likelihood is AR(24)'s of z per window of 46 ms, the variance profiled out, times the Jacobian of f⁻¹ (a Wiener system, a linear sound then a memoryless curve, inverted blindly; Taleb, Solé-Casals & Jutten 2001 invert one by its output's independence). Two shapes, each of unit slope at 0, with a ceiling per side and a knee k: c·tanh((|x|/c)^k)^(1/k), tanh at k = 1, an exponential approach to the ceiling; and x/(1 + (|x|/c)^k)^(1/k), an algebraic one, as arctan's. It reads the 48 windows of the highest peaks, a quarter of them first to screen, and takes a curve that gains over 0.02 nats a sample against the sound as it is and bends the loudest peak to half its slope or less. A band the recording left empty (a lowpass, a codec's) would make a curve's new harmonics there cost more than they should, so each window's fit keeps a white floor 70 dB under its power. The sound is then inverted, z = f⁻¹(x), where the curve keeps over 1/40 of its slope (its noise and the fit's error raised at most 32 dB); above, z is unknown and held at least at f⁻¹ there: a clip, rebuilt as one. A limiter is no curve: its gain moves over milliseconds and keeps each wave's shape, and undoing it is an expander's work, not a repair's. Sound with no rail, no band and no curve comes back bit-exact: none of 1736 clean recordings, as they are, peak-normalized, or driven 12 dB into a lookahead limiter, shows one (VoiceBank+DEMAND's 1328 utterances, MUSDB18's 144 mixtures whole, the survey's ten SQAM excerpts, the four pieces whole, ten Spoken Wikipedia narrations, 100 VocalSet takes, 120 GuitarSet takes, 20 Slakh mixes), nor do sines from 50 Hz to 5 kHz. The most any gains is 0.01 nats a sample, VocalSet's sung long tones, whose curve leaves the loudest peak 0.6–0.9 of its slope; MUSDB18's mixtures, as they are and limited, 10⁻⁴. On the tuning material of the comparison below, saturation to 10 dB SDR gains 0.07–0.23 nats a sample on speech and 0.5–1.1 on music, its peaks bent to 1/17 of their slope or less; the slope's limit, 40, was chosen there: against 10 and 20, up to 9 dB more on its tanh-saturated mixtures, the same on its speech and under curves outside the two (arctan, a side's ceiling apart, hiss after the curve). The screen costs about a tenth of a second on clean sound; a fit, a few seconds.
|
|
653
|
+
Soft saturation, a valve, transistor or tape stage driven hot, leaves no rail and no band: a memoryless curve bends the peaks over toward a ceiling. Where neither is found, the curve is fitted blind, by maximum likelihood, the sound before it taken for locally AR Gaussian: for a curve f, z = f⁻¹(x) is the sound it bent, and the likelihood is AR(24)'s of z per window of 46 ms, the variance profiled out, times the Jacobian of f⁻¹ (a Wiener system, a linear sound then a memoryless curve, inverted blindly; Taleb, Solé-Casals & Jutten 2001 invert one by its output's independence). Two shapes, each of unit slope at 0, with a ceiling per side and a knee k: c·tanh((|x|/c)^k)^(1/k), tanh at k = 1, an exponential approach to the ceiling; and x/(1 + (|x|/c)^k)^(1/k), an algebraic one, as arctan's. It reads the 48 windows of the highest peaks, a quarter of them first to screen, and takes a curve that gains over 0.02 nats a sample against the sound as it is and bends the loudest peak to half its slope or less. A band the recording left empty (a lowpass, a codec's) would make a curve's new harmonics there cost more than they should, so each window's fit keeps a white floor 70 dB under its power. The sound is then inverted, z = f⁻¹(x), where the curve keeps over 1/40 of its slope (its noise and the fit's error raised at most 32 dB); above, z is unknown and held at least at f⁻¹ there: a clip, rebuilt as one. A limiter is no curve: its gain moves over milliseconds and keeps each wave's shape, and undoing it is an expander's work, not a repair's. Sound with no rail, no band and no curve comes back bit-exact: none of 1736 clean recordings, as they are, peak-normalized, or driven 12 dB into a lookahead limiter, shows one (VoiceBank+DEMAND's 1328 utterances, MUSDB18's 144 mixtures whole, the survey's ten SQAM excerpts, the four pieces whole, ten Spoken Wikipedia narrations, 100 VocalSet takes, 120 GuitarSet takes, 20 Slakh mixes), nor do sines from 50 Hz to 5 kHz. The most any gains is 0.01 nats a sample, VocalSet's sung long tones, whose curve leaves the loudest peak 0.6–0.9 of its slope; MUSDB18's mixtures, as they are and limited, 10⁻⁴. On the tuning material of the comparison below, saturation to 10 dB SDR gains 0.07–0.23 nats a sample on speech and 0.5–1.1 on music, its peaks bent to 1/17 of their slope or less; the slope's limit, 40, was chosen there: against 10 and 20, up to 9 dB more on its tanh-saturated mixtures, the same on its speech and under curves outside the two (arctan, a side's ceiling apart, hiss after the curve). The screen costs about a tenth of a second on clean sound; a fit, a few seconds. A hard-edged white noise (a synthesizer's, dither alone) is taken for saturated: a Gaussian through its own CDF is uniform, so by its amplitudes it is a saturated white noise, and no likelihood tells the two apart: speech under a loud uniform noise, no curve to undo, comes back with the noise inverted toward a Gaussian's, as through 0.5.1 (11 of the 300 random takes below, 15–25 dB from how they came; and 5 saturated under uniform noise further from the sound before the curve than they came).
|
|
594
654
|
|
|
595
|
-
Every sample at a rail is then rebuilt three times, each rebuild held at least as far out as the sample was recorded (a clip only ever lowers a sample). AR: per window of 186 ms, AR(256) fitted under its taper, every unknown solved at once by exact least squares ([`lpc`](https://github.com/audiojs/denoise/tree/main/packages/lpc)'s `arFill`), refitted and solved again until the fill moves by under 1 %, at most 8 times (Janssen, Veldhuis & Vries 1986). Sparse: A-SPADE (Kitić, Bertin & Gribonval 2015) as the declipping survey's code runs it (Záviška, Rajmic, Ozerov & Rencker 2021), the fewest DFT lines that agree with what was recorded, per block of 93 ms and per block of 186 ms: the long block resolves a held note's partials (a held chord clipped to 1 dB, half a second: 11.6 → 14.2 dB), the short one follows speech and attacks. No one of the three wins everywhere, so they are blended, region by region, by weights chosen by cross-validation (Stone 1974; stacked regressions, Breiman 1996): the clipped sound is clipped once more, at the level that takes as large a share of what the first clip left as the first took of the whole; each method rebuilds that; the weights, on a grid of tenths over the three, are those whose blend lies nearest what is known there (the samples the second clip hid, and the bounds of those the first took), read per 93 ms over ±1 s. A blend of consistent rebuilds is consistent; each rebuild runs only where its weight is not 0. Samples off the rails come back bit-exact; a sound over 30 s is rebuilt in pieces crossfaded over 2 s.
|
|
655
|
+
Every sample at a rail is then rebuilt three times, each rebuild held at least as far out as the sample was recorded (a clip only ever lowers a sample). AR: per window of 186 ms, AR(256) fitted under its taper, every unknown solved at once by exact least squares ([`lpc`](https://github.com/audiojs/denoise/tree/main/packages/lpc)'s `arFill`), refitted and solved again until the fill moves by under 1 %, at most 8 times (Janssen, Veldhuis & Vries 1986). Sparse: A-SPADE (Kitić, Bertin & Gribonval 2015) as the declipping survey's code runs it (Záviška, Rajmic, Ozerov & Rencker 2021), the fewest DFT lines that agree with what was recorded, per block of 93 ms and per block of 186 ms: the long block resolves a held note's partials (a held chord clipped to 1 dB, half a second: 11.6 → 14.2 dB), the short one follows speech and attacks. A block that is white noise, its lines' spectral flatness (geometric over arithmetic mean of their power) within four standard deviations of white Gaussian noise's e^(−γ), has no lines to keep: A-SPADE meets its residual there only once it keeps every line, after 300 iterations of the block's transform pair, so the block is left as recorded. Clipped speech's and chords' blocks (clipped to 1–30 dB SDR) lie 15 deviations or more off it at 8 kHz, 21 at 16 and 22.05 kHz, 43 at 44.1 kHz and up, and the take's first block, which holds a quarter of its samples, 7.6 at 8 kHz, 11.6 at 16, 12.9 at 22.05 and 22.5 or more from 44.1 kHz; a whole block of speech clipped to 1 dB is as flat as 0.25 at 8 and 16 kHz, 0.13 at 44.1. The take's last block holds 1 to a quarter of its samples, so few that it can read as white though it holds speech or a chord (with under 21, a flatness of 0 is within four deviations), and the bound then leaves it as recorded: of clipped speech and a chord cut to 24 lengths of 0.5–3 s, 21 of 125 last blocks at 8 kHz in blocks of 93 ms, 11 of 111 at 22.05 kHz in blocks of 186 ms, 0 to 5 of 111–128 at the other rates and lengths. Its samples lie in its window's first quarter, so its share of each in that rebuild, under a sixth, stays as recorded; what that costs in SNR is not measured. Of 116 takes a curve restores (109 of 300 random ones: speech, tones, Gaussian or uniform noise 5–55 dB down, half through tanh or arctan at drive 1–6; and 7 named ones), 102 come back as from 0.5.1 bit for bit and 11 within 0.1 dB; white noise through tanh at drive 4 1.1 dB under it (22.3 → 21.3 dB: the run's last iterations had pushed its few clipped peaks outward), one noisy take 0.26 dB under, one 0.13 over. 8192 stereo frames of a uniform noise take 3.6 s where 0.5.1 took 40, most of it the curve's fit (one loaded machine). The bound holds for a rail's blocks as for a curve's: given a rail (or `clipLevel`), white Gaussian noise clipped at 1, 1.5 and 2 σ (31, 13 and 4 % of it) comes back with the SNR it was clipped to, to 0.01 dB, where 0.5.1 restored 1.4–1.5, 1.1–1.4 and 0.9–1.2 dB (seven 0.3 s takes a level, 16–96 kHz); in 23 of 54 such takes (16 and 44.1 kHz) 1 to 4 samples at the rail come back moved outward, by up to 3.2·10⁻², and every other sample as clipped. A uniform noise clipped by 30 % comes back as clipped (0.5.1: 1.2–2.1 dB), speech under white noise 6 dB over it 0.05–0.35 dB under 0.5.1, at 0 dB and over bit for bit; read blind as a curve, that white noise comes back 1.7–2.4 dB over 0.5.1 at 1 σ and 0.6–1.9 at 1.5 σ. Given its rail, 0.3 s of the white noise takes 0.1–2.8 s where 0.5.1 took 5.9–66 s (16–96 kHz; the seconds depend on the machine's load); a clipped pink noise's blocks are not white, and it takes what it took (83–111 s at 96 kHz). No one of the three wins everywhere, so they are blended, region by region, by weights chosen by cross-validation (Stone 1974; stacked regressions, Breiman 1996): the clipped sound is clipped once more, at the level that takes as large a share of what the first clip left as the first took of the whole; each method rebuilds that; the weights, on a grid of tenths over the three, are those whose blend lies nearest what is known there (the samples the second clip hid, and the bounds of those the first took), read per 93 ms over ±1 s. A blend of consistent rebuilds is consistent; each rebuild runs only where its weight is not 0. Samples off the rails come back bit-exact; a sound over 30 s is rebuilt in pieces crossfaded over 2 s.
|
|
596
656
|
|
|
597
657
|
```js
|
|
598
658
|
declip(data, { fs: 44100 }) // each side's rail (or band, or curve) found; none: untouched
|
|
@@ -605,6 +665,13 @@ declip(data, { fs: 44100, clipLevel: 0.95 }) // a known rail,
|
|
|
605
665
|
| `order` | `256` | AR order of the AR rebuild; `512` takes it on dense music up to 2 dB closer, in about 3× the time |
|
|
606
666
|
| `fs` | `44100` | sample rate, Hz |
|
|
607
667
|
|
|
668
|
+
On every core: the rebuild is a run of jobs, each sparse block and each AR window one, each made from the sound and the clip's mask alone. `declipAsync` hands each batch of them to a `map` of yours, which may make them anywhere at once; they are put back together in the one order, so the output is `declip()`'s, bit for bit. [audio](https://github.com/audiojs/audio) makes them on worker threads (its `parallel.js`; its `declip()` and `auto()`): a clipped 2 s take at 48 kHz, 38.5 s in turn, 9.2 s on 8 threads, a 14-core machine under other load all along.
|
|
669
|
+
|
|
670
|
+
```js
|
|
671
|
+
import { declipAsync, solve } from '@audio/denoise-declip'
|
|
672
|
+
await declipAsync(data, { fs: 48000 }, (shared, jobs) => pool.map(jobs, job => solve(shared, job))) // each job anywhere
|
|
673
|
+
```
|
|
674
|
+
|
|
608
675
|
`node scripts/declip.js` clips speech (audio-lena) and music ("Vibe Ace", Brahms, the trumpet loop, as `repair`), 6 s of each, peak-normalized and cut at the level that leaves the clipped sound 1–20 dB from the original (the input SDR of the declipping survey), and measures the SDR after, dB, declip (finding the rails itself) · FFmpeg `adeclip` at its defaults:
|
|
609
676
|
|
|
610
677
|
| input SDR | 1 dB | 3 dB | 7 dB | 10 dB | 15 dB | 20 dB |
|
|
@@ -1158,6 +1225,19 @@ Reverberant speech (`vbreverb`): a quarter of the clean test utterances, 206, th
|
|
|
1158
1225
|
On the training utterances (`vbreverb-train`, 126): PESQ 2.36 → 2.64 → 2.61 (input, 0.4, 0.5). The constants were chosen on `scripts/dereverb.py train`: VoiceBank training speakers in the even-numbered rooms, 1.8–4.5 s utterances and 25–41 s takes. Of the 206 reverberant test utterances 18 % (0.4) and 25 % (0.5) come out untouched: rooms with little tail, which the dry and diffuse checks pass; 0.6 passes one more, p257_291, whose speaker holds a vowel's pitch as a singer holds a note (the music check), PESQ 2.606 → 2.604, the other 205 bit for bit.
|
|
1159
1226
|
|
|
1160
1227
|
|
|
1228
|
+
### Allocation in a first stream
|
|
1229
|
+
|
|
1230
|
+
`node scripts/firststream.js [seconds] [--own] [--flags=a,b] [--runs=N]` runs `specsub`, `wiener`, `omlsa` and `dewind`, each alone in a fresh Node, as a real-time host calls its `audio.js` processor: stereo at 44.1 kHz in blocks of 128 frames, at its defaults, its inputs and outputs made before any count, on the contract validator's noise (σ 0.15) and on speech (audio-lena, 12.3 s looped) 20 dB over pink noise. Each second of sound it reads what the young generation, the stores of typed arrays and the old generation take between two forced minor collections, the measure of test.js and of the validator; then 10 s of a second instance in the same process; and a processor that copies its input through the same harness, the measure's own floor. Under the validator's flags (synchronous compilation, no pretenuring, no concurrent sweeping of array buffers) or, with `--own`, Node's own, and with `--flags` more V8 flags; `--runs=N` repeats each in N fresh processes and reads seconds 20 on, since what V8 compiles on its own thread lands at a moment that differs from run to run. Each processor's section has its table. In short:
|
|
1231
|
+
|
|
1232
|
+
| | 0–1 s, the validator's flags (Node's own) | 16–90 s, either | Node 20, its own flags, 20 runs |
|
|
1233
|
+
|---|---|---|---|
|
|
1234
|
+
| `specsub` | 11.2 to 24.6 MB (21.2 to 47.0) | at most 2.0 KB a second | went on allocating 118 to 135 KB a second in 9 of 20 runs |
|
|
1235
|
+
| `wiener` | 12.5 to 29.1 MB (24.1 to 54.1) | at most 2.7 KB a second | 118 to 171 KB a second in 12 of 20 |
|
|
1236
|
+
| `omlsa` | 21.5 to 86.7 MB (72.6 to 121.0) | at most 2.1 KB a second | 38 KB a second in 1 of 20 |
|
|
1237
|
+
| `dewind` | 28.6 to 90.4 MB (36.4 to 97.3) | at most 2.7 KB a second | at most 1.2 KB in seconds 20 to 30, in 20 of 20 |
|
|
1238
|
+
|
|
1239
|
+
What allocates there is V8 at work: the code a stream runs each frame, interpreted until compiled, and each path first taken later (a tracker's window closing, others the sound decides), which stops the compiled code once. After 16 s at most 2.7 KB a second on any Node, beside the copying processor's 1.7 KB, as test.js holds them to the floor in steady state; the one steady allocation found is Node 20's under its own flags, where V8 11.3, compiling on the compiler's thread, can leave noise-estimate's update (its minimum statistics, or its guard of held partials) entering its on-stack-replacement code from the interpreter every frame, its own compiled code never taking over; with `--no-concurrent-recompilation` it did not in 40 runs of the four on Linux (`--own --flags=--no-concurrent-recompilation --runs=5`), at most 1.5 KB in seconds 20 to 30.
|
|
1240
|
+
|
|
1161
1241
|
## Demo
|
|
1162
1242
|
|
|
1163
1243
|
`demo.html` is a self-contained browser demo: pick a noise scenario, pick a method (or `auto`), inspect input/output waveforms, hear the difference, and read the live classifier scores.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-debleed/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-debleed/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-debreath/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-debreath/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-declick/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-declick/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-declip/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-declip/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-decrackle/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-decrackle/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dehum/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dehum/audio'
|
package/members/dehum.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-deplosive/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-deplosive/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dereverb/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dereverb/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-desilence/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-desilence/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-desqueak/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-desqueak/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dewind/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dewind/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dewow/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-dewow/audio'
|
package/members/dewow.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-omlsa/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-omlsa/audio'
|
package/members/omlsa.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-spectral/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-spectral/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-wiener/audio'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@audio/denoise-wiener/audio'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/denoise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Noise reduction and restoration: gate, spectral subtraction, Wiener, OM-LSA, dehum, declick, decrackle, declip, dewind, deplosive, deesser, debreath, dereverb, debleed, dewow, desqueak",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,17 +9,24 @@
|
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"default": "./index.js"
|
|
11
11
|
},
|
|
12
|
-
"./package.json": "./package.json"
|
|
12
|
+
"./package.json": "./package.json",
|
|
13
|
+
"./*": {
|
|
14
|
+
"types": "./members/*.d.ts",
|
|
15
|
+
"default": "./members/*.js"
|
|
16
|
+
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
15
19
|
"index.js",
|
|
16
|
-
"*.d.ts"
|
|
20
|
+
"*.d.ts",
|
|
21
|
+
"members/"
|
|
17
22
|
],
|
|
18
23
|
"scripts": {
|
|
19
24
|
"test": "node test.js",
|
|
20
25
|
"test:all": "npm test --workspaces --if-present && npm test",
|
|
21
26
|
"measure": "node scripts/measure.js",
|
|
22
|
-
"publish:all": "npm publish --workspaces && npm publish"
|
|
27
|
+
"publish:all": "node ../compile/tools/tested.js && npm publish --workspaces && npm publish",
|
|
28
|
+
"members": "node scripts/members.js",
|
|
29
|
+
"prepublishOnly": "node ../compile/tools/tested.js && node scripts/members.js --check"
|
|
23
30
|
},
|
|
24
31
|
"repository": {
|
|
25
32
|
"type": "git",
|
|
@@ -51,19 +58,19 @@
|
|
|
51
58
|
},
|
|
52
59
|
"dependencies": {
|
|
53
60
|
"@audio/vad": "^2.0.1",
|
|
54
|
-
"@audio/noise-estimate": "^2.
|
|
55
|
-
"@audio/denoise-spectral": "^0.
|
|
56
|
-
"@audio/denoise-wiener": "^0.
|
|
57
|
-
"@audio/denoise-omlsa": "^0.
|
|
58
|
-
"@audio/denoise-dehum": "^0.7.
|
|
61
|
+
"@audio/noise-estimate": "^2.4.0",
|
|
62
|
+
"@audio/denoise-spectral": "^0.4.0",
|
|
63
|
+
"@audio/denoise-wiener": "^0.5.0",
|
|
64
|
+
"@audio/denoise-omlsa": "^0.7.0",
|
|
65
|
+
"@audio/denoise-dehum": "^0.7.2",
|
|
59
66
|
"@audio/denoise-declick": "^0.4.0",
|
|
60
67
|
"@audio/denoise-decrackle": "^0.4.0",
|
|
61
|
-
"@audio/denoise-declip": "^0.5.
|
|
62
|
-
"@audio/denoise-dewind": "^0.
|
|
63
|
-
"@audio/denoise-deplosive": "^0.
|
|
68
|
+
"@audio/denoise-declip": "^0.5.1",
|
|
69
|
+
"@audio/denoise-dewind": "^0.5.0",
|
|
70
|
+
"@audio/denoise-deplosive": "^0.4.0",
|
|
64
71
|
"@audio/denoise-debreath": "^0.4.0",
|
|
65
72
|
"@audio/denoise-dereverb": "^0.6.0",
|
|
66
|
-
"@audio/denoise-detect": "^0.
|
|
73
|
+
"@audio/denoise-detect": "^0.8.0",
|
|
67
74
|
"@audio/dynamics-gate": "^0.1.4",
|
|
68
75
|
"@audio/denoise-repair": "^0.4.0",
|
|
69
76
|
"@audio/quality": "^1.0.0",
|
|
@@ -71,7 +78,7 @@
|
|
|
71
78
|
"@audio/denoise-desilence": "^0.2.1",
|
|
72
79
|
"@audio/denoise-debleed": "^0.3.0",
|
|
73
80
|
"@audio/denoise-dewow": "^0.3.0",
|
|
74
|
-
"@audio/denoise-desqueak": "^0.
|
|
81
|
+
"@audio/denoise-desqueak": "^0.4.0"
|
|
75
82
|
},
|
|
76
83
|
"devDependencies": {
|
|
77
84
|
"audio-lena": "^3.0.0",
|