comparison examples/AudioInpainting/CVX_add_const_Audio_declipping.m @ 218:c38d965b5a1d luisf_dev

Moved CVX_add_const_Audio_declipping.m from solvers to the examples/AudioInpainting folder.
author Aris Gretsistas <aris.gretsistas@eecs.qmul.ac.uk>
date Thu, 22 Mar 2012 15:37:45 +0000
parents
children 1fbd28dfb99e
comparison
equal deleted inserted replaced
217:8b3c71bb44eb 218:c38d965b5a1d
1 function solver=CVX_add_const_Audio_declipping(Problem, solver, idxFrame)
2
3 %% CVX additional constrains
4 % Clipping level: take the analysis window into account
5 % clipping level detection
6
7 signal = Problem.b1;
8 signalFull = Problem.b(:,idxFrame);
9 Dict = Problem.A;
10 DictFull = Problem.B;
11 Clipped = ~Problem.M(:,idxFrame);
12 W=1./sqrt(diag(Dict'*Dict));
13
14 idxCoeff = find(solver.solution~=0);
15
16 solution = solver.solution;
17
18 wa = Problem.wa(Problem.windowSize); % analysis window
19
20
21 clippingLevelEst = max(abs(signal./wa(~Clipped)'));
22
23 idxPos = find(signalFull>=0 & Clipped);
24 idxNeg = find(signalFull<0 & Clipped);
25
26 DictPos=DictFull(idxPos,:);
27 DictNeg=DictFull(idxNeg,:);
28
29
30 wa_pos = wa(idxPos);
31 wa_neg = wa(idxNeg);
32 b_ineq_pos = wa_pos(:)*clippingLevelEst;
33 b_ineq_neg = -wa_neg(:)*clippingLevelEst;
34 if isfield(Problem,'Upper_Limit') && ~isempty(Problem.Upper_Limit)
35 b_ineq_pos_upper_limit = wa_pos(:)*Problem.Upper_Limit;
36 b_ineq_neg_upper_limit = -wa_neg(:)*Problem.Upper_Limit;
37 else
38 b_ineq_pos_upper_limit = Inf;
39 b_ineq_neg_upper_limit = -Inf;
40 end
41
42
43 j = length(idxCoeff);
44
45 if isinf(b_ineq_pos_upper_limit)
46 %% CVX code
47 cvx_begin
48 cvx_quiet(true)
49 variable solution(j)
50 minimize(norm(Dict(:,idxCoeff)*solution-signal))
51 subject to
52 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_pos
53 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_neg
54 cvx_end
55 if cvx_optval>1e3
56 cvx_begin
57 cvx_quiet(true)
58 variable solution(j)
59 minimize(norm(Dict(:,idxCoeff)*solution-xObs))
60 cvx_end
61 end
62 else
63 %% CVX code
64 cvx_begin
65 cvx_quiet(true)
66 variable solution(j)
67 minimize(norm(Dict(:,idxCoeff)*solution-signal))
68 subject to
69 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_pos
70 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_neg
71 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_pos_upper_limit
72 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_neg_upper_limit
73 cvx_end
74 if cvx_optval>1e3
75 cvx_begin
76 cvx_quiet(true)
77 variable solution(j)
78 minimize(norm(Dict(:,idxCoeff)*solution-xObs))
79 cvx_end
80 end
81 end
82
83 solver.solution(idxCoeff) = solution;
84
85