-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5x5 midi grid notes 36-60.littlefoot
81 lines (72 loc) · 1.87 KB
/
5x5 midi grid notes 36-60.littlefoot
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
80
void initialise()
{
clearDisplay();
for (int g=0;g<25;g++)
{
if (g % 2 == 0)
{
fillRect (0x0d0702, g%5*3, int(g/5)*3, 3, 3);
}
else
{
fillRect (0x1a0e05, g%5*3, int(g/5)*3, 3, 3);
}
}
}
void handleMIDI(int type, int note, int velocity)
{
if (type == 144)
{
if (note>=36 && note <=60)
{
int r = int(map(float(velocity),0.0,127.0,25.5,255.0));
int g = int(map(float(velocity),0.0,127.0,13.6,136.0));
int b = int(map(float(velocity),0.0,127.0,5.1,51.0));
int col = makeARGB(255,r,g,b);
int pos = note - 36;
fillRect(col,(pos%5)*3,int(pos/5)*3,3,3);
}
}
if (type == 128)
{
if (note>=36 && note<=60)
{
int pos_off = note - 36;
if (pos_off % 2 == 0)
{
fillRect(0x0d0702,(pos_off%5)*3,int(pos_off/5)*3,3,3);
}
else
{
fillRect(0x1a0e05,(pos_off%5)*3,int(pos_off/5)*3,3,3);
}
}
}
}
void touchStart (int index, float x, float y, float z, float vz)
{
int x_int = convertPositionToPixel(x);
int y_int = convertPositionToPixel(y);
int note = x_int/3+(y_int/3)*5+36;
setHeapByte(index, note);
sendNoteOn(0,note,127);
}
void touchMove (int index, float x, float y, float z, float vz)
{
int x_int = convertPositionToPixel(x);
int y_int = convertPositionToPixel(y);
int newnote = x_int/3+(y_int/3)*5+36;
int note = getHeapByte(index);
if (note != newnote)
{
sendNoteOff(0,note,127);note=newnote;sendNoteOn(0,note,127);setHeapByte(index,newnote);
}
}
void touchEnd (int index, float x, float y, float z, float vz)
{
sendNoteOff(0,getHeapByte(index),127);
}
int convertPositionToPixel (float pos)
{
return int (map(pos,0.0,1.9,0.15,4.55)) * 3;
}