Skip to content

Instantly share code, notes, and snippets.

@justmat
Last active April 11, 2021 14:14
Show Gist options
  • Save justmat/71aed57d468228153ed1bc2537853f32 to your computer and use it in GitHub Desktop.
Save justmat/71aed57d468228153ed1bc2537853f32 to your computer and use it in GitHub Desktop.
play melodies on JF with crow
-- just crow
--
-- clock in 1 for straight arps
-- clock in 2 for euclidean patterns
-- clock both, because you can and it sounds cool
--
dominant7th = {0, 4, 7, 10, 12, 16, 19, 22, 24}
-- ER parameters for each channel.
lengths = {7,28}
fills = {2,12}
offsets = {0,2}
locations = {-1,-1}
function er(k,n,s)
local r = {}
for i = 1,n do
r[i] = {i <= k}
end
local function cat(i,k)
for _,v in ipairs(r[k]) do
r[i][#r[i]+1] = v
end
r[k] = nil
end
while #r > k do
for i = 1,math.min(k, #r-k) do
cat(i, #r)
end
end
while #r > 1 do
cat(#r-1, #r)
end
return r[1][s+1]
end
input[1].change = function(state)
local note = dominant7th[math.random(#dominant7th)]
-- pluck w/delay
ii.jf.play_note(note/12, 8)
-- send cv/gate
output[1].volts = n2v(note)
output[2](pulse(0.1, 3))
end
input[2].change = function(state)
for i = 1, 2 do
local note = dominant7th[math.random(#dominant7th)]
local note2 = dominant7th[math.random(#dominant7th)]
--- increment counters
locations[i] = ((locations[i]+1) % lengths[i])
-- get current location
local index = ((locations[i]+offsets[i]) % lengths[i])
-- note 1 goes to jf
-- note 2 is a cv/gate pair
if er(fills[i],lengths[i],index) then
if i == 1 then
ii.jf.play_note(note/12, 8)
else
output[1].volts = n2v(note2)
output[2](pulse(0.1, 3))
end
end
end
end
function init()
input[1].mode('change', 1, 0.1, 'rising')
input[2].mode('change', 1, 0.1, 'rising')
print("remember to send ii.jf.mode(1) from druid!")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment