Skip to content

Commit

Permalink
update examples to use math.randomstate
Browse files Browse the repository at this point in the history
  • Loading branch information
emuell committed Jul 6, 2024
1 parent 1fccc33 commit 7d4fbe1
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions examples/assets/hihat.lua
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
math.randomseed(0x12345)

return rhythm {
unit = "1/8",
pattern = function(context)
if math.imod(context.pulse_step, 8) == 1 then
return { 0.8, 0.2, 0.9, 0.2 }
else
if math.random() > 0.9 then
return { 0.8, 0.9 }
else
return { 1 }
local rand = math.randomstate(0x12345)
return function(context)
if math.imod(context.pulse_step, 8) == 1 then
return { 0.8, 0.2, 0.9, 0.2 }
else
if rand() > 0.9 then
return { 0.8, 0.9 }
else
return { 1 }
end
end
end
end,
emit = function(context)
local note = "c6"
local _, fraction = math.modf(context.pulse_time_step)
if fraction == 1.0/2.0 then
note = "c5 v0.3"
local rand = math.randomstate(0x8879)
return function(context)
local note = rand(1, 10) >= 8 and "c6" or "c7"
local _, fraction = math.modf(context.pulse_time_step)
if fraction == 1.0 / 2.0 then
note = "c5 v0.3"
end
return note
end
return note
end
}
}

0 comments on commit 7d4fbe1

Please sign in to comment.