-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcp_main.m
More file actions
72 lines (51 loc) · 1.93 KB
/
cp_main.m
File metadata and controls
72 lines (51 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% Chambolle-Pock sparsity based dequantization
%
% Vojtěch Kovanda
% Brno University of Technology, 2024
% using LTFAT toolbox
ltfatstart
%% input signal
audiofile = 'test/violin_scales/A_staccato.wav';
% the audio recordings are divided by instruments in the "test" folder
% for example
% 'test/violin_scales/A_staccato.wav'
% 'test/trumpet_scales/A#.wav'
% 'test/sax_tenor_scales/A#_legato.wav'
% 'test/sax_alto_scales/D#_staccato.wav'
% 'test/flute_scales/C_legato.wav'
% 'test/clarinet_scales/F_legato.wav'
[x, param.fs] = audioread(audiofile);
% signal length
param.L = length(x);
% normalization
maxval = max(abs(x));
x = x/maxval;
%% generate observations y
% setting conversion parameters
param.w = 8;
% quantization
y = quant(x, param.w);
%% settings for proposed algorithm
% frame settings
param.winlen = 2048; % window length
param.wtype = 'hann'; % window type
param.a = param.winlen/4; % window shift
param.M = 2*param.winlen; % number of frequency channels
% frame construction
param.F = frametight(frame('dgtreal', {param.wtype, param.winlen}, param.a, param.M));
param.F = frameaccel(param.F, param.L);
% algorithm parameters
param.lam = [0.0012 0.000094 0.000032 0.000013 0.0000055 0.0000027 0.0000018 0.0000011 0.0000006 0.0000004 0.0000003 0.0000002 0.0000001]; % different clipping thresholds for different bit depth
param.rho = 1;
%% calling optimization algorithm
param.maxit = 200;
[xcp, SDR_in_time] = cp_alg(y, param, x);
%% evaluation
SDR = max(SDR_in_time);
SDRq = 20*log10(norm(x,2)./norm(x-y, 2));
% [~, ~, ODG] = audioqual(x, xcp, param.fs);
% [~, ~, ODGq] = audioqual(x, y, param.fs);
fprintf('SDR of the quantized signal is %4.3f dB.\n', SDRq);
fprintf('SDRcp of the reconstructed signal is %4.3f dB.\n', SDR);
% fprintf('ODG of the quantized signal is %4.3f.\n', ODGq);
% fprintf('ODGcp of the reconstructed signal is %4.3f.\n', ODG);