annotate Problems/AudioDeclipping_reconstruct.m @ 161:f42aa8bcb82f ivand_dev

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