wolffd@0: function varargout = mirbeatspectrum(orig,varargin) wolffd@0: % n = mirbeatspectrum(m) evaluates the beat spectrum. wolffd@0: % [n,m] = mirbeatspectrum(m) also return the similarity matrix on which wolffd@0: % the estimation is made. wolffd@0: % Optional argument: wolffd@0: % mirbeatspectrum(...,s) specifies the estimation method. wolffd@0: % Possible values: wolffd@0: % s = 'Diag', summing simply along the diagonals of the matrix. wolffd@0: % s = 'Autocor', based on the autocorrelation of the matrix. wolffd@0: % mirbeatspectrum(...,'Distance',f) specifies the name of a dissimilarity wolffd@0: % distance function, from those proposed in the Statistics Toolbox wolffd@0: % (help pdist). wolffd@0: % default value: f = 'cosine' wolffd@0: % J. Foote, M. Cooper, U. Nam, "Audio Retrieval by Rhythmic Similarity", wolffd@0: % ISMIR 2002. wolffd@0: wolffd@0: wolffd@0: dist.key = 'Distance'; wolffd@0: dist.type = 'String'; wolffd@0: dist.default = 'cosine'; wolffd@0: option.dist = dist; wolffd@0: wolffd@0: meth.type = 'String'; wolffd@0: meth.choice = {'Diag','Autocor'}; wolffd@0: meth.default = 'Autocor'; wolffd@0: option.meth = meth; wolffd@0: wolffd@0: specif.option = option; wolffd@0: varargout = mirfunction(@mirbeatspectrum,orig,varargin,nargout,specif,@init,@main); wolffd@0: wolffd@0: wolffd@0: function [x type] = init(x,option) wolffd@0: if not(isamir(x,'mirscalar')) wolffd@0: if isamir(x,'miraudio') wolffd@0: x = mirmfcc(x,'frame',.025,'s',.01,'s','Rank',8:30); wolffd@0: end wolffd@0: x = mirsimatrix(x,'Distance',option.dist,'Similarity'); wolffd@0: end wolffd@0: type = 'mirscalar'; wolffd@0: wolffd@0: wolffd@0: function y = main(orig,option,postoption) wolffd@0: if iscell(orig) wolffd@0: orig = orig{1}; wolffd@0: end wolffd@0: fp = get(orig,'FramePos'); wolffd@0: if not(isa(orig,'mirscalar')) wolffd@0: s = get(orig,'Data'); wolffd@0: total = cell(1,length(s)); wolffd@0: for k = 1:length(s) wolffd@0: for h = 1:length(s{k}) wolffd@0: maxfp = find(fp{k}{h}(2,:)>4,1); wolffd@0: if isempty(maxfp) wolffd@0: maxfp = Inf; wolffd@0: else wolffd@0: fp{k}{h}(:,maxfp+1:end) = []; wolffd@0: end wolffd@0: l = min(length(s{k}{h}),maxfp); wolffd@0: total{k}{h} = zeros(1,l); wolffd@0: if strcmpi(option.meth,'Diag') wolffd@0: for i = 1:l wolffd@0: total{k}{h}(i) = mean(diag(s{k}{h},i-1)); wolffd@0: end wolffd@0: else wolffd@0: for i = 1:l wolffd@0: total{k}{h}(i) = mean(mean(s{k}{h}(:,1:l-i+1).*s{k}{h}(:,i:l))); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: else wolffd@0: total = get(orig,'Data'); wolffd@0: end wolffd@0: n = mirscalar(orig,'Data',total,'FramePos',fp,'Title','Beat Spectrum'); wolffd@0: y = {n orig};