Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es2!! #1

Merged
merged 1 commit into from Aug 1, 2020
Merged

es2!! #1

Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -0,0 +1,79 @@
-- Exquisite Script # 2

graphics = include "lib/graphics"

scale = {0,2,3,5,7,8,10,12,15}
pattern = { {}, {}, {}, {}, {}, {} }
steps = 8
pos = {1,1,1,1,1,1}
div = {1,1,1,1,1,1}
selector = 1

j = crow.ii.jf

function init()
j.mode(1)
clk = {}
for i=1,6 do
clk[i] = clock.run(tick,i)
end
build()
end

function tick(voice)
while true do
clock.sync(1/div[voice])
count(voice)
end
end

function count(voice)
pos[voice] = (pos[voice] % steps) + 1
j.play_voice(voice,pattern[voice][pos[voice]]/12, 8)
end

function build()
for i=1,6 do
for n=1,steps do
pattern[i][n] = scale[math.random(#scale)]
end
end
end

function key(n,d)
if n == 2 and d == 1 then
build()
elseif n == 3 and d == 1 then
for i=1,6 do
div[i] = math.random(1,4)
end
end
redraw()
end

function enc(n,d)
if n == 1 then
steps = util.clamp(steps+d,1,8)
elseif n == 2 then
selector = util.clamp(selector+d,1,6)
elseif n == 3 then
div[selector] = util.clamp(div[selector]+d,1,4)
end
redraw()
end

function redraw()
screen.clear()
screen.level(15)
screen.move(8,20)
screen.text(steps)
graphics.baseline()
for i=1,6 do
screen.level(i == selector and 15 or 2)
screen.move(i*8,32)
screen.text(div[i])
graphics.visualizer(i,div[i])
end

screen.update()
end
@@ -0,0 +1,25 @@
local graphics = {}

function graphics.init() end

function graphics.mlrs(xa,ya,xb,yb)
screen.move(xa,ya)
screen.line_rel(xb,yb)
screen.stroke()
end

function graphics.baseline()
screen.level(1)
graphics.mlrs(6,35,47,0)
end

function graphics.visualizer(i,div)
local a = div * 4
local x1 = (i * 8) + 2
local x2 = ((i * 8) + 1) + 2
screen.level(15)
graphics.mlrs(x1,36,0,a)
graphics.mlrs(x2,36,0,a)
end

return graphics
ProTip! Use n and p to navigate between commits in a pull request.