|
| 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