To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / _dbn / add_keys.m
History | View | Annotate | Download (1.05 KB)
| 1 |
function param = add_keys(param) |
|---|---|
| 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'};
|
| 3 |
switch param.key.set |
| 4 |
case 'major' |
| 5 |
param.key.names = names(1:12); |
| 6 |
profile = [1 0 1 0 1 1 0 1 0 1 0 1]; |
| 7 |
case 'majorminor' |
| 8 |
param.key.names = names; |
| 9 |
profile = [1 0 1 0 1 1 0 1 0 1 0 1; |
| 10 |
1 0 1 1 0 1 0 1 1 0 0 1]; |
| 11 |
end |
| 12 |
|
| 13 |
nMode = size(profile,1); |
| 14 |
|
| 15 |
param.key.profiles = zeros(12 * nMode, 12); |
| 16 |
param.key.n = nMode * 12; |
| 17 |
|
| 18 |
for iMode = 1:nMode |
| 19 |
for iSemitone = 1:12 |
| 20 |
param.key.profiles(12 * (iMode-1) + iSemitone,:) = ... |
| 21 |
circshift(profile(iMode,:),[0,iSemitone-1]); |
| 22 |
end |
| 23 |
end |
| 24 |
|
| 25 |
|
| 26 |
param.chord.givenkey = zeros([param.key.n,param.chord.n]); |
| 27 |
|
| 28 |
for iKey = 1:param.key.n |
| 29 |
for iChord = 1:param.chord.n |
| 30 |
chord_prefit = ... |
| 31 |
(1-param.key.profiles(iKey,:)) * param.chord.mu(:,iChord); |
| 32 |
param.chord.givenkey(iKey,iChord) = 1 / (chord_prefit + param.key.c); |
| 33 |
end |
| 34 |
end |
| 35 |
param.chord.givenkey = qnormalise(param.chord.givenkey,1,2); |
| 36 |
|