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

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

there is this also, for sending a patch to the device:

--
-- Called when a modulator value changes
--

SendFullTone = function(modulator, newValue)

if tChar ~= nil then

	label = panel:getModulatorByName("lblPhTtl"):getComponent()
	PatchName = label:getProperty("uiLabelText")

	if PatchName == "" then 
		PatchName = tostring(pNumber) 
		label:setPropertyString ("uiLabelText", PatchName)
	end
	

	if PatchName ~= "*Roland MKS-50*" then

		TransName = ""
		addspace = 0
		b = 0

		for l=1,10 do

			char = string.sub(PatchName,l,l) 

			if char=="%" then char="@" end -- % causes issues. 
			charNum = TranslateStr(string.format(char))

			if tonumber(charNum) > 63 then -- this is for special charicters that are skipped.
				addspace = addspace + 1
			else
				TransName = string.format("%s%s", TransName, string.format(" %.2x", charNum))	
			end

		end
		
		while b < addspace do
			TransName = string.format("%s%s", TransName, string.format(" %.2x", 62)) -- adding blank spaces at the end if characters are not available.
			b = b + 1
		end

		---------------- Tone Transmit ------------------

		PatchCommand = "F0 41 35 00 23 20 01"
		PatchCommand = AddHexCommand("DcoEvMd", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfEvMd", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcaEvMd", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoPuls", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoSaw", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoSub", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoRnge", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoSbLv", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoNse", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfHpf", tostring(PatchCommand))
		PatchCommand = AddHexCommand("ChrsOF", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoLfo", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoEnv", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoAftr", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoPwm", tostring(PatchCommand))
		PatchCommand = AddHexCommand("DcoPwRt", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfFrq", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfRes", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfLfo", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfEnv", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfFolw", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcfAftr", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcaLvl", tostring(PatchCommand))
		PatchCommand = AddHexCommand("VcaAftr", tostring(PatchCommand))
		PatchCommand = AddHexCommand("LfoRate", tostring(PatchCommand))
		PatchCommand = AddHexCommand("LfoDly", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvT1", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvL1", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvT2", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvL2", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvT3", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvL3", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvT4", tostring(PatchCommand))
		PatchCommand = AddHexCommand("EnvFolw", tostring(PatchCommand))
		PatchCommand = AddHexCommand("ChrsRt", tostring(PatchCommand))
		PatchCommand = AddHexCommand("BndRange", tostring(PatchCommand))

		PatchCommand = string.format("%s%s%s", PatchCommand, TransName, " F7")

		panel:sendMidiMessageNow(CtrlrMidiMessage(PatchCommand))

	end

end

end

so this shows how the outgoing bulk message is put together
-and presumably would let you write *.syx files for a patch
library.
don’t yet understand ‘PatchCommand = string.format(..’ etc.
what is "%s%s%s"?

fascinating stuff for the midi fan. apologies if this is longwinded 🙂

Ctrlr