@audio/denoise 0.12.0 → 0.12.2
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 +4 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -74,13 +74,15 @@ classify(data, fs) // → { method,
|
|
|
74
74
|
1. **hum → `dehum`**: dehum's own measurement finds a mains series, and the lines it finds, A-weighted (IEC 61672-1), lie within 50 dB of the program's A-weighted level (`HUM_LEVEL`, −50; a series further under goes unheard and is left). A lone 60 Hz line 30 dB under a voice is there, and the ear hears 60 Hz 26 dB less than 1 kHz.
|
|
75
75
|
2. **clicks → `declick`**: over 1 a second (`CLICK_RATE`) of impulses standing 32× out of the AR(30) error's local scale (the median of its 1.5 ms block RMS over ±12 ms, as declick judges), alone: no like of half its size 2.5–40 ms either side (a voice's pulses, creak down to 25 Hz), and no sound 10 dB louder after it than before (a plosive's burst, a note's attack).
|
|
76
76
|
3. **sibilance → `deesser`**: 5–9 kHz over 0.2–2 kHz power over 8.
|
|
77
|
-
4. **noise bed → `omlsa`**: a floor within 25 dB of the program (`BED_SNR`; the program: frames within 40 dB of the loudest), shown in its *pauses* or in *steady bands*. The pauses are runs of 0.15 s or more within 6 dB of the frame level's 10th percentile that hold noise or hold the floor; the bed is their median level. *Noise*: flat and without lines
|
|
77
|
+
4. **noise bed → `omlsa`**: a floor within 25 dB of the program (`BED_SNR`; the program: frames within 40 dB of the loudest), shown in its *pauses* or in *steady bands*. The pauses are runs of 0.15 s or more within 6 dB of the frame level's 10th percentile that hold noise or hold the floor; the bed is their median level. A take has pauses where it stops: one whose loudest frame stands less than 6 dB over its quietest tenth (the pause band's own 6 dB) never stops, and its quietest frames are its program (a test tone, a chord held through, a sweep, a noise alone), so the steady bands alone read its bed. Digital silence beside the program (a lead-in of zeros, zeros between phrases, a gate's closed stretches) is no pause of it: frames 80 dB under the loudest count for nothing, and the pauses that hold the bed read it as they do without the zeros. *Noise*: flat, in the bands from 300 Hz, and without lines but those it holds through the take: a band's persistence less its persistence a second on, between pause frames that far apart, where the band draws the rest of its bins anew. A bed's own lines (radio static's, a carrier's, a fan's) hold their bins a second on as from frame to frame; a voice's or a passage's partials have moved, and a held note's pauses are its partials, not flat. A band held within 0.05 of 1, as noise is within 0.05 of 0 (the bound set by that symmetry alone), draws nothing anew: it holds a line alone and its leakage, no bed. An archival radio transmission, its static 7 dB under the voice with lines at 345, 517 and 861 Hz, read no bed while every line counted against it; a tone stepping 20 dB down over nothing read one 17 dB under while a line alone passed for noise with its own lines. *The floor*: a bed lies under the program all the time, so in each band the pauses sit where the band sinks to over the whole take (its 5th percentile), no further over it than Gaussian noise's own spread puts them (1.645 · 4.34/√(n/1.5) dB over n bins) plus 3 dB for the bed's slow wander (the bands' median), and they hold no partials that come and go (median persistence under 0.1; babble reads 0.04–0.08). A line held through every pause and across the notes, an engine's, a fan's, a mains-like tone, is part of the floor; a quiet passage of music isn't: its notes come and go, and its pauses stand over the floors other passages sink to. *Steady bands*: a band whose quieter half varies no more than twice what Gaussian noise over its bins would, without lines. A line is a band's fine structure (log power less its ±4-bin mean) correlated with the frame N back, which shares no sample: a partial holds its bins, noise draws them anew; held through the take, it correlates as well with the frame a second back.
|
|
78
78
|
5. **wind → `dewind`**: in over a tenth of the 0.15 s blocks, the low end (< 200 Hz) within 20 dB of the program, 6 dB over the 300–2000 Hz band, and without lines, where no bed shows. Wind is turbulence at the microphone, without a period (Nelke & Vary, IWAENC 2014); a bass line or a voice's low end repeats at its pitch.
|
|
79
79
|
6. **steady tones → `dehum`**: dehum's `tones()` finds lines held through the program's pauses and under it, their phase turning as one line's (a whine, a test tone; see [dehum](#dehum)), A-weighted within 50 dB of the program, as hum is.
|
|
80
80
|
7. otherwise **`none`**.
|
|
81
81
|
|
|
82
82
|
Where `tones()` finds steady tones and another route is taken (clicks, sibilance, a bed, wind), `dehum` runs first: a gain floored per bin takes a line standing over the bed down by its floor at most (speech, a 7 kHz line at 0.3 and white noise at 0.01: `wiener` alone 10.5 dB SNR, `dehum` then `wiener` 24.2). `force` runs the forced method alone.
|
|
83
83
|
|
|
84
|
+
A line alone is no bed. Over 576 takes that hold nothing but lines (`node scripts/tonebed.mjs lines`: sines from 100 Hz to 7 kHz, a chord, a reed; in bursts, at two levels, stepping 20 dB down, fading 30 dB, held, held at −40 dBFS; over digital silence and over a 16-bit file's dither; at 8 to 96 kHz) a bed reads in 138, where 0.7.1 read one in 260 and 0.8.0 in 450, each of the 138 a take both read one in: a line at two levels, stepping down or fading over dither, or fading over digital silence (12), whose quiet end sits at every band's floor and reads as the floor, a fan's lines and all; and 3150 Hz at 8 kHz or 7 kHz at 16 kHz held over dither, past the top band's edge (the bands stop short of fs/2 by up to half an octave), where the program is out of their sight. Under the tones of `matrix` (1 kHz, a chord, a sweep, a reed), white Gaussian noise 20, 30 and 40 dB down reads within 1.7 dB of its level, a bed at 20 dB and none at 30 or 40, as before (under 300 Hz bursts 1.3 to 2.7 dB under at 20 and 30 dB: their program holds the bed between them). On `scripts/detect.js`'s material (`compare`: 2121 tuning items, 3110 test) no method changes and no bed reading moves.
|
|
85
|
+
|
|
84
86
|
Every bed goes to `omlsa`, and a bed outranks wind, by what each reducer made of the noisy speech the router sends them (`node scripts/detect.js tune reduce`, `python scripts/detect.py score tune`; PESQ wideband, STOI, DNSMOS SIG at 16 kHz as `scripts/speech.py` scores):
|
|
85
87
|
|
|
86
88
|
| noise (takes) | PESQ: noisy · `wiener` · `omlsa` · `dewind` | STOI, the same | SIG, the same |
|
|
@@ -652,7 +654,7 @@ Lossy coding (MP3, AAC, Opus) leaves no flat top: it spreads the rail into a ban
|
|
|
652
654
|
|
|
653
655
|
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).
|
|
654
656
|
|
|
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:
|
|
657
|
+
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: run from k = 1, A-SPADE's least residual stays the recorded block's own until k passes 0.39–0.46 of its lines, and it meets its residual only as k nears every line, after 230–371 passes of the block's transform pair (1024 to 16384 samples). So a white block's k starts at 0.3 of its lines: 62–65 passes. Its samples are not those of the run from k = 1 (0.5.1's), as on a white block the iterate depends on the run's whole path, and its SNR lands near that run's, on either side. Of the 116 of 311 takes a curve restores (300 random ones: speech, tones, Gaussian or uniform noise 5–55 dB down, half through tanh or arctan at drive 1–6; and 11 named ones), 102 come back as from k = 1 bit for bit and 13 within 0.013 dB, either way, the 116th, a uniform noise, having no sound before it to measure against (CPU 279 s from k = 1, 249 s bounded); hard-clipped white and uniform noise at 16–96 kHz, the rail given or found, and white noise through tanh at drive 4, 0.07 dB under it to 0.03 over (25 takes, 125 s and 30 s); 300 random takes of white or uniform noise at 8–48 kHz, clipped or through a curve, 1.45 dB under to 1.21 over, 11 of them more than 0.1 dB under and 10 more than 0.1 over, 0.004 dB over on average (866 s and 281 s); 8192 stereo frames of a uniform noise through the manifest, 5.8 s and 1.5 s; the seconds are CPU time on one loaded machine, and a second run gave other seconds in about the same ratios (`node packages/denoise-declip/scripts/white.js`, `--curves`, `--random 300`; the white test's spread, 0.62–0.70/√s for s samples on the take, `--flatness`). Clipped speech's and chords' blocks read otherwise at 8–96 kHz (`test.js`) and run from k = 1; the take's last block holds 1 to a quarter of its samples and can read white whatever it holds (with under 21, a flatness of 0 is within four deviations), and then starts at 0.3 of its lines too. 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.
|
|
656
658
|
|
|
657
659
|
```js
|
|
658
660
|
declip(data, { fs: 44100 }) // each side's rail (or band, or curve) found; none: untouched
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/denoise",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
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,
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"@audio/denoise-dehum": "^0.7.2",
|
|
66
66
|
"@audio/denoise-declick": "^0.4.0",
|
|
67
67
|
"@audio/denoise-decrackle": "^0.4.0",
|
|
68
|
-
"@audio/denoise-declip": "^0.5.
|
|
68
|
+
"@audio/denoise-declip": "^0.5.2",
|
|
69
69
|
"@audio/denoise-dewind": "^0.5.0",
|
|
70
70
|
"@audio/denoise-deplosive": "^0.4.0",
|
|
71
71
|
"@audio/denoise-debreath": "^0.4.0",
|
|
72
72
|
"@audio/denoise-dereverb": "^0.6.0",
|
|
73
|
-
"@audio/denoise-detect": "^0.8.
|
|
73
|
+
"@audio/denoise-detect": "^0.8.1",
|
|
74
74
|
"@audio/dynamics-gate": "^0.1.4",
|
|
75
75
|
"@audio/denoise-repair": "^0.4.0",
|
|
76
76
|
"@audio/quality": "^1.0.0",
|