matthiasm@8
|
1 function param = add_keys(param)
|
matthiasm@8
|
2 names = {'A','Bb','B','C','C#','D','Eb','E','F','F#','G','G#','Am','Bbm','Bm','Cm','C#m','Dm','Ebm','Em','Fm','F#m','Gm','G#m'};
|
matthiasm@8
|
3 switch param.key.set
|
matthiasm@8
|
4 case 'major'
|
matthiasm@8
|
5 param.key.names = names(1:12);
|
matthiasm@8
|
6 profile = [1 0 1 0 1 1 0 1 0 1 0 1];
|
matthiasm@8
|
7 case 'majorminor'
|
matthiasm@8
|
8 param.key.names = names;
|
matthiasm@8
|
9 profile = [1 0 1 0 1 1 0 1 0 1 0 1;
|
matthiasm@8
|
10 1 0 1 1 0 1 0 1 1 0 0 1];
|
matthiasm@8
|
11 end
|
matthiasm@8
|
12
|
matthiasm@8
|
13 nMode = size(profile,1);
|
matthiasm@8
|
14
|
matthiasm@8
|
15 param.key.profiles = zeros(12 * nMode, 12);
|
matthiasm@8
|
16 param.key.n = nMode * 12;
|
matthiasm@8
|
17
|
matthiasm@8
|
18 for iMode = 1:nMode
|
matthiasm@8
|
19 for iSemitone = 1:12
|
matthiasm@8
|
20 param.key.profiles(12 * (iMode-1) + iSemitone,:) = ...
|
matthiasm@8
|
21 circshift(profile(iMode,:),[0,iSemitone-1]);
|
matthiasm@8
|
22 end
|
matthiasm@8
|
23 end
|
matthiasm@8
|
24
|
matthiasm@8
|
25
|
matthiasm@8
|
26 param.chord.givenkey = zeros([param.key.n,param.chord.n]);
|
matthiasm@8
|
27
|
matthiasm@8
|
28 for iKey = 1:param.key.n
|
matthiasm@8
|
29 for iChord = 1:param.chord.n
|
matthiasm@8
|
30 chord_prefit = ...
|
matthiasm@8
|
31 (1-param.key.profiles(iKey,:)) * param.chord.mu(:,iChord);
|
matthiasm@8
|
32 param.chord.givenkey(iKey,iChord) = 1 / (chord_prefit + param.key.c);
|
matthiasm@8
|
33 end
|
matthiasm@8
|
34 end
|
matthiasm@8
|
35 param.chord.givenkey = qnormalise(param.chord.givenkey,1,2);
|
matthiasm@8
|
36
|