What a good lesson @dan_derks! I’ve only been coding for a couple of weeks and watching these makes it a breeze. Having this info accessible to new adopters will surely help propel this community forward.
How difficult is it to add clocking via external midi to a patch? I’m trying to apply it to AWAKE but every time I switch my clock to external everything comes to a halt.
I’ve written this baby Test Script to mess around with and try out some ideas.
Little baby script
music = require ‘musicutil’
beatclock = require ‘beatclock’
clk = beatclock.new()
clk_midi = midi.connect(1)
clk_midi.event = clk.process_midi
function go()
norns.script.load(norns.state.script)
end
step = 1
function init()
clk.on_step = function() redraw() tick() end
clk.on_select_internal = function() clk:start() end
clk.on_select_external = function() print(“external”) end
clk:add_clock_params()
clk:start()
source_get = params:get(“clock”)
clk_src = params:get(“clock_source”)
end
function tick()
step = (step % 4) + 1
end
function enc(n,d)
if n == 1 then
source_get = util.clamp(source_get + d, 1, 2)
params:set(“clock”, source_get)
redraw()
elseif n == 2 then
clk_src = util.clamp(clk_src + d, 1, 2)
params:set(“clock_source”, clk_src)
redraw()
end
end
function int_ext()
if source_get == 1 then
int_ex = “internal”
elseif source_get == 2 then
int_ex = “external”
end
return int_ex
end
function int_midi()
if clk_src == 1 then
sponge = “internal”
elseif clk_src == 2 then
sponge = “midi”
end
return sponge
end
function redraw()
screen.clear()
screen.level(1)
screen.move(0,5)
screen.text(int_ext())
screen.move(0,15)
screen.text(int_midi())
screen.move(54,22)
screen.text("step: "…step)
screen.move(54,32)
screen.text("bpm: "…params:get(“bpm”))
screen.move(54,42)
screen.text("midi_bpm: "…params:get(“clock_tempo”))
screen.update()
end
before I started writing it I could go into parameters - CLOCK set the source to midi and see the tempo change when I adjusted the clock on the midi device but, for some reason that stopped working altogether by the time I finished my script.