ivan@138: function D = DCT_Dictionary(param)
ivan@138: % Windowed DCT dictionary
ivan@138: %
ivan@138: % Usage:
ivan@138: %   D = DCT_Dictionary(param)
ivan@138: %
ivan@138: %
ivan@138: % Inputs [and default values]:
ivan@138: %   - param.N: frame length [256]
ivan@138: %   - param.redundancyFactor: redundancy factor to adjust the number of
ivan@138: %   frequencies [1]. The number of atoms in the dictionary equals 
ivan@138: %   param.N*param.redundancyFactor
ivan@138: %   - param.wd: weigthing window function [@wSine]
ivan@138: %
ivan@138: % Output:
ivan@138: %   - Dictionary: D
ivan@138: %
ivan@138: %
ivan@138: % -------------------
ivan@138: %
ivan@138: % Audio Inpainting toolbox
ivan@138: % Date: June 28, 2011
ivan@138: % By Valentin Emiya, Amir Adler, Maria Jafari
ivan@138: % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt).
ivan@138: % Windowed DCT dictionary
ivan@138: %
ivan@138: 
ivan@138: % Check and load default parameters
ivan@138: defaultParam.N = 256;
ivan@138: defaultParam.redundancyFactor = 1;
ivan@138: defaultParam.wd = @wSine;
ivan@138: 
ivan@138: if nargin<1
ivan@138:     param = defaultParam;
ivan@138: else
ivan@138:     names = fieldnames(defaultParam);
ivan@138:     for k=1:length(names)
ivan@138:         if ~isfield(param,names{k}) || isempty(param.(names{k}))
ivan@138:             param.(names{k}) = defaultParam.(names{k});
ivan@138:         end
ivan@138:     end
ivan@138: end
ivan@138: K = param.N*param.redundancyFactor; % number of atoms
ivan@138: wd = param.wd(param.N); % weigthing window
ivan@138: u = 0:(param.N-1); % time
ivan@138: k=0:K-1; % frequency
ivan@138: D = diag(wd)*cos(pi/K*(u.'+1/2)*(k+1/2));
ivan@138: 
ivan@138: % normalisation
ivan@138: D = D*diag(1./sqrt(diag(D'*D)));
ivan@138: return