summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-16 14:01:42 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-16 14:01:42 +0000
commit03e37abb33dfcaa9d67cadbb3b1d3c5ae17b057d (patch)
treea909766dc276e23e6a32293159235563f08303d6 /muse2
parent2cf9d99932d8f45d5508c45729bea7af4e6ec8fd (diff)
In "Cakewalk" mode, drum and instrument slivers are now stretched
to the whole rectangle's height
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/arranger/pcanvas.cpp68
1 files changed, 53 insertions, 15 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 599e90a0..9ad7bf3c 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -12,6 +12,7 @@
#include <values.h>
#include <uuid/uuid.h>
#include <math.h>
+#include <map>
#include <QClipboard>
#include <QLineEdit>
@@ -1660,7 +1661,7 @@ void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&)
//---------------------------------------------------------
-// drawWavePart
+// drawMidiPart
// bb - bounding box of paint area
// pr - part rectangle
//---------------------------------------------------------
@@ -1710,23 +1711,56 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi
}
}
else { // show Cakewalk Style
- //p.setPen(QColor(80,80,80));
- //EventList* events = mp->events();
- iEvent ito(events->lower_bound(to));
- //printf("PartCanvas::drawItem pTick:%d from:%d to:%d\n", pTick, from, to);
-
+ using std::map;
+ using std::pair;
+
+ iEvent ito(events->lower_bound(to)); //FINDMICH
bool isdrum = (mt->type() == Track::DRUM);
+
+ int lowest_pitch=127;
+ int highest_pitch=0;
+ map<int,int> y_mapper;
+
+ for (iEvent i = events->begin(); i != ito; ++i)
+ {
+ if (i->second.type()==Note)
+ {
+ int pitch=i->second.pitch();
+
+ if (!isdrum)
+ {
+ if (pitch > highest_pitch) highest_pitch=pitch;
+ if (pitch < lowest_pitch) lowest_pitch=pitch;
+ }
+ else
+ {
+ y_mapper.insert(pair<int,int>(pitch, 0));
+ }
+ }
+ }
+
+ if (isdrum)
+ {
+ int cnt=0;
+ for (map<int,int>::iterator it=y_mapper.begin(); it!=y_mapper.end(); it++)
+ {
+ it->second=cnt;
+ cnt++;
+ }
+ lowest_pitch=0;
+ highest_pitch=cnt-1;
+ }
+
+ if (lowest_pitch==highest_pitch)
+ {
+ lowest_pitch--;
+ highest_pitch++;
+ }
+
for (iEvent i = events->begin(); i != ito; ++i) {
int t = i->first + pTick;
int te = t + i->second.lenTick();
- if (t > (to + pTick))
- {
- //printf("PartCanvas::drawItem t:%d > to:%d + pTick:%d i->first:%d\n", t, to, pTick, i->first);
-
- break;
- }
-
if (te < (from + pTick))
continue;
@@ -1738,8 +1772,12 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi
int pitch = i->second.pitch();
int th = int(mt->height() * 0.75); // only draw on three quarters
int hoffset = (mt->height() - th ) / 2; // offset from bottom
- //int y = hoffset + (r.y() + th - (pitch * (th) / 127));
- int y = hoffset + r.y() + th - (isdrum?127-pitch:pitch) * th / 127;
+ int y;
+ if (!isdrum)
+ y = hoffset + r.y() + th - (pitch-lowest_pitch)*th/(highest_pitch-lowest_pitch);
+ else
+ y = hoffset + r.y() + y_mapper[pitch]*th/(highest_pitch-lowest_pitch);
+
p.drawLine(t, y, te, y);
}
}