void Piano::viewMousePressEvent(QMouseEvent* event) { button = event->button(); shift = event->modifiers() & Qt::ShiftModifier; if (keyDown != -1) { emit keyReleased(keyDown, shift); keyDown = -1; } keyDown = y2pitch(event->y()); if (keyDown < 0 || keyDown > 127) { keyDown = -1; } else { int velocity = event->x()*127/40; // REMOVE Tim. Noteoff. Changed. Zero note on vel is not allowed now. // emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift); //emit keyPressed(keyDown, shift); if(velocity > 127) velocity = 127; else if(velocity <= 0) velocity = 1; // Zero note on vel is not allowed. emit keyPressed(keyDown, velocity, shift); //emit keyPressed(keyDown, shift); } if (keyDown != -1 && keyDown != _curSelectedPitch) { _curSelectedPitch = keyDown; emit curSelectedPitchChanged(_curSelectedPitch); redraw(); MusEGlobal::song->update(SC_DRUMMAP); } }
void Piano::setCurSelectedPitch(int pitch) { if (pitch < 0 || pitch >= 128) return; if (pitch != _curSelectedPitch) { _curSelectedPitch = pitch; emit curSelectedPitchChanged(_curSelectedPitch); redraw(); } }