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

pickOut(), pickRestart(), pickReset() #950

Merged
merged 14 commits into from
Feb 29, 2024

Conversation

eefano
Copy link
Contributor

@eefano eefano commented Feb 18, 2024

added pickr() and pickrmod() , see #948

also fixed typos in inhabit() and inhabitmod()

added pickr() and pickrmod()
prettier fix
Fixed pickr() description
@yaxu
Copy link
Member

yaxu commented Feb 18, 2024

The use of collect and restart here is cunning but I think will limit patterning possibilities. It'd be simpler and more flexible to use a trigZeroJoin. I think this might well involve changes to register to support, which currently has an innerJoin. Maybe this just needs a pick but with a trigZeroJoin

I'd say use of reset (trig) should be privileged over restart (trigZero), as the former is more 'patterny', although we can offer both as an option.

Maybe a nice solution would be to define pick as an operator, then all the different join variants would be automatically created, with aliases added if necessarily. Actually .reset is an alias for .keepif.trig. So pickReset could be an alias for .pick.trig then.

Make pickr() handle dictionaries also
@eefano
Copy link
Contributor Author

eefano commented Feb 18, 2024

With my implementation of pickr() i can do something like that:
"<[0,2] 1@2>".pickr(["a", "<b c>", "d"]).note()

And the result is equivalent to this looped indefinitely:
"[a,d] b c"

When you use pick() , you have this loop instead:
"[a,d] c b [a,d] b c"

  • I'm using restart() because with reset() it doesn't work.
  • I'm using collect() because [0,2] restarts both patterns twice, causing the output to double (in haps and volume).
  • I'm incrementing by one the values because restart("0") does nothing

Now, assuming your API suggestions are implemented, can you please show me a strudel example that makes my use case work correctly?

@yaxu
Copy link
Member

yaxu commented Feb 18, 2024

Hmm unfortunately defining pick as an operator doesn't really work as operators are defined to work on pairs of values, not patterns.

@yaxu
Copy link
Member

yaxu commented Feb 18, 2024

Now, assuming your API suggestions are implemented, can you please show me a strudel example that makes my use case work correctly?

Howabout this?

https://strudel.cc/?leVkB6geMrE_

These are the same as inhabit but with different joins (_pick is pasted in because it's not exported from signal.mjs)

Maybe it's clear from this how reset is more patterny..

using trigZeroJoin in pickr() instead
now pickRestart() and pickReset()
@eefano eefano changed the title added pickr() and pickrmod() added pickRestart(), pickReset(), pickmodRestart(), pickmodReset() Feb 18, 2024
@eefano eefano changed the title added pickRestart(), pickReset(), pickmodRestart(), pickmodReset() pickRestart(), pickReset(), pickmodRestart(), pickmodReset() Feb 18, 2024
@eefano
Copy link
Contributor Author

eefano commented Feb 18, 2024

Your approach is cleaner, for sure!
But pickReset still doesn't work as I'd like. The equivalent output is:
"[a,d] c b [a,d] b c"

pickRestart works as intended.

I'm keeping both in the PR.

@eefano eefano changed the title pickRestart(), pickReset(), pickmodRestart(), pickmodReset() pickOuter(), pickRestart(), pickReset() Feb 25, 2024
@eefano
Copy link
Contributor Author

eefano commented Feb 25, 2024

I have added also pickOuter() , applying an outer join can achieve something useful like that:

"<0 1>/9".pickRestart(
  ["<rd*3 , <[[bd ~ bd] [~ ~ bd]]!3@2 [bd ~ bd] [~ bd bd]!2> , <[~ sd]!3@2 ~ sd!2> , cr/9>"
  ,"<rd*2 , <[[bd ~ bd] [bd ~ ~]]!3@2 [bd ~ bd] [~ bd bd]!2> , <[sd sd]!3@2 ~ sd!2> , cr/9>" 
  ]).pickOuter({
             rd:s('rd').gain(0.1).pan(0.4),
             bd:s('bd').gain(0.5),
             sd:s('sd').gain(0.5),
             cr:s('cr').gain(0.1).pan(0.6)}).bank("Linn9000").velocity(0.5)

@felixroos
Copy link
Collaborator

these functions look very useful! maybe it makes sense to add pickSqueeze / pickmodSqueeze as synonyms for inhabit / inhabitmod to make the naming more consistent?

I also wonder if it would make sense to change the syntax from pickX to pick.x, e.g.:

"a b".pick.trig({...})
// instead of
"a b".pickReset({...})

this would follow the same convention as operators e.g.

"0 1".add.trig("0 1 2 3")

overview:

now then
pick pick, pick.in
pickOuter pick.out
pickRestart pick.trigzero
pickReset pick.trig
inhabit inhabit, pick.squeeze

I've omitted all the mod variants, because they are the same

not sure if it makes sense to add all operators, probably not

@eefano
Copy link
Contributor Author

eefano commented Feb 25, 2024

Pragmatically speaking, can this PR be merged as is by now ? I can work on a structured patch in the future.

@daslyfe
Copy link
Collaborator

daslyfe commented Feb 25, 2024

these functions look very useful! maybe it makes sense to add pickSqueeze / pickmodSqueeze as synonyms for inhabit / inhabitmod to make the naming more consistent?

I also wonder if it would make sense to change the syntax from pickX to pick.x, e.g.:

"a b".pick.trig({...})
// instead of
"a b".pickReset({...})

this would follow the same convention as operators e.g.

"0 1".add.trig("0 1 2 3")

overview:

now then
pick pick, pick.in
pickOuter pick.out
pickRestart pick.trigzero
pickReset pick.trig
inhabit inhabit, pick.squeeze
I've omitted all the mod variants, because they are the same

not sure if it makes sense to add all operators, probably not

I like this approach it seems a lot more flexible

@yaxu
Copy link
Member

yaxu commented Feb 25, 2024

Maybe we should standardise on the friendlier reset and restart rather than trig and trigZero?

Yes pick.x would be nice, as would moving towards supporting this in general, across all patterning function parameters. Tricky for functions with higher arity though..

prettier

prettier2

clamp?

Revert "clamp?"

This reverts commit 83a3b91.

Revert "prettier2"

This reverts commit de13871.

Revert "prettier"

This reverts commit 1550bf4.

Revert "mux operator, muxers.mjs with pick variants"

This reverts commit af062f9.
@eefano
Copy link
Contributor Author

eefano commented Feb 26, 2024

I tried to introduce the mux operator but tests don't pass, so i reverted. At the moment I'm not knowledgeable enough to provide a better solution. I hope you'll integrate pickOuter, pickReset, pickRestart soon. A better solution can be thought out in the future.

@felixroos felixroos mentioned this pull request Feb 29, 2024
@felixroos
Copy link
Collaborator

Maybe we should standardise on the friendlier reset and restart rather than trig and trigZero?

Yes pick.x would be nice, as would moving towards supporting this in general, across all patterning function parameters. Tricky for functions with higher arity though..

now tracking this here: #970

+ add pick*Squeeze alias to inhabit*
@felixroos felixroos changed the title pickOuter(), pickRestart(), pickReset() pickOut(), pickRestart(), pickReset() Feb 29, 2024
@felixroos
Copy link
Collaborator

I've renamed pickOuter to pickOut for consistency with the alignment operators. I'd merge this now, but maybe we'll get the dot notation with #970

@felixroos
Copy link
Collaborator

For now I'd consider these functions experimental, as they might get renamed later

@felixroos felixroos merged commit 6a43eb6 into tidalcycles:main Feb 29, 2024
1 check passed
@felixroos
Copy link
Collaborator

and thanks @eefano :)

@eefano eefano deleted the pickr-pickrmod branch February 29, 2024 15:45
@eefano
Copy link
Contributor Author

eefano commented Feb 29, 2024

thank you Felix, this is very useful!

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.

4 participants