-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMFD_MIDI Guitar PB Control.jsfx
81 lines (70 loc) · 1.9 KB
/
MFD_MIDI Guitar PB Control.jsfx
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
81
desc:MIDI Guitar Pitch Bend Control
author: Michael Fewkes
version: 0.9
changelog: Initial release
about: Control options for pitch bend designed for MIDI guitar
//slider1:8192<0,16383,1>In Pitch Bend
//slider2:8192<0,16383,1>Out Pitch Bend
slider3:12<1,24,1>PB Range In
slider4:2<1,24,1>PB Range Out
slider5:0<0,3,1{pass thru,rounded,rounded with steps,stepped}>PB Style
slider6:10<0,50,0.1>Threshdold in cents
@init
PBout = 8192;
oldbend = 0;
@slider
PBi = slider3;
PBo = slider4;
style = slider5;
thresh = slider6;
@block
while (midirecv(offset,msg1,msg2,msg3)) ( //MIDI revieve loop
(msg1 & $xF0) == $xE0 ? ( //converting PB to number
mult = PBi/PBo;
pbincents = 8192/PBo/100;
stepSize = 8192/PBo;
actThresh = pbincents * thresh;
LSBin = msg2;
MSBin = msg3;
PBin = LSBin + (MSBin * 128);
//slider1 = PBin;
//sliderchange(slider1);
// style adjustments go here
PBmid = (PBin - 8192) * mult;
(style == 0) ? PBout = PBmid + 8192; //pass thru
(style == 1) ? ( //rounded
(PBmid < actThresh) && (PBmid > -actThresh) ? PBmid = 0;
PBout = PBmid + 8192;);
(style == 2) ? ( //rounded with steps
k = -PBo;
while(k <= PBo) (
(PBmid < actThresh + (stepSize * k)) && (PBmid > -actThresh + (stepSize * k)) ? PBmid = 0 + (stepSize * k);
PBout = PBmid + 8192;
k += 1;
);
);
(style == 3) ? ( //stepped
k = -PBo;
stepFound = 0;
while(k <= PBo) (
(PBmid < actThresh + (stepSize * k)) && (PBmid > -actThresh + (stepSize * k)) ? (
PBmid = 0 + (stepSize * k);
oldbend = PBmid;
stepFound = 1;
);
k += 1;
);
stepFound == 0 ? PBmid = oldbend;
PBout = PBmid + 8192;
);
PBout > 16383 ? PBout = 16383; //converting number back to PB
PBout < 0 ? PBout = 0;
LSBout = PBout & 127;
MSBout = PBout>>7;
//slider2 = PBout;
//sliderchange(slider2);
midisend(offset, msg1, LSBout, MSBout);
) : (
midisend(offset, msg1, msg2, msg3);
)
);