Reply To: Demo panel for MIDI receive/transmit routines

Home Forums General Using Ctrlr Demo panel for MIDI receive/transmit routines Reply To: Demo panel for MIDI receive/transmit routines

#73186
human fly
Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    in the MKS-50 Advanced bpanelz by layzer/bomma72, there’s a
    method called ‘setPatch’ that seems to be the basis of a
    typical sysex receive operation.

    after a dump request has been sent to the device, this is
    used to check size and identify the type of data dump.
    in this case, whether it is Tone or Patch data

    setPatch = function(midiMessage)
    
    s = midiMessage:getSize()
    if s == 54 then
    	assignToneValues(midiMessage)  
    	end
    
    if s == 31 then
    	assignPatchValues(midiMessage)  
    	end
    end

    assignToneValues and assignPatchValues are 2 functions tacked
    onto the end of the method, as:

    function assignToneValues(midiMessage)
    	
    	programData = midiMessage:getLuaData()
    
    	--console ("RAW DATA: ")
    	--console (programData:toHexString(1))
    	
    	panel:getModulatorByName("DcoEvMd"):setValueMapped(programData:getByte(7), true)
    	panel:getModulatorByName("VcfEvMd"):setValueMapped(programData:getByte(8), true)
    
    etc...
    	panel:getModulatorByName("BndRange"):setModulatorValue(programData:getByte(42), false, false, true)
    	pName = string.format("%s%s%s%s%s%s%s%s%s%s",
    			TranslateChar (string.format (programData:getByte(43), number )),
    			TranslateChar (string.format (programData:getByte(44), number )),
    
    etc..
    
    end
    
    function assignPatchValues(midiMessage)
    	
    	programData = midiMessage:getLuaData()
    
    	--console ("RAW DATA: ")
    	--console (programData:toHexString(1))
    
    	tNumber = string.format("%.2x",programData:getByte(7))
    	KeyLow =  string.format("%.2x",programData:getByte(8))
    	KeyHigh = string.format("%.2x",programData:getByte(9))
    
    etc...
    	
    end

    so programData = midiMessage:getLuaData() creates a ?memory block?

    and then bytes can be accessed as items, and values used to set panel
    modulator values, eg:

    panel:getModulatorByName("DcoEvMd"):setValueMapped(programData:getByte(7),
    true)

    parameter data starts at byte7 -previous 6 bytes are the sysex header.

    Ctrlr