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

%
%   Centre for Digital Music, Queen Mary, University of London.
%   This file copyright 2009 Ivan Damnjanovic.
%
%   This program is free software; you can redistribute it and/or
%   modify it under the terms of the GNU General Public License as
%   published by the Free Software Foundation; either version 2 of the
%   License, or (at your option) any later version.  See the file
%   COPYING included with this distribution for more information.
%%

windowSize = Problem.windowSize;
overlap = Problem.overlap;
ws = Problem.ws(windowSize);
wa = Problem.wa(windowSize);
A = Problem.B;

orig     = Problem.original;
clipped  = Problem.clipped;
clipMask = Problem.clipMask;

% reconstruct audio frames

xFrames = diag(ws)*(A*y);
wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2));

%   overlap and add

rec   = col2imstep(xFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]);
wNorm = col2imstep(wNormFrames, size(clipped), [windowSize 1], [windowSize*overlap 1]); 
wNorm(find(wNorm==0)) = 1; 
recN  = rec./wNorm;

% change only clipped samples

recSignal = orig.*double(~clipMask) + recN.*double(clipMask); 

%% output structure image+psnr %%
reconstructed.audioAllSamples  = recN;
reconstructed.audioOnlyClipped = recSignal;
[reconstructed.snrAll , reconstructed.snrMiss] = SNRInpaintingPerformance(orig, clipped, recSignal, clipMask, 1);

end