ivan@136: function reconstructed=AudioDeclipping_reconstruct(y, Problem, SparseDict) ivan@136: %% Audio declipping Problem reconstruction function ivan@136: % ivan@136: % This reconstruction function is using sparse representation y ivan@136: % in dictionary Problem.A to reconstruct the patches of the denoised ivan@136: % image. 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