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

tidal style d1 ... d9 functions + more #805

Merged
merged 6 commits into from Nov 17, 2023
Merged

tidal style d1 ... d9 functions + more #805

merged 6 commits into from Nov 17, 2023

Conversation

felixroos
Copy link
Collaborator

@felixroos felixroos commented Nov 16, 2023

this is an attempt in adding tidal style d1 ... d9 functions + the p function and an additional q function, while still being backwards compatible with the old strudel style of not using any of these functions:

  • pPatterns maps identifiers to patterns
  • before each evaluation, pPatterns is cleared
  • on evaluation, .p(id) sets the calling pattern on pPatterns using the given id as key
  • after evaluation, if at least one key is found in pPatterns, the pattern used for playback is a stack of all pPatterns
  • after evaluation, if pPatterns is empty, the old behavior is used, so the last expression is expected to be a pattern
  • .d1 ... .d9 are just shortcuts for .p(1) ... .p(9)

so for example:

s("bd").d1
s("hh*2").d2

will play both patterns stacked, as pPatterns will be {1: s("bd"), 2: s("hh*2") }.

s("bd").d1
s("hh*2").d1

Here, s("hh*2") will win.

Also, This still works:

s("hh*2")

There is now also the all function:

all(set(gain(.5)))

.. which just takes in a function that is applied to the evaluated pattern at the end.

  • I've also added a shouldHush flag that can be set on the evaluate function.
    If it is true, the evaluation will not clear the pPatterns, meaning you could do block based evaluation (with hidden state).

breaking changes:

There is now also a new top level hush function that will clear pPatterns and return silence (actually the hush function did exist before but it was just the non chained variant of .hush() which is not useful at all i think).

To support .d1 to .d9, i had to remove the transpiler feature that turns note variables into note strings, as it interfered with it. I don't think anyone really uses this feature, as mini notation is just more practical + it can also be confusing when you cannot name your variable after a note name..

@yaxu
Copy link
Member

yaxu commented Nov 17, 2023

Looks great! So 'd' is for dough?

In practice it's nice to be able to disable a pattern quickly, and maybe the quickest way would be to remove the 'd' target. I suppose this wouldn't work if it was the last and only pattern in the file. Maybe that'd be a bit confusing, but probably not too bad.

@jarmitage
Copy link
Contributor

jarmitage commented Nov 17, 2023

I moved from d to p (for pattern) in my setup a while ago for three reasons:

  • 'd' only made sense when targeting SuperDirt, so when using Tidal with anything else (or indeed with >1 OSCTarget at once) it felt incorrect
  • semantically, p as pattern seemed closer to the reality, i.e. it's a pattern that is being sent/streamed to a thing (which might be a SomethingDirt), rather than a "dirt". This is in fact true in that d is an alias for p anyway! Having a different letter for every target also doesn't seem meaningful.
  • "what is d?" is a question that it very often asked by beginners in workshops, and I don't think it has a really satisfying answer beyond explaining some history of the project, which while valuable it kind of gets in the way of learning core concepts

I think having d potentially mean both dough and dirt just makes it more confusing now for beginners.

@felixroos
Copy link
Collaborator Author

felixroos commented Nov 17, 2023

Looks great! So 'd' is for dough?

I guess so, as d in tidal is for dirt ? We could also add p1 .. p9 to be more close to p(1) ... p(9) edit: just read @jarmitage 's answer, and yes I also think pX makes more sense.

In practice it's nice to be able to disable a pattern quickly, and maybe the quickest way would be to remove the 'd' target. I suppose this wouldn't work if it was the last and only pattern in the file. Maybe that'd be a bit confusing, but probably not too bad.

For that reason (and for later code modification reasons) I added q1 .. q9 as well as q(x) which just return silence. so to make a pattern silent, just change the d or p to q, which coincidentally all are made of the same shape :) i wonder what b is for then..

edit: q still has a parameter to remember which output is was supposed to use, so while it makes no sense functionally, it still makes sense as "state in code"

@felixroos
Copy link
Collaborator Author

for d vs p, we could also add both, and use the p variants in all examples and let the d variants be there as compatibility / variant for tidal people who prefer it

@yaxu
Copy link
Member

yaxu commented Nov 17, 2023

Yes I think it shouldn't be a big change from d to p, as that's just a 180 degree turn. Changing from p to q in a performance is easy as well, you can just flip it over.

@felixroos
Copy link
Collaborator Author

``

Yes I think it shouldn't be a big change from d to p, as that's just a 180 degree turn. Changing from p to q in a performance is easy as well, you can just flip it over.

hihi, maybe q will one day be used to send the pattern to the cue output...

@jarmitage
Copy link
Contributor

This is the cue output: d-_-b

@yaxu
Copy link
Member

yaxu commented Nov 17, 2023

Yes that would send to both headphones, c-_-b just to the left one

@felixroos
Copy link
Collaborator Author

q-_-p is now in.. so i guess I'll just add it like it is and block eval / codemod is an experiment for the future based on this

@felixroos felixroos marked this pull request as ready for review November 17, 2023 09:53
@felixroos felixroos merged commit 47a6af2 into main Nov 17, 2023
2 checks passed
@felixroos felixroos deleted the pq-functions branch November 17, 2023 13:37
@yaxu yaxu mentioned this pull request Nov 17, 2023
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.

None yet

3 participants