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

onSubCycle function for "step sequencer" style rhythm notation #1237

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

daslyfe
Copy link
Collaborator

@daslyfe daslyfe commented Jan 3, 2025

I meant to put up a PR for this last year after we discussed it, but we could not figure out how to name the function. I thought of a good name today so here is the pr :)
Example: https://strudel.cc/?A3sRLsdfgjhP

@daslyfe daslyfe requested review from yaxu and felixroos January 3, 2025 03:37
@yaxu
Copy link
Member

yaxu commented Jan 8, 2025

Version from discord discussion:

const beat = register(['beat'], (t, pat) => {
  let div = 16;
  if (Array.isArray(t)) {
    if (t.length > 1) {
      div = t[1];
    }
    t = t[0];
  }
  t = Fraction(t).mod(div);
  div = Fraction(div);
  const b = t.div(div);
  const e = t.add(1).div(div);
  return pat.fmap(x => pure(x)._compress(b,e)).squeezeJoin();
 }
)

@yaxu
Copy link
Member

yaxu commented Jan 12, 2025

Following more discussion on discord:

const __beat = join => (t, div, pat) => {
  t = Fraction(t).mod(div);
  div = Fraction(div);
  const b = t.div(div);
  const e = t.add(1).div(div);
  return join(pat.fmap(x => pure(x)._compress(b,e)));
}

const {beat, beatOut} = register(['beat', 'beatOut'], __beat(x => x.innerJoin()));
const {beatIn} = register(['beatIn'], __beat(x => x.outerJoin()));
const {beatSqueeze, bsq} = register(['beatSqueeze', 'bsq'], __beat(x => x.squeezeJoin()));

s("bd:4 sd").bsq("0,<1 1 2>,3,5,8,<12 11>","16")

Maybe we can use a proxy object to make beat.squeeze etc possible.

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

Successfully merging this pull request may close these issues.

2 participants