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