Skip to content

Commit 6081cfd

Browse files
Add files via upload
1 parent 4fde871 commit 6081cfd

File tree

4 files changed

+268
-4
lines changed

4 files changed

+268
-4
lines changed

code-extracts.lua

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
function onValueChanged(x)
3+
if x == "x" then
4+
root.children.midiactions:notify("EFF", 1)
5+
end
6+
end
7+
8+
9+
10+
function onValueChanged()
11+
local t = { "Off", "DF Sens", "DF Cutoff freq", "DF Q", "DF Up/Down", "Comp Attack", "Comp Sustain", "OD Tone", "OD Drive", "OD Turbo", "Dist Tone", "Dist Drive", "Phaser Rate", "Phaser Depth", "Phaser Resonance", "Eq High", "Eq Mid", "Eq Low", "Eq Volume", "DD Level", "DD Time", "DD Feedback", "Chorus Rate", "Chorus Depth", "Chorus Level", "Chorus Pre Delay", "Chorus Feedback", "Master Volume" }
12+
self.parent.children.eparamname.values.text = t[tonumber(self.values.text) + 1]
13+
14+
-- propagate on midi
15+
root.children.midiactions:notify("EXP", 1)
16+
end
17+
18+
19+
-- slider for string16
20+
21+
function onValueChanged()
22+
local pos = 6
23+
local r = string.char(math.floor(self.values.x * 95 + 32))
24+
local str = self.parent.children.string16.values.text
25+
local new = string.sub(str, 1, pos - 1) .. r .. string.sub(str, pos + 1, 16)
26+
self.parent.children.string16.values.text = new
27+
end
28+
29+
-- preset left or right
30+
31+
function onValueChanged(x)
32+
if x == "x" and self.values.x == 0 then
33+
local gbn = 0
34+
if self.parent.children.group.values.text == "B" then
35+
gbn = 64
36+
end
37+
gbn = gbn + (tonumber(self.parent.children.bank.values.text) - 1) * 8 + (tonumber(self.parent.children.number.values.text) - 1)
38+
gbn = gbn - 1 -- + 1 to go right
39+
if gbn < 0 then
40+
gbn = gbn + 128
41+
elseif gbn > 127 then
42+
gbn = gbn - 128
43+
end
44+
if gbn > 63 then
45+
gbn = gbn - 64
46+
self.parent.children.group.values.text = "B"
47+
else
48+
self.parent.children.group.values.text = "A"
49+
end
50+
local b = math.floor(gbn / 8) + 1
51+
self.parent.children.bank.values.text = b
52+
gbn = gbn - (b - 1) * 8 + 1
53+
self.parent.children.number.values.text = gbn
54+
end
55+
end
56+

main-midiaction.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function checksum(t)
44
do
55
cs = cs + t[i]
66
end
7-
return cs % 0x80
7+
return 0x80 - (cs % 0x80)
88
end
99

1010
-- read effects MSB
@@ -294,7 +294,7 @@ end
294294

295295
-- read NAME
296296
function nameParam(t)
297-
local str = root.children.gname.children.string16.values.text
297+
local str = root.children.string16.values.text
298298
for i = 1, 16 do
299299
t[#t + 1] = string.byte(str, i)
300300
end
@@ -304,7 +304,7 @@ end
304304
-- send bytes of data at the given roland address
305305
-- this fuction creates the sysex header and happends checksum and end of sysex then sends to MIDI
306306
function sendOneParam(data)
307-
if #data == 0 then
307+
if #data == 0 or self.values.x == 0 then
308308
return
309309
end
310310

@@ -322,6 +322,9 @@ end
322322

323323
-- send all params in GP8 memory (given group-bank-number id)
324324
function writeAll(gbn)
325+
if self.values.x == 0 then
326+
return
327+
end
325328
local address = (gbn * 0x40) + 0x2000
326329
local addressMSB = math.floor(address / 0x80)
327330
local addressLSB = address % 0x80
@@ -342,7 +345,6 @@ function writeAll(gbn)
342345
ext2AllParams(t)
343346
nameParam(t)
344347
t[#t + 1] = 0x0 -- end of string
345-
-- end todo
346348
sendOneParam(t)
347349
end
348350

midi-change-program.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- midi-change-program.lua
2+
3+
function checksum(t)
4+
local cs = 0
5+
for i = 6, #t
6+
do
7+
cs = cs + t[i]
8+
end
9+
return 0x80 - (cs % 0x80)
10+
end
11+
12+
function wait40ms()
13+
local t1 = getMillis()
14+
local t2 = t1
15+
while t2 - t1 < 40 do
16+
t2 = getMillis()
17+
end
18+
end
19+
20+
function requestValues(channel, gbn)
21+
local address = (gbn * 0x40) + 0x2000
22+
local addressMSB = math.floor(address / 0x80)
23+
local addressLSB = address % 0x80
24+
local t = { 0xF0, 0x41, channel - 1, 0x13, 0x11, addressMSB, addressLSB, 0x0, 0x32 }
25+
t[#t + 1] = checksum(t)
26+
t[#t + 1] = 0xF7
27+
sendMIDI(t)
28+
end
29+
30+
function onValueChanged(x)
31+
if x == "x" and self.values.x == 0 then
32+
local gbn = 0
33+
if self.parent.children.group.values.text == "B" then
34+
gbn = 64
35+
end
36+
gbn = gbn + (tonumber(self.parent.children.bank.values.text) - 1) * 8 + (tonumber(self.parent.children.number.values.text) - 1)
37+
self.parent.children.label4.values.text = tostring(gbn)
38+
39+
sendMIDI({ MIDIMessageType.PROGRAMCHANGE - 1 + tonumber(self.parent.children.channel.values.text), gbn })
40+
wait40ms()
41+
requestValues(tonumber(self.parent.children.channel.values.text), gbn)
42+
end
43+
end

midi-receive.lua

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
-- midi-receive.lua
2+
3+
-- root.children.midiactions:notify("DF", 1)
4+
function enableMIDI(b)
5+
if (b) then
6+
root.children.midiactions.values.x = 1
7+
else
8+
root.children.midiactions.values.x = 0
9+
end
10+
end
11+
12+
function odd(v)
13+
return 2 * (math.floor(v/2)) ~= v
14+
end
15+
16+
function effectsMSB(v)
17+
local a = v
18+
for i = 1, 4 do
19+
if i == 1 then
20+
root.children.phaser.children.phaser.values.x = odd(a)
21+
elseif i == 2 then
22+
root.children.eq.children.eq.values.x = odd(a)
23+
elseif i == 3 then
24+
root.children.dd.children.dd.values.x = odd(a)
25+
elseif i == 4 then
26+
root.children.chorus.children.chorus.values.x = odd(a)
27+
end
28+
a = math.floor(a / 2)
29+
end
30+
end
31+
32+
function effectsLSB(v)
33+
local a = v
34+
for i = 1, 4 do
35+
if i == 1 then
36+
root.children.df.children.df.values.x = odd(a)
37+
elseif i == 2 then
38+
root.children.comp.children.comp.values.x = odd(a)
39+
elseif i == 3 then
40+
root.children.od.children.od.values.x = odd(a)
41+
elseif i == 4 then
42+
root.children.dist.children.dist.values.x = odd(a)
43+
end
44+
a = math.floor(a / 2)
45+
end
46+
end
47+
48+
function setValues(t)
49+
local s = 0x8
50+
local v = 0
51+
local name = ""
52+
for i = 1, #t do
53+
v = t[i]
54+
-- effects
55+
if i == s + 0x0 then
56+
effectsMSB(v)
57+
elseif i == s + 0x1 then
58+
effectsLSB(v)
59+
-- df
60+
elseif i == s + 0x2 then
61+
root.children.df.children.dfsens.values.x = v / 100
62+
elseif i == s + 0x3 then
63+
root.children.df.children.dfcutoff.values.x = v / 100
64+
elseif i == s + 0x4 then
65+
root.children.df.children.dfq.values.x = v / 100
66+
elseif i == s + 0x5 then
67+
local a = "DOWN"
68+
if v > 50 then
69+
a = "UP"
70+
end
71+
root.children.df.children.updown.values.text = a
72+
-- comp
73+
elseif i == s + 0x6 then
74+
root.children.comp.children.compattack.values.x = v / 100
75+
elseif i == s + 0x7 then
76+
root.children.comp.children.compsustain.values.x = v / 100
77+
-- od
78+
elseif i == s + 0x8 then
79+
root.children.od.children.fodtone.values.x = v / 100
80+
elseif i == s + 0x9 then
81+
root.children.od.children.foddrive.values.x = v / 100
82+
elseif i == s + 0xA then
83+
local a = "STD"
84+
if v > 50 then
85+
a = "TURBO"
86+
end
87+
root.children.od.children.turbo.values.text = a
88+
-- dist
89+
elseif i == s + 0xB then
90+
root.children.dist.children.disttone.values.x = v / 100
91+
elseif i == s + 0xC then
92+
root.children.dist.children.distdrive.values.x = v / 100
93+
-- phaser
94+
elseif i == s + 0xD then
95+
root.children.phaser.children.phaserrate.values.x = v / 100
96+
elseif i == s + 0xE then
97+
root.children.phaser.children.phaserdepth.values.x = v / 100
98+
elseif i == s + 0xF then
99+
root.children.phaser.children.phaserresonance.values.x = v / 100
100+
-- eq
101+
elseif i == s + 0x10 then
102+
root.children.eq.children.eqhigh.values.x = v / 100
103+
elseif i == s + 0x11 then
104+
root.children.eq.children.eqmid.values.x = v / 100
105+
elseif i == s + 0x12 then
106+
root.children.eq.children.eqlow.values.x = v / 100
107+
elseif i == s + 0x13 then
108+
root.children.eq.children.eqvol.values.x = v / 100
109+
-- dd
110+
elseif i == s + 0x14 then
111+
root.children.dd.children.fddlevel.values.x = v / 100
112+
elseif i == s + 0x15 then
113+
root.children.dd.children.ddtime.values.x = 128 * v / 1000
114+
elseif i == s + 0x16 then
115+
root.children.dd.children.ddtime.values.x = root.children.dd.children.ddtime.values.x + v / 1000
116+
elseif i == s + 0x17 then
117+
root.children.dd.children.ddfeedback.values.x = v / 100
118+
-- chorus
119+
elseif i == s + 0x18 then
120+
root.children.chorus.children.chorusrate.values.x = v / 100
121+
elseif i == s + 0x19 then
122+
root.children.chorus.children.chorusdepth.values.x = v / 100
123+
elseif i == s + 0x1A then
124+
root.children.chorus.children.choruslevel.values.x = v / 100
125+
elseif i == s + 0x1B then
126+
root.children.chorus.children.choruspredelay.values.x = v / 100
127+
elseif i == s + 0x1C then
128+
root.children.chorus.children.chorusfeedback.values.x = v / 100
129+
-- other
130+
elseif i == s + 0x1D then
131+
root.children.other.children.mastervol.values.x = v / 100
132+
elseif i == s + 0x1E then
133+
root.children.other.children.eparam.values.text = tostring(v)
134+
-- ext 1 & 2
135+
elseif i == s + 0x1F then
136+
root.children.ext1.children.ext1.values.x = (v > 50)
137+
elseif i == s + 0x20 then
138+
root.children.ext2.children.ext2.values.x = (v > 50)
139+
-- name
140+
elseif i == s + 0x31 then
141+
root.children.string16.values.text = name
142+
elseif (i > s + 0x20) and (i < s + 0x21 + 16) then
143+
name = name .. string.char(v)
144+
end
145+
end
146+
end
147+
148+
-- test
149+
function test(x)
150+
setValues({240, 65, 0, 19, 18, 64, 0, 15, 15, 20, 30, 40, 0, 80, 90, 10, 20, 0, 70, 80, 50, 60, 70, 20, 30, 40, 50, 90, 6, 32, 70, 30, 40, 50, 60, 70, 70, 14, 100, 100, 65, 66, 67, 68, 69, 70, 32, 78, 97, 109, 101, 32, 32, 58, 45, 41, 0, 0, 56})
151+
end
152+
153+
-- main
154+
function onReceiveMIDI(message, connections)
155+
if (#message > 57) and (message[1] == 0xF0) and (message[2] == 0x41) and (message[4] == 0x13) and (message[5] == 0x12) then
156+
enableMIDI(false)
157+
setValues(message)
158+
enableMIDI(true)
159+
return true
160+
else
161+
return false
162+
end
163+
end

0 commit comments

Comments
 (0)