ivan@161: function reconstructed = AudioDeclipping_reconstruct(y, Problem) ivan@136: %% Audio declipping Problem reconstruction function ivan@136: % ivan@136: % This reconstruction function is using sparse representation y ivan@140: % in dictionary Problem.A to reconstruct declipped audio. ivan@161: % The output structure has following fields: ivan@161: % audioAllSamples - signal with all samples taken from reconstructed ivan@161: % signal ivan@161: % audioOnlyClipped - only clipped samples are reconstructed, ivan@161: % others are taken from original signal ivan@161: % snrAll - psnr of whole signal ivan@161: % snrMiss - psnr of the reconstructed clipped samples ivan@140: % ivan@140: % [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an ivan@140: % evaluation framework for sparse representations and dictionary ivan@140: % learning algorithms," V. Vigneron et al. (Eds.): LVA/ICA 2010, ivan@140: % Springer-Verlag, Berlin, Germany, LNCS 6365, pp. 418-425 ivan@140: % [2] A. Adler, V. Emiya, M. G. Jafari, M. Elad, R. Gribonval, and M. D. ivan@140: % Plumbley, “Audio Inpainting,” submitted to IEEE Trans. Audio, Speech, ivan@140: % and Lang. Proc., 2011, http://hal.inria.fr/inria-00577079/en/. ivan@136: ivan@136: % ivan@136: % Centre for Digital Music, Queen Mary, University of London. ivan@136: % This file copyright 2009 Ivan Damnjanovic. ivan@136: % ivan@136: % This program is free software; you can redistribute it and/or ivan@136: % modify it under the terms of the GNU General Public License as ivan@136: % published by the Free Software Foundation; either version 2 of the ivan@136: % License, or (at your option) any later version. See the file ivan@136: % COPYING included with this distribution for more information. ivan@136: %% ivan@136: ivan@136: windowSize = Problem.windowSize; ivan@136: overlap = Problem.overlap; ivan@136: ws = Problem.ws(windowSize); ivan@136: wa = Problem.wa(windowSize); ivan@136: A = Problem.B; ivan@136: ivan@136: orig = Problem.original; ivan@136: clipped = Problem.clipped; ivan@136: clipMask = Problem.clipMask; ivan@136: ivan@136: % reconstruct audio frames ivan@136: ivan@136: xFrames = diag(ws)*(A*y); ivan@136: wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2)); ivan@136: ivan@136: % overlap and add ivan@136: ivan@136: rec = col2imstep(xFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]); ivan@136: wNorm = col2imstep(wNormFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]); ivan@136: wNorm(find(wNorm==0)) = 1; ivan@136: recN = rec./wNorm; ivan@136: ivan@136: % change only clipped samples ivan@136: ivan@136: recSignal = orig.*double(~clipMask) + recN.*double(clipMask); ivan@136: ivan@136: %% output structure image+psnr %% ivan@136: reconstructed.audioAllSamples = recN; ivan@136: reconstructed.audioOnlyClipped = recSignal; ivan@136: [reconstructed.snrAll , reconstructed.snrMiss] = SNRInpaintingPerformance(orig, clipped, recSignal, clipMask, 1); ivan@136: ivan@136: end