-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
ChordStore.cpp
73 lines (65 loc) · 1.79 KB
/
ChordStore.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "ChordStore.h"
void ChordStore::updateCurrentChord(WhenNoChordNote::Enum whenNoChordNoteVal,
WhenSingleChordNote::Enum whenSingleChordNoteVal) {
if (!mNeedsUpdate)
return;
mShouldSilence = false;
mShouldProcess = true;
Chord newChord;
for (Counters::Iterator i(mCounters); i.next();) {
newChord.add(i.getKey());
}
switch (newChord.size()) {
case 0:
// No chord notes
switch (whenNoChordNoteVal) {
case WhenNoChordNote::LATCH_LAST_CHORD:
if (mCurrentChord.size() == 0)
// No last chord known. We silence
mShouldSilence = true;
break;
case WhenNoChordNote::USE_PATTERN_AS_NOTES:
mShouldProcess = false;
break;
case WhenNoChordNote::SILENCE:
mShouldSilence = true;
break;
}
break;
case 1:
// Just 1 chord note
switch (whenSingleChordNoteVal) {
case WhenSingleChordNote::TRANSPOSE_LAST_CHORD:
if (mCurrentChord.size() > 0) {
int offset = newChord[0] - mCurrentChord[0];
newChord.clear();
for (NoteNumber nn : mCurrentChord)
newChord.add(nn + offset);
mCurrentChord = newChord;
}
else // No last chord known. We silence
mShouldSilence = true;
break;
case WhenSingleChordNote::POWERCHORD:
newChord.add(newChord[0] + 7);
mCurrentChord = newChord;
break;
case WhenSingleChordNote::USE_AS_IS:
mCurrentChord = newChord;
break;
case WhenSingleChordNote::USE_PATTERN_AS_NOTES:
mShouldProcess = false;
break;
case WhenSingleChordNote::SILENCE:
mShouldSilence = true;
break;
}
break;
default:
// "Normal" case: 2 chords notes or more
mCurrentChord = newChord;
break;
};
mNeedsUpdate = false;
}
JUCE_IMPLEMENT_SINGLETON(GlobalChordStore);