ModScript: Using scripts for a better and richer integration with MIDI controllers (beta soon!)

“MS helper” does not display the correct module instance ID (this must have changed in Rack). edit: see below for a fix.

Use the ID reported by the target module right-click-menu


here, the module ID is “7992587039813875”

Simple example ModScript
config.frameDivider = 16
config.bufferSize = 1

function NewPatchMaster(id)
	mod = Module(id)
	mod.params = {
		["Controller 1"] = {index = 0, min = 0.000000, max = 1.000000, default = 0.000000},
		["Controller 2"] = {index = 1, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 2, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 3, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 4, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 5, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 6, min = 0.000000, max = 1.000000, default = 0.000000},
		["No name"] = {index = 7, min = 0.000000, max = 1.000000, default = 0.000000},
	}
	mod.inputs = {
	}
	mod.outputs = {
	}
	mod.lights = {
		{index = 0},
		{index = 1},
		{index = 2},
		{index = 3},
		{index = 4},
		{index = 5},
		{index = 6},
		{index = 7},
		{index = 8},
		{index = 9},
		{index = 10},
		{index = 11},
		{index = 12},
		{index = 13},
		{index = 14},
		{index = 15},
		{index = 16},
		{index = 17},
		{index = 18},
		{index = 19},
		{index = 20},
		{index = 21},
		{index = 22},
		{index = 23},
		{index = 24},
		{index = 25},
		{index = 26},
		{index = 27},
		{index = 28},
		{index = 29},
		{index = 30},
		{index = 31},
		{index = 32},
		{index = 33},
		{index = 34},
		{index = 35},
		{index = 36},
		{index = 37},
		{index = 38},
		{index = 39},
		{index = 40},
		{index = 41},
		{index = 42},
		{index = 43},
		{index = 44},
		{index = 45},
		{index = 46},
		{index = 47},
		{index = 48},
		{index = 49},
		{index = 50},
		{index = 51},
		{index = 52},
		{index = 53},
		{index = 54},
		{index = 55},
		{index = 56},
		{index = 57},
		{index = 58},
		{index = 59},
		{index = 60},
		{index = 61},
		{index = 62},
		{index = 63},
		{index = 64},
		{index = 65},
		{index = 66},
		{index = 67},
		{index = 68},
		{index = 69},
		{index = 70},
		{index = 71},
	}
	return mod
end

myPM = NewPatchMaster(7992587039813875)

function process(block)

	value = myPM:getParam("Controller 1")
	display('Controller 1: ' .. value)

	value = myPM:getParam("Controller 2")
	display('Controller 2: ' .. value)

end

Result is live values scrolling, if Rack was started in a shell.

[2508.086 debug src/LuaJITEngineAPI.cpp:6 display] Controller 1: 0.5
[2508.086 debug src/LuaJITEngineAPI.cpp:6 display] Controller 2: 0
1 Like