annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirkey.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function varargout = mirkey(orig,varargin)
Daniel@0 2 % k = mirkey(x) estimates the key.
Daniel@0 3 % Optional argument:
Daniel@0 4 % mirkey(...,'Total',m) selects not only the most probable key, but
Daniel@0 5 % the m most probable keys.
Daniel@0 6 % The other parameter 'Contrast' related to mirpeaks can be specified
Daniel@0 7 % here (see help mirchromagram).
Daniel@0 8 % The optional parameters 'Weight' and 'Triangle' related to
Daniel@0 9 % mirchromagram can be specified here (see help mirchromagram).
Daniel@0 10 % [k,ks] = mirkey(...) also returns the key clarity, corresponding here
Daniel@0 11 % to the key strength associated to the best candidate.
Daniel@0 12 % [k,ks,ksc] = mirkey(...) also displays the key strength curve used for
Daniel@0 13 % the key estimation and shows in particular the peaks corresponding
Daniel@0 14 % to the selected key(s).
Daniel@0 15
Daniel@0 16 tot.key = 'Total';
Daniel@0 17 tot.type = 'Integer';
Daniel@0 18 tot.default = 1;
Daniel@0 19 option.tot = tot;
Daniel@0 20
Daniel@0 21 thr.key = 'Contrast';
Daniel@0 22 thr.type = 'Integer';
Daniel@0 23 thr.default = .1;
Daniel@0 24 option.thr = thr;
Daniel@0 25
Daniel@0 26 wth.key = 'Weight';
Daniel@0 27 wth.type = 'Integer';
Daniel@0 28 wth.default = .5;
Daniel@0 29 option.wth = wth;
Daniel@0 30
Daniel@0 31 tri.key = 'Triangle';
Daniel@0 32 tri.type = 'Boolean';
Daniel@0 33 tri.default = 0;
Daniel@0 34 option.tri = tri;
Daniel@0 35
Daniel@0 36 specif.option = option;
Daniel@0 37 specif.defaultframelength = 1;
Daniel@0 38 specif.defaultframehop = .5;
Daniel@0 39
Daniel@0 40 varargout = mirfunction(@mirkey,orig,varargin,nargout,specif,@init,@main);
Daniel@0 41
Daniel@0 42
Daniel@0 43 function [p type] = init(x,option)
Daniel@0 44 if not(isamir(x,'mirkeystrength'))
Daniel@0 45 x = mirkeystrength(x,'Weight',option.wth,'Triangle',option.tri);
Daniel@0 46 end
Daniel@0 47 p = mirpeaks(x,'Total',option.tot,'Contrast',option.thr);
Daniel@0 48 type = {'mirscalar','mirscalar','mirkeystrength'};
Daniel@0 49
Daniel@0 50
Daniel@0 51 function k = main(p,option,postoption)
Daniel@0 52 if iscell(p)
Daniel@0 53 p = p{1};
Daniel@0 54 end
Daniel@0 55 pc = get(p,'PeakPos');
Daniel@0 56 pv = get(p,'PeakMaxVal');
Daniel@0 57 pm = get(p,'PeakMode');
Daniel@0 58 k = mirscalar(p,'Data',pc,'Mode',pm,'Title','Key',...
Daniel@0 59 'Legend',{'C','C#','D','D#','E','F','F#','G','G#','A','A#','B'});
Daniel@0 60 m = mirscalar(p,'Data',pv,'Title','Key clarity','MultiData',{});
Daniel@0 61 k = {k m p};