Debian Codegraph @

dwtest/test_Sound_noiseReduction.praat

raw
1 # test_Sound_noiseReduction.praat
2 # djmw 20190326, 20210831
3
4 appendInfoLine: "test_Sound_noiseReduction.praat"
5
6
7 @ test_reduction
8 @test_numberOfBands: 10
9
10 appendInfoLine: "test_Sound_noiseReduction.praat OK"
11
12 procedure test_reduction
13 appendInfoLine: tab$, "test_reduction"
14 .sound = Create Sound from formula: "test", 1, 0, 1, 44100, "0.0"
15 Formula: "randomGauss(0,0.1) + if x < 0.5 then 0.5*sin(2*pi*377*x) else 0 fi"
16 .spectrum = To Spectrum: "no"
17 .bandEnergy = Get band energy: 1000, 9000
18 for .i to 10
19 .db = -10 * (.i - 1)
20 selectObject: .sound
21 .copy = Copy: string$ (.db)
22 .soundReduced = Reduce noise: 0.5, 1, 0.025, 80, 10000, 40, .db, "spectral-subtraction"
23 .spectrumReduced = To Spectrum: "no"
24 .bandEnergyReduced = Get band energy: 1000, 9000
25 appendInfoLine: tab$, tab$, "db=", .db, " ", 10* log10 (.bandEnergyReduced/4e-10), " ",
26 ... 10* log10 (.bandEnergyReduced / .bandEnergy), " ", .bandEnergy / .bandEnergyReduced
27 removeObject: .spectrumReduced, .soundReduced, .copy
28 endfor
29 removeObject: .spectrum, .sound
30 appendInfoLine: tab$, "test_reduction OK"
31 endproc
32
33 procedure test_numberOfBands: .numberOfTries
34 appendInfoLine: tab$, "test_numberOfBands"
35 for .i to .numberOfTries
36 .samplingFrequency = randomUniform(1000, 50000)
37 .sound = Create Sound from formula: "test", 1, 0, 1, .samplingFrequency, "0.0"
38 .windowLength = randomUniform (0.005,0.06)
39 .soundReduced = Reduce noise: 0.5, 1, .windowLength, 80, 10000, 40, -20, "spectral-subtraction"
40 appendInfoLine: tab$, tab$, "Fmax = ", .samplingFrequency, " windowLength = ", .windowLength
41 removeObject: .sound, .soundReduced
42 endfor
43 appendInfoLine: tab$, "test_numberOfBands OK"
44 endproc