Line | |
---|
1 | %% Input must be a spectrogram
|
---|
2 |
|
---|
3 | function s2 = whiten(s,fmax)
|
---|
4 |
|
---|
5 | %Values output by spectrogram are already in [0, 1] range
|
---|
6 |
|
---|
7 | %Square root of spectrogram (of the absolute value?)
|
---|
8 | s1 = sqrt(abs(s));
|
---|
9 | %s1 = sqrt(s);
|
---|
10 |
|
---|
11 | %For each frame, find a quantity similar to the energy"
|
---|
12 |
|
---|
13 | [Nf Nt] = size(s1);
|
---|
14 | energy = nan(Nt,1);
|
---|
15 |
|
---|
16 | for t=1:Nt
|
---|
17 | energy(t) = 1/fmax * sum(s1(:,t).^2);
|
---|
18 | end
|
---|
19 |
|
---|
20 | threshold = quantile(energy, 0.2);
|
---|
21 |
|
---|
22 | lowestix = find(energy<threshold);
|
---|
23 | lowestenergy = energy(lowestix);
|
---|
24 |
|
---|
25 |
|
---|
26 | P = nan(Nf,1);
|
---|
27 | s2 = s1;
|
---|
28 | for f=1:Nf
|
---|
29 | P(f) = sqrt(eps + sum(s1(f,lowestix).^2));
|
---|
30 | s2(f,:) = s1(f,:) ./P(f);
|
---|
31 | end
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.