Re: midiMessageRecieved values for modulators

Home Forums General Programming midiMessageRecieved values for modulators Re: midiMessageRecieved values for modulators

#4421
Cramp
Participant
  • Topics: 11
  • Replies: 66
  • Total: 77

after I finished the post and then tried to figure out again script according to Message Type $40 it works now without configuring each controller and knob.

I created Update button and set the ‘Update’ script on it

[code:1xfzwott]UpdatePatch = function(modulator, newValue)
slot= panel:getModulatorByName("Slot Number")

if program ~= nil and bank ~= nil and slot~= nil then
m = CtrlrMidiMessage({0xF0, 0x33, 0, 0x09, 0x40, slot:getModulatorValue(), 0xF7})
panel:sendMidiMessageNow(m)
end

end[/code:1xfzwott]

midiMessageRecieved looks like
[code:1xfzwott]–
— Called when a panel receives a midi message (does not need to match any modulator mask)
— @midiMessage http://ctrlr.org/api/class_ctrlr_midi_message.html

midiMessageReceived = function(midiMessage)

s = midiMessage:getMidiMessageType()
if s == 7 then
program_number = panel:getModulatorByName("Patch")
if program_number ~= nil then
xx = midiMessage:getValue()
if xx ~= nil then
program_number:setModulatorValue(xx+1,false,false,true)
end
end
end

s = midiMessage:getSize()
if s == 524 then
if dump_send ~= nil then
if dump_send == 1 then
— console("received program data")
PatchDataLoaded = midiMessage:getLuaData()
assignValues(midiMessage)
dump_send = 0
end
end
end
end
function assignValues(midiMessage)
— console ("assignValues")
lastSavedProgram = midiMessage:getLuaData()
programData = midiMessage:getLuaData():getRange(09,514)
programNumber = midiMessage:getLuaData():getRange(08,1)
PatchDataLoaded = midiMessage:getLuaData()
— console ("RAW DATA: ")
— console (PatchDataLoaded:toHexString(1))

— panel:getModulatorByName("FilterFreq1"):setModulatorValue(programData:getByte(74), false, false, true)

symbols = {"|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|"," ","!","","#","$","%","&","’","(",")","*","+","4","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","b","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"}
a = symbols[programData:getByte(240)]
b = symbols[programData:getByte(241)]
c = symbols[programData:getByte(242)]
d = symbols[programData:getByte(243)]
e = symbols[programData:getByte(244)]
f = symbols[programData:getByte(245)]
g = symbols[programData:getByte(246)]
h = symbols[programData:getByte(247)]
i = symbols[programData:getByte(248)]
j = symbols[programData:getByte(249)]

patch = programNumber:getByte(0)

if patch ~= nil and bank_Select ~= nil and program_Select ~= nil then
text1 = string.format("%s%s%s%s%s%s%s%s%s%s", a, b, c, d, e, f, g, h, i, j)
patchName = panel:getModulatorByName("Patch")
if patchName ~= nil then
c = patchName:getComponent()
c:setPropertyString ("Patch Name", text1)
end
pos = 1
text = string.format("%s", "Patch Loaded")
text2 = string.format("%s", text1)
end
redraw = panel:getPanelEditor():getCanvas()
redraw:repaint()
end
[/code:1xfzwott]

and also set prgram change know to use that script. and it works
when I change program (patch) on panel every knob and slider lights changing to patch values. thats awesome

The only thing I cannot realize is how to change Slot value. Is there any code how to change the MIDI channel?

Ctrlr