comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirkey.m @ 0:e9a9cd732c1e tip

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