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

Patternable tempo changes via cps #51

Open
yaxu opened this issue Apr 12, 2022 · 16 comments · Fixed by #181
Open

Patternable tempo changes via cps #51

yaxu opened this issue Apr 12, 2022 · 16 comments · Fixed by #181
Labels
compatibility Mainline Tidal Compatibility

Comments

@yaxu
Copy link
Member

yaxu commented Apr 12, 2022

There is cpm in core but it assumes a scheduler running at 1 cps.

It would be great if cps could be patternable, e.g.

cps(saw.range(0.9,1.8).slow(16))

or

sound("bd [bd bd]").cps(1,1.5)
@felixroos
Copy link
Collaborator

I wonder if the assumption of 1 cycle / second has any disadvantage? If not, we could implement cps like cpm

@yaxu
Copy link
Member Author

yaxu commented Apr 18, 2022

Hm, I think having a global cycle rate that can be changed is pretty important. Personally I don't really like 1cps, the default in tidal is 0.5625.

@felixroos
Copy link
Collaborator

But anything against implementing it with slow, assuming a hard coded cps? I kind of like 1s because it's normalized

@yaxu
Copy link
Member Author

yaxu commented Apr 18, 2022

slow doesn't hold state, so slow (saw.segment(8).range(1,2)) would miss a lot of events.

With something like: "a b".cps(1.5).every(3,rev)

The rev would not work on cycle boundaries.

More generally, when it comes to syncing between systems, it would be difficult to do that without a global clock.

@felixroos
Copy link
Collaborator

makes sense. so we need a global clock that dictates how fast the scheduler will run. also thought syncing would be great. .cps would then have a side effect to talk to the scheduler.

@felixroos felixroos added the compatibility Mainline Tidal Compatibility label Apr 24, 2022
@yaxu
Copy link
Member Author

yaxu commented May 8, 2022

SuperDirt likes to have some metadata - the current cps, the duration (as delta) of the event in seconds, and the event onset (wholeorpart.begin) in cycles (as cycle). So it could be good for the scheduler to provide this info (or a way to get it) to the callback.

@felixroos
Copy link
Collaborator

felixroos commented Aug 11, 2022

i made some improvements to the scheduler + sketched cps option DEMO

I am not sure if the behavior is right when I change the tempo: when pressing minus, the scheduling might repeat notes, if pressing plus, the scheduler might jump over notes. it feels like the scheduler has to use a time phase? is this how tidal does it too? this is the code: https://github.com/tidalcycles/strudel/blob/ea1ffca4ae430cc64a0be08dfc062204021c351a/packages/webaudio/scheduler.mjs

@felixroos
Copy link
Collaborator

felixroos commented Aug 12, 2022

tempo changes are now working smoothly (the above link will still show the old behavior). Updated demo

Interestingly, the implementation is quite similar to a digital oscillator, which also requires keeping the phase in state to avoid phase jumps / cracks when repitching: https://github.com/tidalcycles/strudel/blob/optimize-scheduler/packages/webaudio/scheduler.mjs#L17

The next step is changing cps from a hap. I think it will only be possible to change the cps once per slice (in the above example it's 10Hz)

@felixroos
Copy link
Collaborator

The next step is changing cps from a hap. I think it will only be possible to change the cps once per slice (in the above example it's 10Hz)

That's also working now not sure if this is similar how it works in tidal though

@yaxu
Copy link
Member Author

yaxu commented Feb 21, 2023

This got lost along the way..

@yaxu yaxu reopened this Feb 21, 2023
@felixroos
Copy link
Collaborator

moved from #494:

global clock #470 is now implemented in #493 . example: https://strudel.tidalcycles.org/?9xvgxvOjkBR1

now the next step is making it work with patterns

@yaxu
Copy link
Member Author

yaxu commented Mar 1, 2023

Good stuff. FWIW I needed to do a hard refresh for that to work.

@felixroos
Copy link
Collaborator

felixroos commented Mar 1, 2023

Good stuff. FWIW I needed to do a hard refresh for that to work.

sometimes the old version may be stuck in the cache.. ideally, the pwa service worker will update itself and reload the page when it's ready

@jarmitage
Copy link
Contributor

small request: once this is fixed, if possible find a way to make a separate function that does what the current behaviour does, because it's quite cool!

@yaxu
Copy link
Member Author

yaxu commented Nov 21, 2023

I noticed that passing a pattern to setcps("0.6") stops all sound and needs a hard refresh. No errors/warnings are printed to console.

@felixroos felixroos mentioned this issue Mar 22, 2024
@yaxu
Copy link
Member Author

yaxu commented Nov 15, 2024

In summary, the following needs to happen:

  • Update cps at scheduler time in cyclist Cps hack #1001
  • Update .cpm(), setcps() etc to work as well
  • Consider what happens to the query window
    • cps goes faster - either drop remaining haps now outside the window, or increase cyclist's lastEnd
    • cps goes slower - either perform extra query to extend the window, or reduce cyclist's lastEnd
    • probably adjusting lastEnd is better, especially to avoid possibility of an infinite query if cps keeps getting slower (xeno's paradox ??)
  • Might well be best to start using rationals for cps everywhere..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Mainline Tidal Compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants