drumstick  2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
pianokeybd.cpp
Go to the documentation of this file.
1 /*
2  Virtual Piano Widget for Qt
3  Copyright (C) 2008-2023, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include <QApplication>
20 #include <drumstick/pianokeybd.h>
21 #include "pianoscene.h"
22 
34 inline void initResources()
35 {
36  Q_INIT_RESOURCE(pianokeybd);
37 }
38 
39 namespace drumstick { namespace widgets {
40 
45  {Qt::Key_Z, 12},
46  {Qt::Key_S, 13},
47  {Qt::Key_X, 14},
48  {Qt::Key_D, 15},
49  {Qt::Key_C, 16},
50  {Qt::Key_V, 17},
51  {Qt::Key_G, 18},
52  {Qt::Key_B, 19},
53  {Qt::Key_H, 20},
54  {Qt::Key_N, 21},
55  {Qt::Key_J, 22},
56  {Qt::Key_M, 23},
57  {Qt::Key_Q, 24},
58  {Qt::Key_2, 25},
59  {Qt::Key_W, 26},
60  {Qt::Key_3, 27},
61  {Qt::Key_E, 28},
62  {Qt::Key_R, 29},
63  {Qt::Key_5, 30},
64  {Qt::Key_T, 31},
65  {Qt::Key_6, 32},
66  {Qt::Key_Y, 33},
67  {Qt::Key_7, 34},
68  {Qt::Key_U, 35},
69  {Qt::Key_I, 36},
70  {Qt::Key_9, 37},
71  {Qt::Key_O, 38},
72  {Qt::Key_0, 39},
73  {Qt::Key_P, 40}
74 };
75 
80 #if defined(Q_OS_LINUX)
81  {94, 11},
82  {52, 12},
83  {39, 13},
84  {53, 14},
85  {40, 15},
86  {54, 16},
87  {55, 17},
88  {42, 18},
89  {56, 19},
90  {43, 20},
91  {57, 21},
92  {44, 22},
93  {58, 23},
94  {59, 24},
95  {46, 25},
96  {60, 26},
97  {47, 27},
98  {61, 28},
99 
100  {24, 29},
101  {11, 30},
102  {25, 31},
103  {12, 32},
104  {26, 33},
105  {13, 34},
106  {27, 35},
107  {28, 36},
108  {15, 37},
109  {29, 38},
110  {16, 39},
111  {30, 40},
112  {31, 41},
113  {18, 42},
114  {32, 43},
115  {19, 44},
116  {33, 45},
117  {20, 46},
118  {34, 47},
119  {35, 48}
120 #endif
121 
122 #if defined(Q_OS_WIN)
123  {86, 11},
124  {44, 12},
125  {31, 13},
126  {45, 14},
127  {32, 15},
128  {46, 16},
129  {47, 17},
130  {34, 18},
131  {48, 19},
132  {35, 20},
133  {49, 21},
134  {36, 22},
135  {50, 23},
136  {51, 24},
137  {38, 25},
138  {52, 26},
139  {39, 27},
140  {53, 28},
141 
142  {16, 29},
143  {3, 30},
144  {17, 31},
145  {4, 32},
146  {18, 33},
147  {5, 34},
148  {19, 35},
149  {20, 36},
150  {7, 37},
151  {21, 38},
152  {8, 39},
153  {22, 40},
154  {23, 41},
155  {10, 42},
156  {24, 43},
157  {11, 44},
158  {25, 45},
159  {12, 46},
160  {26, 47},
161  {27, 48}
162 #endif
163 
164 #if defined(Q_OS_MAC)
165  {50, 11},
166  {6, 12},
167  {1, 13},
168  {7, 14},
169  {2, 15},
170  {8, 16},
171  {9, 17},
172  {5, 18},
173  {11, 19},
174  {4, 20},
175  {45, 21},
176  {38, 22},
177  {46, 23},
178  {43, 24},
179  {37, 25},
180  {47, 26},
181  {41, 27},
182  {44, 28},
183 
184  {12, 29},
185  {19, 30},
186  {13, 31},
187  {20, 32},
188  {14, 33},
189  {21, 34},
190  {15, 35},
191  {17, 36},
192  {22, 37},
193  {16, 38},
194  {26, 39},
195  {32, 40},
196  {34, 41},
197  {25, 42},
198  {31, 43},
199  {29, 44},
200  {35, 45},
201  {27, 46},
202  {33, 47},
203  {30, 48}
204 #endif
205 };
206 
207 class PianoKeybd::PianoKeybdPrivate {
208 public:
209  PianoKeybdPrivate(): m_rotation(0), m_scene(nullptr), m_rawMap(nullptr)
210  { }
211  ~PianoKeybdPrivate() = default;
212 
213  int m_rotation;
214  PianoScene *m_scene;
215  KeyboardMap *m_rawMap;
216 };
217 
225 PianoKeybd::PianoKeybd(QWidget *parent)
226  : QGraphicsView(parent), d(new PianoKeybdPrivate())
227 {
228  initialize();
230 }
231 
240 PianoKeybd::PianoKeybd(const int baseOctave, const int numKeys, const int startKey, QWidget *parent)
241  : QGraphicsView(parent), d(new PianoKeybdPrivate)
242 {
243  initialize();
244  initScene(baseOctave, numKeys, startKey);
245 }
246 
251 {
252  d->m_scene->setRawKeyboardMode(false);
253  setKeyboardMap(nullptr);
254 }
255 
264 {
265  return d->m_scene->getPianoHandler();
266 }
267 
277 {
278  d->m_scene->setPianoHandler(handler);
279 }
280 
286 {
287  return d->m_scene->getHighlightPalette();
288 }
289 
297 {
298  d->m_scene->setHighlightPalette(p);
299 }
300 
306 {
307  return d->m_scene->getBackgroundPalette();
308 }
309 
315 {
316  d->m_scene->setBackgroundPalette(p);
317 }
318 
325 {
326  return d->m_scene->getForegroundPalette();
327 }
328 
335 {
336  d->m_scene->setForegroundPalette(p);
337 }
338 
344 {
345  return d->m_scene->showColorScale();
346 }
347 
352 void PianoKeybd::setShowColorScale(const bool show)
353 {
354  d->m_scene->setShowColorScale(show);
355 }
356 
366 void PianoKeybd::useCustomNoteNames(const QStringList &names)
367 {
368  d->m_scene->useCustomNoteNames(names);
369 }
370 
376 {
377  d->m_scene->useStandardNoteNames();
378 }
379 
384 QStringList PianoKeybd::customNoteNames() const
385 {
386  return d->m_scene->customNoteNames();
387 }
388 
393 QStringList PianoKeybd::standardNoteNames() const
394 {
395  return d->m_scene->standardNoteNames();
396 }
397 
404 {
405  d->m_scene->retranslate();
406 }
407 
415 void PianoKeybd::initScene(int base, int num, int strt, const QColor& c)
416 {
417  d->m_scene = new PianoScene(base, num, strt, c, this);
418  d->m_scene->setKeyboardMap(&g_DefaultKeyMap);
419  connect(d->m_scene, &PianoScene::noteOn, this, &PianoKeybd::noteOn);
420  connect(d->m_scene, &PianoScene::noteOff, this, &PianoKeybd::noteOff);
421  connect(d->m_scene, &PianoScene::signalName, this, &PianoKeybd::signalName);
422  setScene(d->m_scene);
423 }
424 
430 {
431  setAttribute(Qt::WA_AcceptTouchEvents);
432  setAttribute(Qt::WA_InputMethodEnabled, false);
433  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
434  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
435  setViewportUpdateMode(MinimalViewportUpdate);
436  setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing|QPainter::SmoothPixmapTransform);
437 #if (QT_VERSION < QT_VERSION_CHECK(5,15,0))
438  setOptimizationFlag(DontClipPainter, true);
439 #endif
440  setOptimizationFlag(DontSavePainterState, true);
441  setOptimizationFlag(DontAdjustForAntialiasing, true);
442  initResources();
443 }
444 
450 void PianoKeybd::resizeEvent(QResizeEvent *event)
451 {
452  QGraphicsView::resizeEvent(event);
453  fitInView(d->m_scene->sceneRect(), Qt::KeepAspectRatio);
454 }
455 
463 {
464 #if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
465  static const auto touchScreen = QTouchDevice::DeviceType::TouchScreen;
466 #else
467  static const auto touchScreen = QInputDevice::DeviceType::TouchScreen;
468 #endif
469  switch(ev->type()) {
470  case QEvent::TouchBegin:
471  case QEvent::TouchUpdate:
472  case QEvent::TouchEnd:
473  case QEvent::TouchCancel:
474  {
475  //qDebug() << Q_FUNC_INFO << ev->type();
476  QTouchEvent *touchEvent = static_cast<QTouchEvent*>(ev);
477  if (isTouchEnabled() && (touchEvent->device()->type() == touchScreen)) {
478  return d->m_scene->touchScreenEvent(touchEvent);
479  }
480  break;
481  }
482  default:
483  break;
484  }
485  return QGraphicsView::viewportEvent(ev);
486 }
487 
499 void PianoKeybd::setNumKeys(const int numKeys, const int startKey)
500 {
501  //qDebug() << Q_FUNC_INFO << numKeys << startKey;
502  if ( numKeys != d->m_scene->numKeys() || startKey != d->m_scene->startKey() )
503  {
504  QByteArray dataBuffer;
505  int baseOctave = d->m_scene->baseOctave();
506  QColor color = d->m_scene->getKeyPressedColor();
507  PianoHandler* handler = d->m_scene->getPianoHandler();
508  KeyboardMap* keyMap = d->m_scene->getKeyboardMap();
509  d->m_scene->saveData(dataBuffer);
510  delete d->m_scene;
511  initScene(baseOctave, numKeys, startKey, color);
512  d->m_scene->loadData(dataBuffer);
513  d->m_scene->setPianoHandler(handler);
514  d->m_scene->setKeyboardMap(keyMap);
515  d->m_scene->hideOrShowKeys();
516  d->m_scene->refreshKeys();
517  d->m_scene->refreshLabels();
518  fitInView(d->m_scene->sceneRect(), Qt::KeepAspectRatio);
519  }
520 }
521 
527 {
528  if (r != d->m_rotation) {
529  d->m_rotation = r;
530  resetTransform();
531  rotate(d->m_rotation);
532  fitInView(d->m_scene->sceneRect(), Qt::KeepAspectRatio);
533  }
534 }
535 
540 QSize PianoKeybd::sizeHint() const
541 {
542  return mapFromScene(sceneRect()).boundingRect().size();
543 }
544 
545 // RAWKBD_SUPPORT
547 {
548  if (d->m_scene->isKeyboardEnabled() && d->m_rawMap != nullptr && d->m_rawMap->contains(keycode)) {
549  d->m_scene->keyOn(d->m_rawMap->value(keycode));
550  return true;
551  }
552  return false;
553 }
554 
556 {
557  if (d->m_scene->isKeyboardEnabled() && d->m_rawMap != nullptr && d->m_rawMap->contains(keycode)) {
558  d->m_scene->keyOff(d->m_rawMap->value(keycode));
559  return true;
560  }
561  return false;
562 }
563 
570 void PianoKeybd::setKeyPicture(const bool natural, const QPixmap &pix)
571 {
572  d->m_scene->setKeyPicture(natural, pix);
573 }
574 
580 QPixmap PianoKeybd::getKeyPicture(const bool natural)
581 {
582  return d->m_scene->getKeyPicture(natural);
583 }
584 
589 void PianoKeybd::setUseKeyPictures(const bool enable)
590 {
591  d->m_scene->setUseKeyPictures(enable);
592 }
593 
599 {
600  return d->m_scene->getUseKeyPictures();
601 }
602 
613 void PianoKeybd::setUsingNativeFilter(const bool newState)
614 {
615  d->m_scene->setUsingNativeFilter( newState );
616 }
617 
626 {
627  return d->m_scene->isUsingNativeFilter();
628 }
629 
641 void PianoKeybd::setOctaveSubscript(const bool enable)
642 {
643  d->m_scene->setOctaveSubscript( enable );
644 }
645 
657 {
658  return d->m_scene->octaveSubscript();
659 }
660 
672 void PianoKeybd::setStartKey(const int startKey)
673 {
674  setNumKeys(numKeys(), startKey);
675 }
676 
682 int PianoKeybd::baseOctave() const
683 {
684  return d->m_scene->baseOctave();
685 }
686 
691 void PianoKeybd::setBaseOctave(const int baseOctave)
692 {
693  d->m_scene->setBaseOctave(baseOctave);
694 }
695 
701 int PianoKeybd::numKeys() const
702 {
703  return d->m_scene->numKeys();
704 }
705 
710 int PianoKeybd::startKey() const
711 {
712  return d->m_scene->startKey();
713 }
714 
720 {
721  return d->m_rotation;
722 }
723 
729 {
730  return d->m_scene->getKeyPressedColor();
731 }
732 
739 void PianoKeybd::setKeyPressedColor(const QColor& c)
740 {
741  d->m_scene->setKeyPressedColor(c);
742 }
743 
748 {
749  d->m_scene->resetKeyPressedColor();
750 }
751 
757 LabelVisibility PianoKeybd::showLabels() const
758 {
759  return d->m_scene->showLabels();
760 }
761 
768 {
769  d->m_scene->setShowLabels(show);
770 }
771 
778 {
779  return d->m_scene->alterations();
780 }
781 
788 {
789  d->m_scene->setAlterations(use);
790 }
791 
797 LabelOrientation PianoKeybd::labelOrientation() const
798 {
799  return d->m_scene->getOrientation();
800 }
801 
808 {
809  d->m_scene->setOrientation(orientation);
810 }
811 
817 LabelCentralOctave PianoKeybd::labelOctave() const
818 {
819  return d->m_scene->getOctave();
820 }
821 
828 {
829  d->m_scene->setOctave(octave);
830 }
831 
838 {
839  return d->m_scene->getTranspose();
840 }
841 
848 {
849  d->m_scene->setTranspose(t);
850 }
851 
857 {
858  return d->m_scene->getChannel();
859 }
860 
865 void PianoKeybd::setChannel(const int c)
866 {
867  d->m_scene->setChannel(c);
868 }
869 
876 {
877  return d->m_scene->getVelocity();
878 }
879 
885 void PianoKeybd::setVelocity(const int v)
886 {
887  d->m_scene->setVelocity(v);
888 }
889 
895 {
896  return d->m_scene->isKeyboardEnabled();
897 }
898 
903 void PianoKeybd::setKeyboardEnabled(const bool enable)
904 {
905  d->m_scene->setKeyboardEnabled(enable);
906 }
907 
913 {
914  return d->m_scene->isMouseEnabled();
915 }
916 
921 void PianoKeybd::setMouseEnabled(const bool enable)
922 {
923  d->m_scene->setMouseEnabled(enable);
924 }
925 
931 {
932  return d->m_scene->isTouchEnabled();
933 }
934 
939 void PianoKeybd::setTouchEnabled(const bool enable)
940 {
941  d->m_scene->setTouchEnabled(enable);
942 }
943 
949 {
950  return d->m_scene->velocityTint();
951 }
952 
957 void PianoKeybd::setVelocityTint(const bool enable)
958 {
959  //qDebug() << Q_FUNC_INFO << enable;
960  d->m_scene->setVelocityTint(enable);
961 }
962 
967 {
968  d->m_scene->allKeysOff();
969 }
970 
976 {
977  d->m_scene->setKeyboardMap(m);
978 }
979 
985 {
986  return d->m_scene->getKeyboardMap();
987 }
988 
993 {
994  d->m_rawMap = &g_DefaultRawKeyMap;
995  d->m_scene->setKeyboardMap(&g_DefaultRawKeyMap);
996 }
997 
1003 {
1004  return d->m_scene->getRawKeyboardMode();
1005 }
1006 
1012 {
1013  d->m_scene->setRawKeyboardMode(b);
1014 }
1015 
1020 {
1021  d->m_scene->setKeyboardMap(&g_DefaultKeyMap);
1022 }
1023 
1029 {
1030  d->m_rawMap = m;
1031  d->m_scene->setKeyboardMap(m);
1032 }
1033 
1039 {
1040  return d->m_rawMap;
1041 }
1042 
1049 void PianoKeybd::showNoteOn(const int note, QColor color, int vel)
1050 {
1051  d->m_scene->showNoteOn(note, color, vel);
1052 }
1053 
1059 void PianoKeybd::showNoteOn(const int note, int vel)
1060 {
1061  d->m_scene->showNoteOn(note, vel);
1062 }
1063 
1069 void PianoKeybd::showNoteOff(const int note, int vel)
1070 {
1071  d->m_scene->showNoteOff(note, vel);
1072 }
1073 
1078 void PianoKeybd::setFont(const QFont &font)
1079 {
1080  QWidget::setFont(font);
1081  d->m_scene->setFont(font);
1082  d->m_scene->refreshLabels();
1083 }
1084 
1085 } // namespace widgets
1086 } // namespace drumstick
The QEvent class is the base class of all event classes.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
The PianoHandler class callbacks.
Definition: pianokeybd.h:84
void initScene(int base, int num, int ini, const QColor &c=QColor())
Creates and initializes a new PianoScene instance and assigns it to this widget.
Definition: pianokeybd.cpp:415
void allKeysOff()
Forces all active notes to silence.
Definition: pianokeybd.cpp:966
virtual ~PianoKeybd()
Destructor.
Definition: pianokeybd.cpp:250
void resetKeyPressedColor()
Assigns the default highlight palette colors and assigns it to the scene.
Definition: pianokeybd.cpp:747
bool handleKeyReleased(int keycode) override
handleKeyReleased handles low level computer keyboard reelase events
Definition: pianokeybd.cpp:555
void setNumKeys(const int numKeys, const int startKey=DEFAULTSTARTINGKEY)
This method changes the number of displayed keys and the starting key number, keeping the other setti...
Definition: pianokeybd.cpp:499
PianoKeybd(QWidget *parent=nullptr)
Constructor.
Definition: pianokeybd.cpp:225
bool octaveSubscript() const
Returns whether the octave subscript designation is enabled.
Definition: pianokeybd.cpp:656
void setBackgroundPalette(const PianoPalette &p)
Assigns the palette used to paint the keys' background.
Definition: pianokeybd.cpp:314
void setRawKeyboardMode(const bool b)
Enables or disables the low level computer keyboard mode.
void setFont(const QFont &font)
Assigns a typographic font for drawing the note labels over the piano keys.
void initialize()
This method is called from the available constructors to initialize some widget attributes,...
Definition: pianokeybd.cpp:429
QSize sizeHint() const override
Overrides QGraphicsView::sizeHint() providing a size value based on the piano scene.
Definition: pianokeybd.cpp:540
void useStandardNoteNames()
Disables the custom note names usage as labels over the keys, and restores the standard note names in...
Definition: pianokeybd.cpp:375
bool isKeyboardEnabled() const
Returns whether the computer keyboard is enabled.
Definition: pianokeybd.cpp:894
void resetKeyboardMap()
Resets the low level computer keyboard note map to the default one.
void setKeyPressedColor(const QColor &c)
Assigns a single color for key highlight.
Definition: pianokeybd.cpp:739
void setChannel(const int c)
Assigns the MIDI Channel (0-15).
Definition: pianokeybd.cpp:865
PianoPalette getForegroundPalette() const
Returns the palette used to paint texts over the keys like the note names or custom labels.
Definition: pianokeybd.cpp:324
bool getUseKeyPictures() const
Returns whether pictures are used to paint the keys.
Definition: pianokeybd.cpp:598
void setHighlightPalette(const PianoPalette &p)
Assigns the palette used for highlighting the played keys.
Definition: pianokeybd.cpp:296
void setShowColorScale(const bool show)
Enables or disables the color scale background palette.
Definition: pianokeybd.cpp:352
void setPianoHandler(PianoHandler *handler)
Assigns a PianoHandler pointer for processing note events.
Definition: pianokeybd.cpp:276
void setLabelOctave(const LabelCentralOctave octave)
Assigns the octave label policy.
Definition: pianokeybd.cpp:827
bool showColorScale() const
Returns true if the color scale background palette is assigned and active.
Definition: pianokeybd.cpp:343
void signalName(const QString &name)
signalName is emitted for each note created, and contains a string with the MIDI note number and the ...
void setKeyboardEnabled(const bool enable)
Enables or disables the computer keyboard note input.
Definition: pianokeybd.cpp:903
KeyboardMap * getRawKeyboardMap()
Returns the low level computer keyboard note map.
PianoPalette getBackgroundPalette() const
Returns the palette used to paint the keys' background.
Definition: pianokeybd.cpp:305
bool isUsingNativeFilter() const
Returns whether the application is filtering native events.
Definition: pianokeybd.cpp:625
void setRawKeyboardMap(KeyboardMap *m)
Assigns the low level computer keyboard note map.
int getChannel() const
Returns the MIDI Channel (0-15).
Definition: pianokeybd.cpp:856
void setBaseOctave(const int baseOctave)
Assigns the base octave number.
Definition: pianokeybd.cpp:691
void setForegroundPalette(const PianoPalette &p)
Assigns the palette used to paint texts over the keys like the note names or custom labels.
Definition: pianokeybd.cpp:334
void setVelocityTint(const bool enable)
Enables or disables the note MIDI velocity influencing the highlight color tint.
Definition: pianokeybd.cpp:957
void setLabelAlterations(const LabelAlteration use)
Assigns the label alterations policy.
Definition: pianokeybd.cpp:787
void setStartKey(const int startKey)
Sets the initial/starting note key.
Definition: pianokeybd.cpp:672
void setKeyPicture(const bool natural, const QPixmap &pix)
Assigns a custom picture to the white or black keys that will be used as a texture to paint the keys.
Definition: pianokeybd.cpp:570
bool velocityTint() const
Returns whether the note MIDI velocity influences the highlight color tint.
Definition: pianokeybd.cpp:948
void setUsingNativeFilter(const bool newState)
Enables or disables the application level usage of a native event filter.
Definition: pianokeybd.cpp:613
QColor getKeyPressedColor() const
Returns the key highlight color.
Definition: pianokeybd.cpp:728
void resizeEvent(QResizeEvent *event) override
This method overrides QGraphicsView::resizeEvent() to keep the aspect ratio of the keys scene when th...
Definition: pianokeybd.cpp:450
void noteOff(int midiNote, int vel)
This signal is emitted for each Note Off MIDI event created using the computer keyboard,...
bool handleKeyPressed(int keycode) override
handleKeyPressed handles low level computer keyboard press events
Definition: pianokeybd.cpp:546
void setKeyboardMap(KeyboardMap *m)
Assigns the computer keyboard note map.
Definition: pianokeybd.cpp:975
void showNoteOff(const int note, int vel=-1)
Shows inactive one note key with the specified velocity.
void setShowLabels(const LabelVisibility show)
Assigns the label visibility policy.
Definition: pianokeybd.cpp:767
LabelAlteration labelAlterations() const
Returns the label alterations policy.
Definition: pianokeybd.cpp:777
PianoPalette getHighlightPalette() const
Returns the palette used for highlighting the played keys.
Definition: pianokeybd.cpp:285
QStringList standardNoteNames() const
Returns the list of standard note names.
Definition: pianokeybd.cpp:393
void noteOn(int midiNote, int vel)
This signal is emitted for each Note On MIDI event created using the computer keyboard,...
void resetRawKeyboardMap()
Resets the computer keyboard note map to the default one.
Definition: pianokeybd.cpp:992
PianoHandler * getPianoHandler() const
Gets the PianoHandler pointer to the note receiver.
Definition: pianokeybd.cpp:263
void setLabelOrientation(const LabelOrientation orientation)
Assigns the labels orientation policy.
Definition: pianokeybd.cpp:807
bool isMouseEnabled() const
Returns whether the mouse note input is enabled.
Definition: pianokeybd.cpp:912
bool getRawKeyboardMode() const
Returns the low level computer keyboard note map.
void showNoteOn(const int note, QColor color, int vel=-1)
Highlights one note key with the specified color and velocity.
void setRotation(int r)
Rotates the keyboard view an angle clockwise.
Definition: pianokeybd.cpp:526
QPixmap getKeyPicture(const bool natural)
Returns the custom picture used to paint the corresponding keys.
Definition: pianokeybd.cpp:580
void retranslate()
Updates the standard names of notes according to the currently active program language translation.
Definition: pianokeybd.cpp:403
void setTouchEnabled(const bool enable)
Enables or disables the touch screen note input.
Definition: pianokeybd.cpp:939
void useCustomNoteNames(const QStringList &names)
Assigns a list of custom text labels to be displayer over the keys.
Definition: pianokeybd.cpp:366
void setMouseEnabled(const bool enable)
Enables or disables the mouse note input.
Definition: pianokeybd.cpp:921
KeyboardMap * getKeyboardMap()
Returns the computer keyboard note map.
Definition: pianokeybd.cpp:984
void setUseKeyPictures(const bool enable)
Enables or disables a picture to paint the keys.
Definition: pianokeybd.cpp:589
int getRotation() const
Returns the rotation angle in degrees, clockwise, of the piano view.
Definition: pianokeybd.cpp:719
void setTranspose(int t)
Assigns the transpose amount in semitones.
Definition: pianokeybd.cpp:847
QStringList customNoteNames() const
Returns the list of custom note names.
Definition: pianokeybd.cpp:384
int getVelocity() const
Returns the MIDI note velocity.
Definition: pianokeybd.cpp:875
void setVelocity(const int v)
Assigns the MIDI note velocity.
Definition: pianokeybd.cpp:885
bool viewportEvent(QEvent *ev) override
This method overrides QGraphicsView::viewportEvent() Only touchscreen events are processed here.
Definition: pianokeybd.cpp:462
void setOctaveSubscript(const bool enable)
Enables or disables the octave subscript designation.
Definition: pianokeybd.cpp:641
bool isTouchEnabled() const
Returns whether the touch screen note input is enabled.
Definition: pianokeybd.cpp:930
int getTranspose() const
Returns the transpose amount in semitones.
Definition: pianokeybd.cpp:837
The PianoPalette class.
Definition: pianopalette.h:71
The PianoScene class is a QGraphicsScene composed by a number of graphics items: the piano keys.
Definition: pianoscene.h:47
void noteOff(int n, int v)
This signal is emitted for each Note Off MIDI event created using the computer keyboard,...
void signalName(const QString &name)
signalName is emitted for each note created, and contains a string with the MIDI note number and the ...
void noteOn(int n, int v)
This signal is emitted for each Note On MIDI event created using the computer keyboard,...
LabelAlteration
Labels for Alterations.
Definition: pianokeybd.h:131
DRUMSTICK_WIDGETS_EXPORT KeyboardMap g_DefaultKeyMap
Global Key Map Variable.
Definition: pianokeybd.cpp:44
LabelCentralOctave
Labels Central Octave.
Definition: pianokeybd.h:161
LabelVisibility
Labels Visibility.
Definition: pianokeybd.h:120
const int DEFAULTNUMBEROFKEYS
Default number of piano keys.
Definition: pianokeybd.h:115
LabelOrientation
Labels Orientation.
Definition: pianokeybd.h:141
const int DEFAULTSTARTINGKEY
Default starting key (A)
Definition: pianokeybd.h:113
QHash< int, int > KeyboardMap
KeyboardMap.
Definition: pianokeybd.h:108
DRUMSTICK_WIDGETS_EXPORT KeyboardMap g_DefaultRawKeyMap
Global Raw Key Map Variable.
Definition: pianokeybd.cpp:79
const int DEFAULTBASEOCTAVE
Default base octave.
Definition: pianokeybd.h:114
Drumstick common.
Definition: alsaclient.cpp:68
Piano Keyboard Widget.
PianoScene class declaration.