Skip to content

new reflection feature: loop duration multiplier #1805

@jaseknighter

Description

@jaseknighter

kinda similar to the existing double function in the reflection lib, there could be a function that increases or decreases the duration by a set amount, like:

--- changes the duration of the current loop
function reflection:mult(mul)
  local copy = deep_copy(self.event)
  local event_new = {}
  for i = 1, self.endpoint do
    event_new[math.ceil(i*mul)] = copy[i]
  end
  self.event = event_new
  self.endpoint = math.ceil(self.endpoint * mul)
end

for reference, here's a copy of the existing double function:

--- doubles the current loop
function reflection:double()
  local copy = deep_copy(self.event)
  for i = 1, self.endpoint do
    self.event[self.endpoint + i] = copy[i]
  end
  self.endpoint = self.endpoint * 2
end

i'd be happy to submit a pull request if there's agreement this would be useful in the lib.

edit: one issue with the suggested approach would be if the length were decreased, data from the original reflection could get munged and lost, so maybe more thought would need to go into the enhancement. a better approach could be to keep a copy of the original event table and always perform the mult on this table and not simply replace it with a new table. (note: a similar approach is used for overdubbing with the event_prev table.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions