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