MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / UpdateKeys

Method UpdateKeys

Source/KompleteKontrol.cpp:150–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void KompleteKontrol::UpdateKeys()
151{
152 if (!mKontrol.IsReady())
153 return;
154
155 ofColor keys[61];
156 for (int i = 0; i < kNumKeys; ++i)
157 {
158 int pitch = i + mKeyOffset;
159 bool inScale = TheScale->MakeDiatonic(pitch) == pitch;
160 bool isRoot = pitch % TheScale->GetPitchesPerOctave() == TheScale->ScaleRoot();
161 bool isFifth = (pitch - 7) % TheScale->GetPitchesPerOctave() == TheScale->ScaleRoot();
162 bool isHeld = false;
163 bool isInPentatonic = pitch >= 0 && TheScale->IsInPentatonic(pitch);
164
165 std::list<int> heldNotes = mNoteOutput.GetHeldNotesList();
166 for (int iter : heldNotes)
167 {
168 if (iter == pitch)
169 isHeld = true;
170 }
171
172 if (isRoot)
173 keys[i] = ofColor(0, 255, 0);
174 else if (TheScale->GetPitchesPerOctave() != 12)
175 keys[i] = ofColor(40, 15, 0);
176 else if (isFifth && inScale)
177 keys[i] = ofColor(255, 0, 70);
178 else if (isInPentatonic)
179 keys[i] = ofColor(255, 70, 0);
180 else if (inScale)
181 keys[i] = ofColor(40, 15, 0);
182 else
183 keys[i] = ofColor::black;
184
185 if (isHeld)
186 {
187 if (keys[i].r == 0 && keys[i].g == 0 && keys[i].b == 0)
188 keys[i] = ofColor::blue; //out-of-key pressed notes turn blue
189 else
190 keys[i] = ofColor::red;
191 }
192 }
193 mKontrol.SetKeyLights(keys);
194}
195
196void KompleteKontrol::UpdateText()
197{

Callers

nothing calls this directly

Calls 8

ofColorClass · 0.85
MakeDiatonicMethod · 0.80
GetPitchesPerOctaveMethod · 0.80
IsInPentatonicMethod · 0.80
GetHeldNotesListMethod · 0.80
SetKeyLightsMethod · 0.80
IsReadyMethod · 0.45
ScaleRootMethod · 0.45

Tested by

no test coverage detected