-
-
Save dndrks/436e7d60da52bf0cba90a2ccf7de361a to your computer and use it in GitHub Desktop.
midi clock out matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could also get fancy and use the params rebuilder actions to capture names of newly added devices!