| 148 | } |
| 149 | |
| 150 | void 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 | |
| 196 | void KompleteKontrol::UpdateText() |
| 197 | { |
nothing calls this directly
no test coverage detected