Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
emuell committed Dec 19, 2024
1 parent aae0641 commit 9aad44f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/src/API/cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
> })
> --Using a static map table with targets
> cycle("bd:1 <bd:5, bd:7>"):map({
> bd = { key = "c4", volume = 0.5 }, -- instrument #1,5,7 will be set as specified
> -- instrument #1,5,7 will be set as specified
> bd = { key = "c4", volume = 0.5 },
> })
> --Using a dynamic map function
> cycle("4 5 4 <5 [4|6]>"):map(function(context, value)
Expand Down
7 changes: 4 additions & 3 deletions docs/src/API/rhythm.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@
>
> -- stateful generator function
> pattern = function(_init_context)
> local triggers = table.create({0, 6, 10})
> local triggers = table.new{ 0, 6, 10 }
> return function(context)
> return triggers:find((context.step - 1) % 16) ~= nil
> local step = (context.step - 1) % 16
> return triggers:contains(step)
> end
> end
>
Expand Down Expand Up @@ -249,7 +250,7 @@
>
> -- a note pattern
> local tritone = scale("c5", "tritone")
> ...
> .. -- instrument #1,5,7 will be set as specified.
> emit = pattern.from(tritone:chord(1, 4)):euclidean(6) +
> pattern.from(tritone:chord(5, 4)):euclidean(6)
>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/guide/cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ return rhythm {
parameter.enum("mode", "major", {"major", "minor"})
},
emit = cycle("I V III VI"):map(
function(context, value)
local s = scale("c4", context.inputs.mode)
function(init_context, value)
local s = scale("c4", init_context.inputs.mode)
return function(context, value)
return value ~= "_" and s:chord(value) or value
end
Expand Down
18 changes: 9 additions & 9 deletions docs/src/guide/pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,31 @@ Static pattern.
```lua
return rhythm {
pattern = { 1, 0, 0, 1 },
-- ...
emit = "c4"
}
```

*Cram* pulses into a single pulse slot via subdivisions in static patterns.
```lua
return rhythm {
pattern = { 1, { 1, 1, 1 } },
-- ...
emit = "c4"
}
```

Static pattern created using the "pattern" lib
```lua
return rhythm {
pattern = pattern.from{1, 0} * 5 + {1, 1}
-- ...
emit = "c4"
}
```

Euclidean pattern created using the "patterns" lib.
```lua
return rhythm {
pattern = pattern.euclidean(7, 16, 2),
-- ...
emit = "c4"
}
```

Expand All @@ -106,7 +106,7 @@ return rhythm {
pattern = function(_context)
return math.random(0, 1)
end
-- ...
emit = "c4"
}
```

Expand All @@ -115,13 +115,13 @@ Stateful generator.
return rhythm {
pattern = function(_init_context)
local rand = math.randomstate(12345)
local triggers = table.create({0, 6, 10})
local triggers = table.new{ 0, 6, 10 }
return function(context)
return rand() > 0.8 and
triggers:find((context.pulse_step - 1) % 16) ~= nil
local step = (context.pulse_step - 1) % 16
return rand() > 0.8 and triggers:contains(step)
end
end
-- ...
emit = "c4"
}
```

Expand Down
3 changes: 2 additions & 1 deletion types/nerdo/library/cycle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ local Cycle = {}
---})
-----Using a static map table with targets
---cycle("bd:1 <bd:5, bd:7>"):map({
--- bd = { key = "c4", volume = 0.5 }, -- instrument #1,5,7 will be set as specified
--- -- instrument #1,5,7 will be set as specified
--- bd = { key = "c4", volume = 0.5 },
---})
-----Using a dynamic map function
---cycle("4 5 4 <5 [4|6]>"):map(function(context, value)
Expand Down
7 changes: 4 additions & 3 deletions types/nerdo/library/rhythm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ error("Do not try to execute this file. It's just a type definition file.")
---
----- stateful generator function
---pattern = function(_init_context)
--- local triggers = table.create({0, 6, 10})
--- local triggers = table.new{ 0, 6, 10 }
--- return function(context)
--- return triggers:find((context.step - 1) % 16) ~= nil
--- local step = (context.step - 1) % 16
--- return triggers:contains(step)
--- end
---end
---
Expand Down Expand Up @@ -257,7 +258,7 @@ error("Do not try to execute this file. It's just a type definition file.")
---
----- a note pattern
---local tritone = scale("c5", "tritone")
---...
---.. -- instrument #1,5,7 will be set as specified.
---emit = pattern.from(tritone:chord(1, 4)):euclidean(6) +
--- pattern.from(tritone:chord(5, 4)):euclidean(6)
---
Expand Down

0 comments on commit 9aad44f

Please sign in to comment.