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

New tools for long-form compositions: setLoop() and cyclecounter() #1139

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

Conversation

eefano
Copy link
Contributor

@eefano eefano commented Jul 3, 2024

setLoop(start, length)
alters the core behaviour of Cyclist (like setCps does): playback is always started at the cycle number 'start' (default=0). When a 'length' number of cycles have elapsed, the cycles counter is reset to 'start'. The parameters are floored (decimal part of the number is ignored). When 'length' is zero (default) the playback is not looped.
Evaluating setLoop() without parameters restores the original behaviour.

cyclecounter()
this widget displays the integer part of 'time' value (that is, the current cycle number) in the bottom-right part of the screen. Optional parameters allow the customization of font and color. The 'div' option divides the counter value by a constant. For example: when all measures are 4/4 and 1beat=1cycle, it can be useful to count the measure number by passing {div: 4}

The actual implementation is not very precise at the edges and the visual feedback is janky (I'm hoping for your help in this regard), but it's still very useful for fast-iterating a middle part of a long composition, without altering the overall structure every time.

Example, this plays C D E in loop:

setCps(120/60)
setLoop(2,3)
note("<a4 b4 c4 d4 e4 f4 g4>").cyclecounter()

Ode to Joy, but only the 3rd and 4th measure (the counter displays Cycles/4):

setCps(120/60)
setLoop(2*4, 2*4)
note("<e4!2 f4 g4!2 f4 e4 d4 c4!2 d4 e4 [e4@3 d4]@2 d4@2>").cyclecounter({div:4})

Let me know what do you think ... thank you as always!

eefano added 2 commits July 3, 2024 11:21
Adds setLoop(start, length) and cyclecounter() widget.
@felixroos
Copy link
Collaborator

As said earlier in discord, ribbon can be used to get the behavior of setLoop:

all(x=>x.ribbon(2,3))

I still like the idea of having a helper function like setLoop that is simpler to write, but I'd rather not implement it in the cyclist to avoid too much complexity.

The problem rn is that all can only be used once, so if we add helper functions that uses all under the hood, it might happen that it gets overridden, e.g.:

all(x=>x.hpf(1000))
setLoop(2,3) // <-- overwrites line above

To fix that, we could implement all in a way that it adds a transformation each time it is called. rn it looks like this:

let allTransforms = [];
const all = function (transform) {
    allTransforms.push(transform)
    return silence;
  };
// later:
if (allTransforms.length) {
  for(let i in allTransforms) {
    pattern = allTransforms[i](pattern);
  } 
}

That would allow defining setLoop as

let setLoop = (a,b) => all(x=>x.ribbon(a,b))

I like the idea of cyclecounter, but maybe it could be part of the DOM instead? Also seems like this should be 2 PRs.
What do you think @eefano ?

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