Daniel@0: function varargout = mirkey(orig,varargin) Daniel@0: % k = mirkey(x) estimates the key. Daniel@0: % Optional argument: Daniel@0: % mirkey(...,'Total',m) selects not only the most probable key, but Daniel@0: % the m most probable keys. Daniel@0: % The other parameter 'Contrast' related to mirpeaks can be specified Daniel@0: % here (see help mirchromagram). Daniel@0: % The optional parameters 'Weight' and 'Triangle' related to Daniel@0: % mirchromagram can be specified here (see help mirchromagram). Daniel@0: % [k,ks] = mirkey(...) also returns the key clarity, corresponding here Daniel@0: % to the key strength associated to the best candidate. Daniel@0: % [k,ks,ksc] = mirkey(...) also displays the key strength curve used for Daniel@0: % the key estimation and shows in particular the peaks corresponding Daniel@0: % to the selected key(s). Daniel@0: Daniel@0: tot.key = 'Total'; Daniel@0: tot.type = 'Integer'; Daniel@0: tot.default = 1; Daniel@0: option.tot = tot; Daniel@0: Daniel@0: thr.key = 'Contrast'; Daniel@0: thr.type = 'Integer'; Daniel@0: thr.default = .1; Daniel@0: option.thr = thr; Daniel@0: Daniel@0: wth.key = 'Weight'; Daniel@0: wth.type = 'Integer'; Daniel@0: wth.default = .5; Daniel@0: option.wth = wth; Daniel@0: Daniel@0: tri.key = 'Triangle'; Daniel@0: tri.type = 'Boolean'; Daniel@0: tri.default = 0; Daniel@0: option.tri = tri; Daniel@0: Daniel@0: specif.option = option; Daniel@0: specif.defaultframelength = 1; Daniel@0: specif.defaultframehop = .5; Daniel@0: Daniel@0: varargout = mirfunction(@mirkey,orig,varargin,nargout,specif,@init,@main); Daniel@0: Daniel@0: Daniel@0: function [p type] = init(x,option) Daniel@0: if not(isamir(x,'mirkeystrength')) Daniel@0: x = mirkeystrength(x,'Weight',option.wth,'Triangle',option.tri); Daniel@0: end Daniel@0: p = mirpeaks(x,'Total',option.tot,'Contrast',option.thr); Daniel@0: type = {'mirscalar','mirscalar','mirkeystrength'}; Daniel@0: Daniel@0: Daniel@0: function k = main(p,option,postoption) Daniel@0: if iscell(p) Daniel@0: p = p{1}; Daniel@0: end Daniel@0: pc = get(p,'PeakPos'); Daniel@0: pv = get(p,'PeakMaxVal'); Daniel@0: pm = get(p,'PeakMode'); Daniel@0: k = mirscalar(p,'Data',pc,'Mode',pm,'Title','Key',... Daniel@0: 'Legend',{'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'}); Daniel@0: m = mirscalar(p,'Data',pv,'Title','Key clarity','MultiData',{}); Daniel@0: k = {k m p};