Dawn@4: function standvar = mpeg7init(fs,hopsize,windowsize,window,FFTsize) Dawn@4: Dawn@4: % This function creates a structure of the default values Dawn@4: % to be used throughout the descriptors Dawn@4: Dawn@4: % Written by Melanie Jackson Dawn@4: Dawn@4: % Version 1 15th March 2001 Dawn@4: % Modified 30/04/2002 by Thorsten Kastner - changed standard hopsize to 30ms Dawn@4: % - set hopsize = windowsize (no overlap for ASF) Dawn@4: Dawn@4: if nargin == 0 Dawn@4: Error = 'need to specify the sampling frequency: standvar = mpeg7init(fs)' Dawn@4: standvar = []; Dawn@4: return Dawn@4: end Dawn@4: Dawn@4: try % variable defined Dawn@4: if isempty(hopsize) % variable defined but no value Dawn@4: hopsize = [fs*30 1000]; % Changed hopsize: 30ms recommend Dawn@4: else Dawn@4: hopsize = [fs*hopsize(1) hopsize(2)]; Dawn@4: end Dawn@4: catch Dawn@4: hopsize = [fs*30 1000] ; Dawn@4: end Dawn@4: [q, n, d] = h_fraction(hopsize(1),hopsize(2)); Dawn@4: % This next section of code is to ensure minimal stray from the sampling period Dawn@4: % This is done by interleaving minor hopsize with major Dawn@4: % e.g if 10 10 10 10 10 11 11 are the hops then the pattern should be Dawn@4: % 10 10 10 11 10 10 11 Dawn@4: if n==0 Dawn@4: hopsize = q; Dawn@4: elseif d-n>=n Dawn@4: k = ceil((d-n)/n); % ratio of q to q+1 occurence Dawn@4: fr = floor((d-n)/(k)); % number of sub sequences required Dawn@4: frr = [q*ones(1,k) q+1]; % subsequence - length k+1 Dawn@4: hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr); % append subsequences to each other Dawn@4: hopsize = [hopsize q*ones(1,d-n-k*fr) (q+1)*ones(1,n-fr)]; % attach extra values Dawn@4: else Dawn@4: k = ceil(n/(d-n)); Dawn@4: fr = floor(n/k); Dawn@4: frr = [(q+1)*ones(1,k) q]; Dawn@4: hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr); Dawn@4: hopsize = [hopsize (q+1)*ones(1,n-k*fr) q*ones(1,d-n-fr)]; Dawn@4: end Dawn@4: Dawn@4: Dawn@4: try Dawn@4: if isempty(windowsize) % variable defined but no value Dawn@4: windowsize = ceil(fs*30/1000); % Changed:Windowsize fixed at 30ms Dawn@4: end Dawn@4: catch Dawn@4: windowsize = ceil(fs*30/1000); % Changed: Windowsize fixed at 30ms Dawn@4: end Dawn@4: Dawn@4: try Dawn@4: if isempty(FFTsize) % variable defined but no value Dawn@4: FFTsize = 2^nextpow2(windowsize); Dawn@4: end Dawn@4: catch Dawn@4: FFTsize = 2^nextpow2(windowsize); Dawn@4: end Dawn@4: Dawn@4: try Dawn@4: if isempty(window) % variable defined but no value Dawn@4: window = [hamming(windowsize)]; Dawn@4: end Dawn@4: catch Dawn@4: window = [hamming(windowsize)]; Dawn@4: end Dawn@4: Dawn@4: standvar = struct('fs',fs,'hopsize',hopsize,'windowsize',windowsize,'window',window,'FFTsize',FFTsize); Dawn@4: return