I meant 15, sorry.
The complete script is here (I’m commented out everything that previously triggered sound, so it’s just your clock setup in init() that’s making any sound.
--
-- Link Clock Test
--
-- v0.5.5 @toneburst
local ControlSpec = require 'controlspec'
engine.name = "GridKit"
-- Step position
local step = 0
-- States of the 3 Norns buttons
local button_states = {0,0,0}
local pattern = {
{1,0,0,0,0,0,0.568627451,0,0,0,0,0,0.8549019608,0,0,0,0.2823529412,0,0.1411764706,0,0.7137254902,0,0,0,0.4274509804,0,0,0,0.2823529412,0,0,0},
{0.1411764706,0,0.4274509804,0,0,0,0.031372549,0,0.95,0,0,0,0,0,0.2823529412,0,0,0,0.7137254902,0,0,0,0.1411764706,0,0.8549019608,0,0,0,0.568627451,0,0,0},
{0.6666666667,0,0.4431372549,0,0.9,0,0.2196078431,0,0.6666666667,0,0.5529411765,83,0,0.7764705882,0,0.2196078431,0,0.6666666667,0,0.4431372549,0,0.8862745098,0,0.1098039216,0,0.6666666667,0,0.4431372549,0,0.7764705882,0,0.3333333333}
}
reset_count = 0
reset_period = 16
--------------------
-- Main ------------
--------------------
function init()
-- Restart screen saver timer
screen.ping()
-- Default render Style
screen.level(15)
screen.aa(0)
screen.line_width(1)
screen.font_size(8)
params:add_control("thresholdkick","density kick",ControlSpec.new(0.0,1.0,'lin',0,0.1))
params:add_control("thresholdsnare","density snare",ControlSpec.new(0.0,1.0,'lin',0,0.0))
params:add_control("thresholdhat","density hat",ControlSpec.new(0.0,1.0,'lin',0,0.0))
-- https://llllllll.co/t/norns-scripting-link-syncing-bar-starts-global-clock/31734/12?u=toneburst
local function sequence()
while true do
clock.sync(4)
for i=1,15 do
engine.trig_kick(0.3)
clock.sync(1/4)
end
end
end
clock.run(sequence)
end -- end init()
function do_step()
print("count: " .. reset_count)
--print("step".. step)
-- if pattern[1][reset_count + 1] >= (1 - params:get('thresholdkick')) then
-- engine.trig_kick(0.3)
-- end
-- if pattern[2][reset_count + 1] >= (1 - params:get('thresholdsnare')) then
-- engine.trig_snare(0.3)
-- end
-- if pattern[3][reset_count + 1] >= (1 - params:get('thresholdhat')) then
-- engine.trig_hat(0.3)
-- end
end -- end do_step()
--------------------
-- Interactions ----
--------------------
function key(id,state)
end -- end key()
function enc(id,delta)
end --end enc()
--------------------
-- Render ----------
--------------------
function redraw()
end -- end redraw()
The 15 kicks are beautifully synced to Samplr, though!
I’ve tried changing the number of iterations and the divisor, but it always seems to leave a silent bar after running through the loop.
Tempo changes track beautifully at either end.
A couple of other little things I noticed:
- The tempo in the params list doesn’t seem to update when tempo is changed from another Link client (or at least not in realtime)
- Also, sometimes (but not every time, I think), Norns forces the tempo of Samplr to change when the script starts, rather than syncing to the tempo already established by the other Link client. This may be intended behaviour, but doesn’t seem to be 100% consistent.