void PixmapKeyboard::keyPressEvent(QKeyEvent* event) { if (! event->isAutoRepeat()) { int qKey = event->key(); std::map<int, int>::const_iterator it = kMidiKeyboard2KeyMap.find(qKey); if (it != kMidiKeyboard2KeyMap.end()) sendNoteOn(it->second); } QWidget::keyPressEvent(event); }
//---------------------------------------------------------- PdBase& PdBase::operator<<(const NoteOn& var) { sendNoteOn(var.channel, var.pitch, var.velocity); return *this; }
void PixmapKeyboard::handleMousePos(const QPoint& pos) { int note, octave; QPointF keyPos; if (fPixmapMode == HORIZONTAL) { if (pos.x() < 0 or pos.x() > fOctaves * 144) return; int posX = pos.x() - 1; octave = posX / fWidth; keyPos = QPointF(posX % fWidth, pos.y()); } else if (fPixmapMode == VERTICAL) { if (pos.y() < 0 or pos.y() > fOctaves * 144) return; int posY = pos.y() - 1; octave = fOctaves - posY / fHeight; keyPos = QPointF(pos.x(), posY % fHeight); } else return; if (fMidiMap[1].contains(keyPos)) // C# note = 1; else if (fMidiMap[3].contains(keyPos)) // D# note = 3; else if (fMidiMap[6].contains(keyPos)) // F# note = 6; else if (fMidiMap[8].contains(keyPos)) // G# note = 8; else if (fMidiMap[10].contains(keyPos))// A# note = 10; else if (fMidiMap[0].contains(keyPos)) // C note = 0; else if (fMidiMap[2].contains(keyPos)) // D note = 2; else if (fMidiMap[4].contains(keyPos)) // E note = 4; else if (fMidiMap[5].contains(keyPos)) // F note = 5; else if (fMidiMap[7].contains(keyPos)) // G note = 7; else if (fMidiMap[9].contains(keyPos)) // A note = 9; else if (fMidiMap[11].contains(keyPos))// B note = 11; else note = -1; if (note != -1) { note += octave * 12; if (fLastMouseNote != note) { sendNoteOff(fLastMouseNote); sendNoteOn(note); } } else if (fLastMouseNote != -1) sendNoteOff(fLastMouseNote); fLastMouseNote = note; }