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