summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/piano.cpp
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2012-10-27 09:58:29 +0000
committerTim E. Real <termtech@rogers.com>2012-10-27 09:58:29 +0000
commitb1776f093d4b87ad2635990f429f4503157f6288 (patch)
treea18bcc5e23674d74037c87e0541f9feefdc7b9ca /muse2/muse/midiedit/piano.cpp
parentb297348e8e2cd76be6f1d546fb458865cc4d263b (diff)
Improved: Velocity graphs. Icon for showing per-note or all velocities. Also found in Settings.
Improved: Piano KB has current selected note (yellow). For velocity/polyaftertouch/other per-note ctrls. Bad timing warning now has "don't show again". Added 'speaker' icon to drum edit. And drum list and piano keyboard now obey the 'speaker' icon.
Diffstat (limited to 'muse2/muse/midiedit/piano.cpp')
-rw-r--r--muse2/muse/midiedit/piano.cpp265
1 files changed, 202 insertions, 63 deletions
diff --git a/muse2/muse/midiedit/piano.cpp b/muse2/muse/midiedit/piano.cpp
index 1000ffe9..afbf8328 100644
--- a/muse2/muse/midiedit/piano.cpp
+++ b/muse2/muse/midiedit/piano.cpp
@@ -26,7 +26,11 @@
#include <stdio.h>
#include "piano.h"
+#include "globals.h"
+#include "song.h"
+namespace MusEGui {
+
static const char *oct_xpm[] = {
// w h colors
"40 91 2 1",
@@ -120,134 +124,125 @@ static const char *oct_xpm[] = {
".........................#...#.........#",
".........................#.............#",
".........................#.............#",
- ".........................#...#.........#", // 10
+ ".........................#...#.........#", // 9
"..........................###..........#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC1[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###.....#....#",
".........................#...#...##....#",
".........................#........#....#",
".........................#........#....#",
- ".........................#...#....#....#", // 10
+ ".........................#...#....#....#", // 9
"..........................###....###...#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC2[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###....##....#",
".........................#...#..#..#...#",
".........................#........#....#",
".........................#.......#.....#",
- ".........................#...#..#......#", // 10
+ ".........................#...#..#......#", // 9
"..........................###...####...#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC3[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###....##....#",
".........................#...#..#..#...#",
".........................#........#....#",
".........................#.........#...#",
- ".........................#...#..#..#...#", // 10
+ ".........................#...#..#..#...#", // 9
"..........................###....##....#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC4[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###...#..#...#",
".........................#...#..#..#...#",
".........................#......####...#",
".........................#.........#...#",
- ".........................#...#.....#...#", // 10
+ ".........................#...#.....#...#", // 9
"..........................###......#...#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC5[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###...####...#",
".........................#...#..#......#",
".........................#......###....#",
".........................#.........#...#",
- ".........................#...#.....#...#", // 10
+ ".........................#...#.....#...#", // 9
"..........................###...###....#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC6[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###....###...#",
".........................#...#..#......#",
".........................#......###....#",
".........................#......#..#...#",
- ".........................#...#..#..#...#", // 10
+ ".........................#...#..#..#...#", // 9
"..........................###...###....#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC7[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###...####...#",
".........................#...#.....#...#",
".........................#........#....#",
".........................#.......#.....#",
- ".........................#...#..#......#", // 10
+ ".........................#...#..#......#", // 9
"..........................###...#......#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpmC8[] = {
- "40 10 2 1",
- ". c #c0c0c0",
+ "40 9 2 1",
+ ". c none",
"# c #000000",
".......................................#",
"..........................###....##....#",
- ".........................#...#..#..#....#",
+ ".........................#...#..#..#...#",
".........................#.......##....#",
".........................#......#..#...#",
- ".........................#...#..#..#...#", // 10
+ ".........................#...#..#..#...#", // 9
"..........................###....##....#",
".......................................#",
".......................................#",
- ".......................................#",
};
static const char *mk1_xpm[] = {
@@ -266,7 +261,7 @@ static const char *mk1_xpm[] = {
"#######################................#",
"########################...............#",
"########################...............#",
- "####################################### ",
+ "########################################",
};
static const char *mk2_xpm[] = {
@@ -285,7 +280,7 @@ static const char *mk2_xpm[] = {
"#######################................#",
"########################...............#",
"########################...............#", // 7
- "####################################### ",
+ "########################################",
};
static const char *mk3_xpm[] = {
@@ -325,6 +320,83 @@ static const char *mk4_xpm[] = {
"........................................",
"........................................",
};
+
+static const char *mk5_xpm[] = {
+ "40 13 2 1",
+ ". c #ffff00",
+ "# c none",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ "#######################................#",
+ "########################...............#",
+ "########################...............#",
+ "########################################",
+ };
+
+static const char *mk6_xpm[] = {
+ "40 13 2 1",
+ ". c #ffff00",
+ "# c none",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 6
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //--------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#", // 7
+ "########################################",
+ };
+
+static const char *mk7_xpm[] = {
+ "40 13 2 1",
+ ". c #ffff00",
+ "# c none",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ "########################################",
+ };
+
+static const char *mk8_xpm[] = {
+ "40 13 2 1",
+ "# c #ffff00",
+ ". c none",
+ "........................................",
+ "........................................",
+ "........................................",
+ "#######################.................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "#######################.................",
+ "........................................",
+ "........................................",
+ "........................................",
+ };
+
/*
0 1 2 3 4 5 6 7 8 9 10
c-2 c-1 C0 C1 C2 C3 C4 C5 C6 C7 C8 - G8
@@ -367,10 +439,11 @@ static const char *mk4_xpm[] = {
//---------------------------------------------------------
Piano::Piano(QWidget* parent, int ymag)
- : MusEGui::View(parent, 1, ymag)
+ : View(parent, 1, ymag)
{
setMouseTracking(true);
curPitch = -1;
+ _curSelectedPitch = 60; // Start with 'C3"
octave = new QPixmap(oct_xpm);
c_keys[0] = new QPixmap(mk1_xpmC8);
c_keys[1] = new QPixmap(mk1_xpmC7);
@@ -385,6 +458,12 @@ Piano::Piano(QWidget* parent, int ymag)
mk2 = new QPixmap(mk2_xpm);
mk3 = new QPixmap(mk3_xpm);
mk4 = new QPixmap(mk4_xpm);
+
+ mk5 = new QPixmap(mk5_xpm);
+ mk6 = new QPixmap(mk6_xpm);
+ mk7 = new QPixmap(mk7_xpm);
+ mk8 = new QPixmap(mk8_xpm);
+
keyDown = -1;
button = Qt::NoButton;
}
@@ -398,39 +477,67 @@ void Piano::draw(QPainter& p, const QRect& r)
QPoint offset(0, KH*2);
p.drawTiledPixmap(r, *octave, r.topLeft()+offset);
+ if (_curSelectedPitch != -1 && _curSelectedPitch != curPitch)
+ {
+ int y = pitch2y(_curSelectedPitch);
+ QPixmap* pm;
+ switch(_curSelectedPitch % 12) {
+ case 0:
+ case 5:
+ pm = mk7;
+ break;
+ case 2:
+ case 7:
+ case 9:
+ pm = mk6;
+ break;
+ case 4:
+ case 11:
+ pm = mk5;
+ break;
+ default:
+ pm = mk8;
+ break;
+ }
+ p.drawPixmap(0, y, *pm);
+ }
+
+ if (curPitch != -1)
+ {
+ int y = pitch2y(curPitch);
+ QPixmap* pm;
+ switch(curPitch % 12) {
+ case 0:
+ case 5:
+ pm = mk3;
+ break;
+ case 2:
+ case 7:
+ case 9:
+ pm = mk2;
+ break;
+ case 4:
+ case 11:
+ pm = mk1;
+ break;
+ default:
+ pm = mk4;
+ break;
+ }
+ p.drawPixmap(0, y, *pm);
+ }
+
// draw C notes
for (int drawKey = 0; drawKey < 8;drawKey++) {
int octaveSize=91;
- int drawY = octaveSize * drawKey + 81 - KH*2;
+ int drawY = octaveSize * drawKey + 82 - KH*2;
if (drawY > r.y() && drawY < r.y() + r.height()) {
p.drawPixmap(0,drawY,*c_keys[drawKey]);
}
}
-
- if (curPitch == -1)
- return;
- int y = pitch2y(curPitch);
- QPixmap* pm;
- switch(curPitch % 12) {
- case 0:
- case 5:
- pm = mk3;
- break;
- case 2:
- case 7:
- case 9:
- pm = mk2;
- break;
- case 4:
- case 11:
- pm = mk1;
- break;
- default:
- pm = mk4;
- break;
- }
- p.drawPixmap(0, y, *pm);
+
+
}
//---------------------------------------------------------
@@ -547,6 +654,13 @@ void Piano::viewMousePressEvent(QMouseEvent* event)
int velocity = event->x()*127/40;
emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift); //emit keyPressed(keyDown, shift);
}
+
+ if (keyDown != -1 && keyDown != _curSelectedPitch) {
+ _curSelectedPitch = keyDown;
+ emit curSelectedPitchChanged(_curSelectedPitch);
+ redraw();
+ MusEGlobal::song->update(SC_DRUMMAP);
+ }
}
//---------------------------------------------------------
@@ -563,3 +677,28 @@ void Piano::viewMouseReleaseEvent(QMouseEvent* event)
}
}
+//---------------------------------------------------------
+// setCurSelectedPitch
+//---------------------------------------------------------
+
+void Piano::setCurSelectedPitch(int pitch)
+ {
+ if (pitch < 0 || pitch >= 128)
+ return;
+ if (pitch != _curSelectedPitch) {
+ _curSelectedPitch = pitch;
+ emit curSelectedPitchChanged(_curSelectedPitch);
+ redraw();
+ }
+ }
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void Piano::wheelEvent(QWheelEvent* ev)
+ {
+ emit redirectWheelEvent(ev);
+ }
+
+} // namespace MusEGui