-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update examples to use math.randomstate
- Loading branch information
Showing
1 changed file
with
19 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |