dnoise

dnoise — Reduces noise in a file.

Description

This is a noise reduction scheme using frequency-domain noise-gating.

Syntax

dnoise [flags] -i noise_ref_file  -o output_soundfile  soundfile_format  input_soundfile

Initialization

Dnoise specific flags:

  • (no flag) input soundfile to be denoised

  • -i fname input reference noise soundfile

  • -o fname output soundfile

  • -N fnum # of bandpass filters (default: 1024)

  • -w fovlp filter overlap factor: {0,1,(2),3} DON'T USE -w AND -M

  • -M awlen analysis window length (default: N-1 unless -w is specified)

  • -L swlen synthesis window length (default: M)

  • -D dfac decimation factor (default: M/8)

  • -b btim begin time in noise reference soundfile (default: 0)

  • -B smpst starting sample in noise reference soundfile (default: 0)

  • -e etim end time in noise reference soundfile (default: end of file)

  • -E smpend final sample in noise reference soundfile (default: end of file)

  • -t thr threshold above noise reference in dB (default: 30)

  • -S gfact sharpness of noise-gate turnoff, range: 1 to 5 (default: 1)

  • -n numfrm number of FFT frames to average over (default: 5)

  • -m mingain minimum gain of noise-gate when off in dB (default: -40)

Soundfile format options:

  • -A AIFF format output

  • -W WAV format output

  • -J IRCAM format output

  • -h skip soundfile header (not valid for AIFF/WAV output)

  • -8 8-bit unsigned char sound samples

  • -c 8-bit signed_char sound samples

  • -a alaw sound samples

  • -u ulaw sound samples

  • -s short_int sound samples

  • -l long_int sound samples

  • -f float sound samples. Floats also supported for WAV files. (New in Csound 3.47.)

Additional options:

  • -R verbose - print status info

  • -H [N] print a heartbeat character at each soundfile write.

  • -- fname output to log file fname

  • -V verbose - print status info

[Note] Note

DNOISE also looks at the environment variable SFOUTYP to determine soundfile output format.

The -i flag is used for a reference noise file (normally created from a short section of the denoised file, where only noise is audible). The input soundfile to be denoised can be given anywhere on the command line, without a flag.

Performance

This is a noise reduction scheme using frequency-domain noise-gating. This should work best in the case of high signal-to-noise with hiss-type noise.

The algorithm is that suggested by Moorer & Berger in Linear-Phase Bandsplitting: Theory and Applications presented at the 76th Convention 1984 October 8-11 New York of the Audio Engineering Society (preprint #2132) except that it uses the Weighted Overlap-Add formulation for short-time Fourier analysis-synthesis in place of the recursive formulation suggested by Moorer & Berger. The gain in each frequency bin is computed independently according to


gain = g0 + (1-g0) * [avg / (avg + th*th*nref)] ^ sh
      

where avg and nref are the mean squared signal and noise respectively for the bin in question. (This is slightly different than in Moorer & Berger.)

The critical parameters th and g0 are specified in dB and internally converted to decimal values. The nref values are computed at the start of the program on the basis of a noise_soundfile (specified in the command line) which contains noise without signal.

The avg values are computed over a rectangular window of m FFT frames looking both ahead and behind the current time. This corresponds to a temporal extent of m*D/R (which is typically (m*N/8)/R). The default settings of N, M, and D should be appropriate for most uses. A higher sample rate than 16 Khz might indicate a higher N.

Examples

Here is an example of the dnoise utility. It uses the file dnoise.csd, MathewsNoise.wav and MathewsN.wav.

Example 1348. Example of the dnoise utility.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac   -m0  ;;;realtime audio out, with limiter protection
; For Non-realtime ouput leave only the line below:
; -o dnoise.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

; by Menno Knevel 2022

; analyze sound file and output result, and be verbose 
ires1 system_i 1,{{ dnoise -V -W        -i MathewsNoise.wav -o outfile01.wav MathewsN.wav }}                  ; default settings (1024 bandoass filters)
ires2 system_i 1,{{ dnoise -V -W -N8    -i MathewsNoise.wav -o outfile02.wav MathewsN.wav }}                  ; LoFi, only 8 bandpass filters
ires3 system_i 1,{{ dnoise -V -W -N4096 -i MathewsNoise.wav -o outfile03.wav MathewsN.wav }}                  ; 4096 bandpass filters used

instr 1 ; untreated signal
asig    diskin2   "MathewsN.wav", 1                                         ; sample = 17.6 secs
prints  "\n---***YOU NOW HEAR THE UNTREATED SOUND SAMPLE***---\n"
outs    asig, asig
endin

instr 2

prints  "\n---***YOU NOW HEAR THE DENOISED FILE WITH DEFAULT SETTINGS:***---\n"
adnoise diskin2 p4, 1                 
outs    adnoise, adnoise
endin

instr 3

prints  "\n---***YOU NOW HEAR THE LoFi FILE:***---\n"
adnoise diskin2 p4, 1                 
outs    adnoise, adnoise
endin

instr 4

prints  "\n---***YOU NOW HEAR THE DENOISED FILE WITH MANY BANDS, CREATING SOME ECHOES:***---\n"
adnoise diskin2 p4, 1                 
outs    adnoise, adnoise
endin
</CsInstruments>
<CsScore>

i1 1 17.6                   ; untreated signal

i2 20 17.6 "outfile01.wav"  ; default settings 
i3 40 17.6 "outfile02.wav"  ; LoFi
i4 60 17.6 "outfile03.wav"  ; echo-y
e
</CsScore>
</CsoundSynthesizer>


Credits

Author: Mark Dolson

August 26, 1989

Author: John ffitch

December 30, 2000

Updated by Rasmus Ekman on March 11, 2002.