Mercurial > hg > smallbox
comparison Problems/AudioDeclipping_reconstruct.m @ 136:1334d2302dd9 ivand_dev
Added Audio declipping problem (problem, reconstruct and example function)
| author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
|---|---|
| date | Thu, 14 Jul 2011 16:26:07 +0100 |
| parents | |
| children | 31d2864dfdd4 |
comparison
equal
deleted
inserted
replaced
| 134:10343fb66448 | 136:1334d2302dd9 |
|---|---|
| 1 function reconstructed=AudioDeclipping_reconstruct(y, Problem, SparseDict) | |
| 2 %% Audio declipping Problem reconstruction function | |
| 3 % | |
| 4 % This reconstruction function is using sparse representation y | |
| 5 % in dictionary Problem.A to reconstruct the patches of the denoised | |
| 6 % image. | |
| 7 | |
| 8 % | |
| 9 % Centre for Digital Music, Queen Mary, University of London. | |
| 10 % This file copyright 2009 Ivan Damnjanovic. | |
| 11 % | |
| 12 % This program is free software; you can redistribute it and/or | |
| 13 % modify it under the terms of the GNU General Public License as | |
| 14 % published by the Free Software Foundation; either version 2 of the | |
| 15 % License, or (at your option) any later version. See the file | |
| 16 % COPYING included with this distribution for more information. | |
| 17 %% | |
| 18 | |
| 19 windowSize = Problem.windowSize; | |
| 20 overlap = Problem.overlap; | |
| 21 ws = Problem.ws(windowSize); | |
| 22 wa = Problem.wa(windowSize); | |
| 23 A = Problem.B; | |
| 24 | |
| 25 orig = Problem.original; | |
| 26 clipped = Problem.clipped; | |
| 27 clipMask = Problem.clipMask; | |
| 28 | |
| 29 % reconstruct audio frames | |
| 30 | |
| 31 xFrames = diag(ws)*(A*y); | |
| 32 wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2)); | |
| 33 | |
| 34 % overlap and add | |
| 35 | |
| 36 rec = col2imstep(xFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]); | |
| 37 wNorm = col2imstep(wNormFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]); | |
| 38 wNorm(find(wNorm==0)) = 1; | |
| 39 recN = rec./wNorm; | |
| 40 | |
| 41 % change only clipped samples | |
| 42 | |
| 43 recSignal = orig.*double(~clipMask) + recN.*double(clipMask); | |
| 44 | |
| 45 %% output structure image+psnr %% | |
| 46 reconstructed.audioAllSamples = recN; | |
| 47 reconstructed.audioOnlyClipped = recSignal; | |
| 48 [reconstructed.snrAll , reconstructed.snrMiss] = SNRInpaintingPerformance(orig, clipped, recSignal, clipMask, 1); | |
| 49 | |
| 50 end |
