ivan@136
|
1 function reconstructed=AudioDeclipping_reconstruct(y, Problem, SparseDict)
|
ivan@136
|
2 %% Audio declipping Problem reconstruction function
|
ivan@136
|
3 %
|
ivan@136
|
4 % This reconstruction function is using sparse representation y
|
ivan@140
|
5 % in dictionary Problem.A to reconstruct declipped audio.
|
ivan@140
|
6 %
|
ivan@140
|
7 % [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an
|
ivan@140
|
8 % evaluation framework for sparse representations and dictionary
|
ivan@140
|
9 % learning algorithms," V. Vigneron et al. (Eds.): LVA/ICA 2010,
|
ivan@140
|
10 % Springer-Verlag, Berlin, Germany, LNCS 6365, pp. 418-425
|
ivan@140
|
11 % [2] A. Adler, V. Emiya, M. G. Jafari, M. Elad, R. Gribonval, and M. D.
|
ivan@140
|
12 % Plumbley, “Audio Inpainting,” submitted to IEEE Trans. Audio, Speech,
|
ivan@140
|
13 % and Lang. Proc., 2011, http://hal.inria.fr/inria-00577079/en/.
|
ivan@136
|
14
|
ivan@136
|
15 %
|
ivan@136
|
16 % Centre for Digital Music, Queen Mary, University of London.
|
ivan@136
|
17 % This file copyright 2009 Ivan Damnjanovic.
|
ivan@136
|
18 %
|
ivan@136
|
19 % This program is free software; you can redistribute it and/or
|
ivan@136
|
20 % modify it under the terms of the GNU General Public License as
|
ivan@136
|
21 % published by the Free Software Foundation; either version 2 of the
|
ivan@136
|
22 % License, or (at your option) any later version. See the file
|
ivan@136
|
23 % COPYING included with this distribution for more information.
|
ivan@136
|
24 %%
|
ivan@136
|
25
|
ivan@136
|
26 windowSize = Problem.windowSize;
|
ivan@136
|
27 overlap = Problem.overlap;
|
ivan@136
|
28 ws = Problem.ws(windowSize);
|
ivan@136
|
29 wa = Problem.wa(windowSize);
|
ivan@136
|
30 A = Problem.B;
|
ivan@136
|
31
|
ivan@136
|
32 orig = Problem.original;
|
ivan@136
|
33 clipped = Problem.clipped;
|
ivan@136
|
34 clipMask = Problem.clipMask;
|
ivan@136
|
35
|
ivan@136
|
36 % reconstruct audio frames
|
ivan@136
|
37
|
ivan@136
|
38 xFrames = diag(ws)*(A*y);
|
ivan@136
|
39 wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2));
|
ivan@136
|
40
|
ivan@136
|
41 % overlap and add
|
ivan@136
|
42
|
ivan@136
|
43 rec = col2imstep(xFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]);
|
ivan@136
|
44 wNorm = col2imstep(wNormFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]);
|
ivan@136
|
45 wNorm(find(wNorm==0)) = 1;
|
ivan@136
|
46 recN = rec./wNorm;
|
ivan@136
|
47
|
ivan@136
|
48 % change only clipped samples
|
ivan@136
|
49
|
ivan@136
|
50 recSignal = orig.*double(~clipMask) + recN.*double(clipMask);
|
ivan@136
|
51
|
ivan@136
|
52 %% output structure image+psnr %%
|
ivan@136
|
53 reconstructed.audioAllSamples = recN;
|
ivan@136
|
54 reconstructed.audioOnlyClipped = recSignal;
|
ivan@136
|
55 [reconstructed.snrAll , reconstructed.snrMiss] = SNRInpaintingPerformance(orig, clipped, recSignal, clipMask, 1);
|
ivan@136
|
56
|
ivan@136
|
57 end |