emuell / afseq

GNU Affero General Public License v3.0
1 stars 1 forks source link

Delay in cycle #29

Closed unlessgames closed 6 hours ago

unlessgames commented 1 week ago

I'd like to add a feature to the cycle to express sub-step delays.

In tidal you can combine patterns with different delaying functions to achieve swing and so on but since here there is only one pattern that determines the final events, this isn't easy to do. Hence I propose an additional operator that could delay any step inside it's own span.

Currently delays can be achieved by enclosing the step in a subdivision and prepending rests like [~~ a] b which is alright but a bit verbose and restrictive.

So instead it could be for example a\0.25 b that would be equivalent to [~ a _ _ ] b and so on. Maybe it could even be just a.25 but that might be a bit ambiguous.

It should be fairly easy to apply this when outputting events.

emuell commented 1 week ago

cycle("a+0.5 b c") or cycle("a+1/2 b c")


Right now delaying also is possible via map:

local delays = { 0, 1/32, 0, 1/32 }

---@param context CycleMapContext
---@param value NoteValue
local function apply_delay(context, value)
  local delay = delays[math.imod(context.step, #delays)]
  return note(value):with_delay(delay)
end

return rhythm {
  unit = "1/1",
  emit = cycle("c d# g a#"):map(apply_delay)
}
emuell commented 6 days ago

The more generalized version of the delay mapping is now here:

https://github.com/emuell/afseq/blob/feature/cycle-mappings/types/nerdo/library/mappings.lua#L95

return rhythm {
  unit = "1/1",
  emit = cycle("c d# g a#"):map(mappings.with_delay{ 0, 1/32, 0, 1/64 })
}
emuell commented 6 hours ago

Let's continue that in https://github.com/emuell/afseq/issues/29 and https://github.com/emuell/afseq/issues/13