-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArpMatrix.cpp
79 lines (63 loc) · 2.28 KB
/
ArpMatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "Arponaut.h"
#include "ArpMatrix.h"
#include <algorithm>
// Arp matrix is 250px high, 10 octaves * 12 * 2 pixels == 240px representing the sequence
// 16 steps * 24px == 384px wide
ArpMatrix::ArpMatrix(IPlugBase* pPlug, Sequence* sequence, int x, int y)
: IControl(pPlug, &IRECT(x, y, x+kMatrixWidth, y+kMatrixHeight)), sequence_(sequence)
{
}
bool ArpMatrix::Draw(IGraphics* pGraphics)
{
IColor bgcolor;
// pGraphics->DrawRect(&bgcolor, &mRECT);
// pGraphics->FillIRect(&bgcolor, &mRECT);
// pGraphics->DrawBitmap(background_, &mRECT, mRECT.L, mRECT.T);
// always display 16 steps
int spos = sequence_->pos;
int page = spos / 16;
int upper = sequence_->playLength() - page*16;
if (upper > 16) upper = 16;
for (int i=page*16; i < page*16 + upper; ++i) {
int nn = sequence_->get(i)->NoteNumber();
if (nn) {
DrawNote(pGraphics, i % 16, nn);
}
}
// cursor
int left = (sequence_->playPos() % 16)*20 + mRECT.L;
int top = mRECT.T;
IRECT notebox(left, top, left+20, top+4);
IColor noteColor(255, 255, 255, 40);
pGraphics->FillIRect(¬eColor, ¬ebox);
// pGraphics->DrawBitmap(&mBackground, &mRECT, 1, &mBlend);
// pGraphics->DrawBitmap(&mPuck, &IRECT(mMouseX, mMouseY, &mPuck), 1, &mBlend);
return true;
}
void ArpMatrix::SetDirty(bool pushParamToPlug)
{
mDirty = true;
// mValueX = BOUNDED(mValueX, mClampXLo, mClampXHi);
// mValueY = BOUNDED(mValueY, mClampYLo, mClampYHi);
// mDirty = true;
// if (pushParamToPlug && mPlug && mParamXIdx >= 0 && mParamYIdx >= 0) {
// mPlug->SetParameterFromGUI(mParamXIdx, mValueX);
// mPlug->SetParameterFromGUI(mParamYIdx, mValueY);
// }
}
void ArpMatrix::OnMouseDown(int x, int y, IMouseMod* pMod)
{
}
void ArpMatrix::OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod)
{
}
void ArpMatrix::DrawNote(IGraphics* pGraphics, int iseq, int note)
{
int left = iseq*kMatrixPW + mRECT.L;
int top = (kMatrixHeight - note*2) + mRECT.T;
IRECT notebox(left, top, left+18, top+2);
IColor noteColor(127, 255, 40, 40);
if (sequence_->playPos() % 16 == iseq)
noteColor.A = 255;
pGraphics->FillIRect(¬eColor, ¬ebox);
};