clear all;
close all;

disp(' ');
disp('Testing MDCT: Modified Discrete Cosine Transform.');
disp('Input vector: 2646016 samples of white noise.');
x = randn(1024*2584,1);
disp('Window length: N = 2048.');
N = 2048;
tic; c1 = mdct( x, N); t=toc;
disp(['1) Matlab implementation (N-size FFT). Time: ' num2str(t) 's.']);
tic; c2 = fastmdct( x, N, 0); t=toc;
s = snr(c1,c2);
disp(['2) C++ implementation (N-size FFT). Time: ' num2str(t) 's, SNR: ' num2str(s) 'dB.']);
tic; c3 = fastmdct( x, N, 1); t=toc;
s = snr(c1,c3);
disp(['3) C++ implementation (N/4-size FFT). Time: ' num2str(t) 's, SNR: ' num2str(s) 'dB.']);

disp(' ');
disp('Testing IMDCT: Inverse Modified Discrete Cosine Transform.');
disp('Input vector: 2646016 samples of white noise.');
x = randn(1024*2584,1);
disp('Window length: N = 2048.');
N = 2048;
tic; c1 = imdct( x, N); t=toc;
disp(['1) Matlab implementation (N-size FFT). Time: ' num2str(t) 's.']);
tic; c2 = fastimdct( x, N, 0); t=toc;
s = snr(c1,c2);
disp(['2) C++ implementation (N-size FFT). Time: ' num2str(t) 's, SNR: ' num2str(s) 'dB.']);
tic; c3 = fastimdct( x, N, 1); t=toc;
s = snr(c1,c3);
disp(['3) C++ implementation (N/4-size FFT). Time: ' num2str(t) 's, SNR: ' num2str(s) 'dB.']);

disp(' ');
disp('Testing SYNTH: Synthesize a union of MDCT bases approximation.');
disp('Input vector: 2646016 samples of white noise.');
x = randn(1024*2584,1);
disp('Dictionary: union of 4 MDCT bases with sizes 256,512,1024,2048.');
d = [256,512,1024,2048];
tic; c1 = synth( x, d); t=toc;
disp(['1) Matlab implementation (N-size FFT). Time: ' num2str(t) 's.']);
tic; c2 = fastsynth( x, d); t=toc;
s = snr(c1,c2);
disp(['2) C++ implementation (N/4-size FFT). Time: ' num2str(t) 's, SNR: ' num2str(s) 'dB.']);

disp(' ');