Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warp function #1143

Open
yaxu opened this issue Jul 23, 2024 · 0 comments
Open

Add warp function #1143

yaxu opened this issue Jul 23, 2024 · 0 comments

Comments

@yaxu
Copy link
Member

yaxu commented Jul 23, 2024

From discussion here: https://discord.com/channels/779427371270275082/937365093082079272/1086643898652311582

Pattern.prototype.enumerate = function () {
  const pat = this.sortHapsByPart()
  return new Pattern(state => {
    const haps = pat.query(state.withSpan(span => span.begin.wholeCycle()))
    const chunks = haps.length
    return haps.map((hap, i) => new Hap(hap.whole, hap.part.intersection(state.span), [hap.value, i, chunks])
                  ).filter(hap => hap.part != undefined)
  }).splitQueries()
}

Pattern.prototype.warp = function (tpat) {
  const pat = this;
  return tpat.enumerate().withValue(v => pat.zoom(Fraction(v[1]).div(v[2]), 
                                                  Fraction(v[1]).add(1).div(v[2]))
                                  ).outerJoin()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant