annotate Code/Descriptors/Matlab/MPEG7/FromWeb/mpeg7init.m @ 4:92ca03a8fa99 tip

Update to ICASSP 2013 benchmark
author Dawn Black
date Wed, 13 Feb 2013 11:02:39 +0000
parents
children
rev   line source
Dawn@4 1 function standvar = mpeg7init(fs,hopsize,windowsize,window,FFTsize)
Dawn@4 2
Dawn@4 3 % This function creates a structure of the default values
Dawn@4 4 % to be used throughout the descriptors
Dawn@4 5
Dawn@4 6 % Written by Melanie Jackson
Dawn@4 7
Dawn@4 8 % Version 1 15th March 2001
Dawn@4 9 % Modified 30/04/2002 by Thorsten Kastner - changed standard hopsize to 30ms
Dawn@4 10 % - set hopsize = windowsize (no overlap for ASF)
Dawn@4 11
Dawn@4 12 if nargin == 0
Dawn@4 13 Error = 'need to specify the sampling frequency: standvar = mpeg7init(fs)'
Dawn@4 14 standvar = [];
Dawn@4 15 return
Dawn@4 16 end
Dawn@4 17
Dawn@4 18 try % variable defined
Dawn@4 19 if isempty(hopsize) % variable defined but no value
Dawn@4 20 hopsize = [fs*30 1000]; % Changed hopsize: 30ms recommend
Dawn@4 21 else
Dawn@4 22 hopsize = [fs*hopsize(1) hopsize(2)];
Dawn@4 23 end
Dawn@4 24 catch
Dawn@4 25 hopsize = [fs*30 1000] ;
Dawn@4 26 end
Dawn@4 27 [q, n, d] = h_fraction(hopsize(1),hopsize(2));
Dawn@4 28 % This next section of code is to ensure minimal stray from the sampling period
Dawn@4 29 % This is done by interleaving minor hopsize with major
Dawn@4 30 % e.g if 10 10 10 10 10 11 11 are the hops then the pattern should be
Dawn@4 31 % 10 10 10 11 10 10 11
Dawn@4 32 if n==0
Dawn@4 33 hopsize = q;
Dawn@4 34 elseif d-n>=n
Dawn@4 35 k = ceil((d-n)/n); % ratio of q to q+1 occurence
Dawn@4 36 fr = floor((d-n)/(k)); % number of sub sequences required
Dawn@4 37 frr = [q*ones(1,k) q+1]; % subsequence - length k+1
Dawn@4 38 hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr); % append subsequences to each other
Dawn@4 39 hopsize = [hopsize q*ones(1,d-n-k*fr) (q+1)*ones(1,n-fr)]; % attach extra values
Dawn@4 40 else
Dawn@4 41 k = ceil(n/(d-n));
Dawn@4 42 fr = floor(n/k);
Dawn@4 43 frr = [(q+1)*ones(1,k) q];
Dawn@4 44 hopsize = reshape(frr'*ones(1,fr),1,(k+1)*fr);
Dawn@4 45 hopsize = [hopsize (q+1)*ones(1,n-k*fr) q*ones(1,d-n-fr)];
Dawn@4 46 end
Dawn@4 47
Dawn@4 48
Dawn@4 49 try
Dawn@4 50 if isempty(windowsize) % variable defined but no value
Dawn@4 51 windowsize = ceil(fs*30/1000); % Changed:Windowsize fixed at 30ms
Dawn@4 52 end
Dawn@4 53 catch
Dawn@4 54 windowsize = ceil(fs*30/1000); % Changed: Windowsize fixed at 30ms
Dawn@4 55 end
Dawn@4 56
Dawn@4 57 try
Dawn@4 58 if isempty(FFTsize) % variable defined but no value
Dawn@4 59 FFTsize = 2^nextpow2(windowsize);
Dawn@4 60 end
Dawn@4 61 catch
Dawn@4 62 FFTsize = 2^nextpow2(windowsize);
Dawn@4 63 end
Dawn@4 64
Dawn@4 65 try
Dawn@4 66 if isempty(window) % variable defined but no value
Dawn@4 67 window = [hamming(windowsize)];
Dawn@4 68 end
Dawn@4 69 catch
Dawn@4 70 window = [hamming(windowsize)];
Dawn@4 71 end
Dawn@4 72
Dawn@4 73 standvar = struct('fs',fs,'hopsize',hopsize,'windowsize',windowsize,'window',window,'FFTsize',FFTsize);
Dawn@4 74 return