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

Method OnKeyPressed

Source/KeyboardDisplay.cpp:316–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void KeyboardDisplay::OnKeyPressed(int key, bool isRepeat)
317{
318 if (mEnabled && !isRepeat && mAllowHoverTypingInput)
319 {
320 key = KeyToLower(key);
321 QwertyToPitchResponse res = QwertyToPitchMapping::GetPitchForComputerKey(key);
322
323 if (res.mOctaveShift != 0)
324 {
325 int newRootOctave = mRootOctave + res.mOctaveShift;
326 if (newRootOctave >= 0 && newRootOctave + mNumOctaves < 12)
327 mRootOctave = newRootOctave;
328 }
329 if (res.mPitch != -1)
330 {
331 int pitch = res.mPitch + mRootOctave * 12;
332 mKeyPressRegister[key] = pitch;
333 PlayNote(NextBufferTime(false), pitch, 127);
334 }
335 }
336}
337
338void KeyboardDisplay::KeyReleased(int key)
339{

Callers

nothing calls this directly

Calls 2

KeyToLowerFunction · 0.85
NextBufferTimeFunction · 0.85

Tested by

no test coverage detected