Skip to content

Instantly share code, notes, and snippets.

@dndrks

dndrks/mcom.lua Secret

Last active June 3, 2021 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dndrks/436e7d60da52bf0cba90a2ccf7de361a to your computer and use it in GitHub Desktop.
Save dndrks/436e7d60da52bf0cba90a2ccf7de361a to your computer and use it in GitHub Desktop.
midi clock out matrix
function init()
midi_clock_out = {}
midi_vports = {}
midi_device = {}
for i = 1,#midi.vports do
midi_vports[i] = midi.vports[i].name ~= "none" and (util.trim_string_to_width(midi.vports[i].name,90)) or tostring(i)..": [device]"
midi_clock_out[i] = false
midi_device[i] = midi.connect(i)
end
params:add_group("MIDI CLOCK OUT MATRIX",17)
params:add_separator("send MIDI clock?")
for i = 1,16 do
params:add_option("port_"..i.."_clock_out", midi_vports[i],{"no","yes"},1)
params:set_action("port_"..i.."_clock_out", function(x)
if x == 1 then
midi_clock_out[i] = false
else
midi_clock_out[i] = true
if params:get("clock_midi_out") - 1 == i then
params:set("clock_midi_out",1)
end
end
end)
end
midi_out_clocks = clock.run(function()
while true do
clock.sync(1/24)
for k,v in pairs(midi_clock_out) do
if v == true then
midi_device[k]:clock()
-- print("sending MIDI clock to "..k) -- uncomment to see the storm!
end
end
end
end)
end
@dndrks
Copy link
Author

dndrks commented Jun 3, 2021

could also get fancy and use the params rebuilder actions to capture names of newly added devices!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment