@audio/denoise 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +33 -4
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -8,7 +8,7 @@ Single-pass noise reduction. 17 specialised methods + an auto-classifier.
8
8
  |---|---|---|---|---|---|
9
9
  | [denoise](#denoise) | meta | auto | — | varies | "just clean it" |
10
10
  | [gate](#gate) | time | silence | ★ | very low | hard cut at threshold |
11
- | [dehum](#dehum) | time | mains hum | ★★★★ | low | 50/60 Hz + harmonics |
11
+ | [dehum](#dehum) | time | mains hum, steady tones | ★★★★ | low | 50/60 Hz + harmonics; a whine, a test tone |
12
12
  | [specsub](#specsub) | freq | broadband stationary | ★★ | medium | baseline |
13
13
  | [wiener](#wiener) | freq | broadband stationary | ★★★ | medium | general broadband |
14
14
  | [omlsa](#omlsa) | freq | broadband non-stationary | ★★★★ | high | speech in changing noise |
@@ -76,7 +76,10 @@ classify(data, fs) // → { method,
76
76
  3. **sibilance → `deesser`**: 5–9 kHz over 0.2–2 kHz power over 8.
77
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 in the bands from 300 Hz. *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.
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
- 6. otherwise **`none`**.
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
+ 7. otherwise **`none`**.
81
+
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.
80
83
 
81
84
  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):
82
85
 
@@ -156,7 +159,10 @@ dehum(data, { fs }) // 50 or 60 Hz, f
156
159
  dehum(data, { fs, freq: 60 }) // the 60 Hz series, its exact frequency tracked
157
160
  dehum(data, { fs, freq: 60, harmonics: 4 }) // remove 60–240 Hz as told
158
161
  dehum(data, { fs, steady: true }) // a buzz held through the take, an amp's under a guitar
162
+ dehum(data, { fs, tones: [15734] }) // this tone, as told (true, the default: those found)
163
+ dehum(data, { fs, tones: false }) // the mains series alone, as 0.6
159
164
  measure(data, fs) // → { f0, harmonics } or null (import from @audio/denoise-dehum)
165
+ tones(data, fs) // → [{ freq, level, … }] the steady tones found (import alike)
160
166
  ```
161
167
 
162
168
  | Param | Default | |
@@ -164,6 +170,7 @@ measure(data, fs) // → { f0, harm
164
170
  | `freq` | found | Fundamental, Hz. Omitted: the 50 or 60 Hz series, whichever is found. Given: that series, its frequency tracked from there (within ±0.4 %, ±`drift` Hz with `adaptive`) |
165
171
  | `harmonics` | to 8 kHz | Remove h = 1…`harmonics` as told. Omitted: every harmonic to 1 kHz and each line above it that stands out, to 8 kHz |
166
172
  | `steady` | `false` | The hum held through the take: a buzz under an instrument, no edit in it. Each line one phasor through the take, the mains phase refined against them (below) |
173
+ | `tones` | `true` | Steady tones off the mains series, held through the take: those `tones()` finds (below); an array: those frequencies, Hz, as told; `false`: none |
167
174
 
168
175
  Hum is found by `measure()`, one Fourier transform over the signal (its first 80–90 s, taken down to 3 kHz), where a hum line, steady for minutes, gathers into a peak 1/T wide while speech spreads: the fundamental 20 dB over the median of the ±8 Hz around it, or two of the first six harmonics 15 dB, each 6 dB over any other peak within 3 Hz, all harmonics of one fundamental. Under music a line 20 dB under the program is too faint for that, so the band to 1 kHz is also tracked along each series (below) and its lines weighed where the program is quiet around them: hum is there when two or more of the first 20 harmonics stand out by 18 dB, are no more than 60 dB under the signal and stand alone, 6 dB over any other peak within 3 Hz, a third at least of those that stand out (a bar of music repeated exactly is a comb of lines 1/bar apart, lines at 50 and 60 Hz among them, few alone). A faster pattern spaces its teeth past 3 Hz, and where its instrument rings a tooth stands over the next: a kick at 200 bpm repeats every 15 periods of 50 Hz and 18 of 60, a comb every 3.33 Hz with teeth on both series, and in the MUSDB18 preview of Dark Ride's "Burning Bridges" its 50 Hz tooth stands 7 dB over the next one; the take has no pause to hear the line persist in, and 0.5.1 took it for hum (the mix out at 6.0 dB SDR). Neither the line's level nor its neighbours tell such a tooth from hum; the program's comb does, by all its teeth: for each pattern of 1/8 s to 2 s that spans a whole number of mains periods (its comb runs through the series), the share of the positions of its other lines, 40 Hz to 1 kHz, that hold a peak, less the share midway between them, where chance puts as many. The kick scores 0.30 (synthetic kicks 0.44–0.50, two BabySlakh mixes rendered from MIDI at an exact tempo 0.33 and 0.53); the 143 other MUSDB18 previews 0.16 at most, the other 18 BabySlakh mixes 0.20, 200 VocalSet takes, 120 GuitarSet takes, ten readings and five DEMAND noises 0.06. Over a quarter, in a take with no pause, the series is the program's and is left. Through 468 clean takes (MUSDB18's 94 training and 50 test previews, Brahms, Vibe Ace, the Nutcracker and the trumpet whole, 200 VocalSet takes, 120 GuitarSet takes, 30 s each: `node bench/rx/dehum.mjs clean` in `audio`) 0.5.2 changes none; 0.5.1 changed that one. Hum under such a pattern is left too where the take has no pause; with one, its lines and the pattern's within a fraction of a hertz of them go together (59.95 Hz hum 20 dB under the 200 bpm kick after 2 s of room tone: the mix out at 2.0 dB SDR, 0.5.1 alike). A tone held right on a mains line through a take with no pause is taken for hum.
169
176
 
@@ -173,6 +180,28 @@ Where the hum itself jumps (an edit's splice turns its phase, a level step, hum
173
180
 
174
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).
175
182
 
183
+ **Steady tones** (0.7.0). Off the mains series a line held through a take is interference too: a whine, a test tone, a monitor's 15.7 kHz, an electrical or fan line. A held note can be as exact in frequency and level (an organ, a synth), so a line is taken only for what a note does not do through a take whose program comes and goes. `tones()` reads one short-time transform (Hann, ~0.19 s, hop half; 2048 frames at most, spread over a longer take), takes as candidates the peaks of the power each bin holds in four frames of five, 12 dB over the median of the bins 4–40 away, and keeps a line that
184
+ - **holds through the pauses**: the frames where all but the lines sits within 6 dB of its 10th percentile, half a second of them at least; it stands 6 dB over its bins' floor in 95 % of them, its level there within 3 dB (90th over 10th percentile). A take whose program never moves 10 dB (90th over 10th percentile) is left: nothing passes over its lines to tell them from notes;
185
+ - **is never gone under the program**: its five bins hold a quarter of its power in the pauses in 90 % of all frames. In a mix the quietest frames can be where the bass plays alone: in the MUSDB18 preview of Grants' "PunchDrunk" a 220 Hz line held 92 % of the pauses, its level within 1.6 dB and its turns' mean resultant length 0.994, and was there in 32 % of the frames;
186
+ - **turns as one line**: between consecutive pauses holding it, the mean resultant length of its phasor's turns is 0.9 at least (their spread under ~0.8 Hz), and its phase breaks off the turn (by over π/3) in 2 % of the transitions at most, across up to a second of the program too. A note struck again on the same pitch starts at a new phase, a kick tuned to it too (van Waterschoot & Moonen's interframe peak persistence, Proc. IEEE 99(2), 2011, a feedback detector's mark, read on the phase rather than the magnitude);
187
+ - stands within 60 dB of the take; under a found mains series, off its harmonics (±0.5 %).
188
+
189
+ Each is subtracted as a harmonic is: its frequency read from its turn, its phasor per 80 ms Hann frame, weighted by the program's power around it, bridged through the program by Rauch–Tung–Striebel at the likeliest rate of drift (up to a turn of ~0.1 rad a frame: a whine wandering ±0.3 Hz), resynthesized and taken out. What goes of the program is what lies within a fraction of a hertz of the line. A note held through the whole take, struck before it starts and released after it ends, under a melody, is a tone by every mark the take offers and goes (the synthetic drone below); a tone switched on or off inside the take is left, as is one that glides.
190
+
191
+ Measured by `node scripts/tones.mjs` (`case`, `synth`, `music`, `speech`; thresholds chosen on its tune split: VoiceBank's training speakers, the odd-numbered VocalSet singers, every third MUSDB18 training preview, odd BabySlakh mixes, GuitarSet; then read once on the test split, below). Test.js's steady line, audio-lena's first 4 s with a 7 kHz sine at 0.3 and white noise at 0.01: speech SNR −3.8 dB as 0.6 leaves it (and `denoise()` routed it to `none`); 22.8 dB through `dehum` (with the line gone exactly, the noise alone leaves 22.8); 24.2 then through `wiener`, where a notch at 7 kHz, told, then `wiener` reaches 23.8. Tones under VoiceBank+DEMAND's test speakers (4 clips of 4 utterances, ~10–14 s), by phase inversion; tone down / speech SDR, dB, the mean over the clips where found, against a notch (Q 30) told each frequency:
192
+
193
+ | tone under speech | −10 dB | −30 dB | −50 dB | notch, told |
194
+ |---|---|---|---|---|
195
+ | 97 Hz | 92.2 / 60.4 (4 of 4) | not found | not found | 22.8 / 25.3 |
196
+ | 440 Hz | 96.1 / 60.5 (4) | 79.6 / 72.6 (3) | not found | 29.4 / 14.3 |
197
+ | 1 kHz | 85.0 / 64.5 (4) | 80.4 / 72.7 (4) | 45.8 / 82.1 (1) | 32.9 / 25.8 |
198
+ | 3.15 kHz | 67.2 / 69.9 (4) | 89.3 / 77.8 (4) | 57.3 / 86.9 (2) | 37.8 / 31.5 |
199
+ | 7 kHz | 60.1 / 72.0 (4) | 89.4 / 83.9 (4) | 86.7 / 96.5 (3) | 40.8 / 36.8 |
200
+ | 12 kHz | 57.8 / 79.1 (4) | 76.9 / 84.8 (4) | 76.5 / 92.9 (4) | 41.8 / 41.9 |
201
+ | 15.734 kHz | 57.5 / 82.7 (4) | 72.3 / 86.0 (4) | 81.0 / 92.6 (4) | 41.2 / 47.4 |
202
+
203
+ A whine at 1234.5 Hz with harmonics 2–4, 20 dB under: 84.9 / 66.8 (notch 34.6 / 21.6); a 3 kHz tone wandering ±0.3 Hz: 33.5 / 55.2 (36.7 / 31.3); a 2 kHz tone switched on halfway: left. Held notes, nothing added: 15 synthetic takes (organ chords with rests, held sines, a pedal held 85 % of the take under a melody, strings with vibrato, piano), 62 VocalSet long tones (straight, messa, pp, forte, trill, trillo, inhaled), 50 MUSDB18 test previews, 10 BabySlakh mixes, 7 GuitarSet takes and the four pieces: none changed by the tones (one VocalSet take, `f8_long_inhaled_a`, changed by the hum lines as 0.6 changes it, bit for bit); on the tune split, 142 takes, none. A drone held from the first sample to the last under a melody goes, 56 dB of it. VoiceBank+DEMAND test set: of 824 clean utterances none changed, of 824 noisy one (`p232_381`, the bus noise's 38.2 Hz engine line, PESQ 2.211 → 2.204); `denoise()` routes every utterance as before, PESQ 2.30 → 2.30 (that utterance 2.292 → 2.290). Tune split, of 504: one changed (`p228_229`, the metro noise's 2374.6 Hz whine; through `denoise()` 2.472 → 2.491).
204
+
176
205
  Measured by `node scripts/dehum.js`, 0.4.0 → 0.5.1 (0.5.2 alike, every cell): the hum (mains: 12 harmonics at −6 dB per octave; buzz: odd-heavy to 8 kHz, odd h at h^−½, even at 0.3·h^−½, rolling off over 3 kHz; levels drifting ±10 %, f0 0.05 Hz off nominal and wandering) and the program told apart by phase inversion (Hagerman & Olofsson 2004). 50 Hz hum 20 dB under the program, wandering ±0.02 Hz; program SDR per band where the band holds 1 % of the program:
177
206
 
178
207
  | material | hum down, dB | program SDR, dB | <100 Hz | 100–300 | 300–1k | 1–4k | >4k |
@@ -223,8 +252,8 @@ Against iZotope RX 12 De-hum (2026-10, `node bench/rx/dehum.mjs` in `audio`; RX
223
252
 
224
253
  RX's learned Dynamic profile acts as a gate: it takes the hum in the room tone 54–60 dB down and leaves it under the speech, where it takes as much of the voice (18.9 dB mean SDR, the input's 22.6). Tuned, it barely touches the take (3 dB of hum), the best SDR it reaches. 0.5.2 (every score as 0.5.1's) is over RX tuned in SDR in all 18 condition × material cells (buzz 30 dB under music: 35.9 against 32.2, input 31.3), and every clip comes out within 0.2 dB of its input SDR or better. Hum as recorded (MIR-1K singing, DEMAND's washing machine and hallway, five readings, a VoiceBank take): RX's select-all Learn takes its lines up to 18 dB down and the program with them (the rest of the spectrum 1.5–20 dB SDR); dehum takes them 0–14 dB down and leaves the rest 21–60 dB. VocalSet's 60 Hz lines, more than 60 dB under the singing and barely over its room tone, are left as they are (0.4.0 took them 0–7 dB down; RX up to 23, the rest of the spectrum 0.2–12.5 dB).
225
254
 
226
- **Use when:** mains buzz, ground-loop hum, fixed tonal interference.<br>
227
- **Not for:** broadband noise (use `wiener`/`omlsa`); shifting tones (use spectral methods).
255
+ **Use when:** mains buzz, ground-loop hum, fixed tonal interference: a whine, a test tone, an electrical or fan line.<br>
256
+ **Not for:** broadband noise (use `wiener`/`omlsa`); tones that glide or switch on and off inside the take (use spectral methods).
228
257
 
229
258
 
230
259
  ### `dewind`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/denoise",
3
- "version": "0.10.0",
3
+ "version": "0.11.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,
@@ -55,7 +55,7 @@
55
55
  "@audio/denoise-spectral": "^0.3.0",
56
56
  "@audio/denoise-wiener": "^0.4.0",
57
57
  "@audio/denoise-omlsa": "^0.6.0",
58
- "@audio/denoise-dehum": "^0.6.0",
58
+ "@audio/denoise-dehum": "^0.7.0",
59
59
  "@audio/denoise-declick": "^0.4.0",
60
60
  "@audio/denoise-decrackle": "^0.4.0",
61
61
  "@audio/denoise-declip": "^0.5.0",
@@ -63,7 +63,7 @@
63
63
  "@audio/denoise-deplosive": "^0.3.0",
64
64
  "@audio/denoise-debreath": "^0.4.0",
65
65
  "@audio/denoise-dereverb": "^0.6.0",
66
- "@audio/denoise-detect": "^0.6.1",
66
+ "@audio/denoise-detect": "^0.7.0",
67
67
  "@audio/dynamics-gate": "^0.1.4",
68
68
  "@audio/denoise-repair": "^0.4.0",
69
69
  "@audio/quality": "^1.0.0",