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

Make cps patternable #1001

Merged
merged 8 commits into from
Nov 30, 2024
Merged

Make cps patternable #1001

merged 8 commits into from
Nov 30, 2024

Conversation

eefano
Copy link
Contributor

@eefano eefano commented Mar 19, 2024

Little hack, you can change the global inner clock with the cps() control function. Very dangerous but very satisfying. You can bring the cps to 0 and stop the playback, also. Negative numbers work in theory (the pianoroll goes in reverse) but no correct audio is produced.

Practical example:

https://youtu.be/No1dQWJKQNU

@felixroos
Copy link
Collaborator

felixroos commented Mar 22, 2024

I don't think this is a hack.. this partly fixes #51

You could also use this like s("bd hh").cps(saw.slow(4).range(.1,1)) which looks less hacky.
To make this complete, I'd say 2 things are missing:

  • the .cpm function needs to use .cps internally, so patterning .cpm also behaves like expected
  • setcps and friends also need to work with a pattern

When #1004 is merged, this one probably needs to be updated to use this.setCps..

@yaxu
Copy link
Member

yaxu commented Mar 22, 2024

Yes tidal has this functionality too.

Based on my experience with tidal, there could be problems when the cps changes part way through a frame. This can result in events getting doubled up or missed.

@yaxu
Copy link
Member

yaxu commented Nov 15, 2024

Ok to merge this for now and improve with later PR(s)?

@yaxu
Copy link
Member

yaxu commented Nov 15, 2024

I posted a summary of the situation here: #51 (comment)

@@ -52,6 +52,10 @@ export class Cyclist {
// see https://github.com/tidalcycles/strudel/pull/1004
const deadline = targetTime - phase;
onTrigger?.(hap, deadline, duration, this.cps, targetTime);
if (hap.value.cps !== undefined && this.cps != hap.value.cps) {
this.cps = hap.value.cps;
this.num_ticks_since_cps_change = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this shouldn't be 0 as we're partway through a tick. Perhaps somewhere between -1 and 0 ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an integer counter... the tick is the smallest unit of handled time. In a tick you feed a fixed-size audio buffer. You could go down to the single sample but i think performance could be killed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure but to handle smooth cps changes then we would need sub-tick precision. I think this is an issue for solving in a later PR though.

@yaxu yaxu changed the title Cps hack Make cps patternable Nov 30, 2024
@yaxu yaxu merged commit 0531369 into tidalcycles:main Nov 30, 2024
1 check passed
@yaxu
Copy link
Member

yaxu commented Nov 30, 2024

Ok merged, thanks!

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.

3 participants