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

add createParam + createParams #110

Merged
merged 1 commit into from Jun 13, 2022
Merged

add createParam + createParams #110

merged 1 commit into from Jun 13, 2022

Conversation

felixroos
Copy link
Collaborator

as requested by @guillaume-leo, this PR contains the methods createParam + createParams to be able to use custom params, e.g. for osc:

const dudu = createParam('dudu'); // for single params
const { dada, dodo} = createParams('dada', 'dodo'); // multiple params

the param can then be used either to start a pattern, or as a pattern method:

dudu('xxx').dada('yyy').osc(); // {dudu:'hehe', dada: 'yyy'}, osc message ['dudu','hehe','dada','yyy']
dodo('xxx').dudu('yyy').osc(); // {dodo:'hehe', dudu: 'yyy'}, osc message ['dodo','hehe','dudu','yyy']

the param is also patternified by default:

dudu("a [b c]") // {dudu:'a'}, {dudu:'b'}, {dudu:'c'}, 

@felixroos felixroos added the enhancement improves an existing feature label May 5, 2022
@yaxu
Copy link
Member

yaxu commented May 5, 2022

I think this could be useful enough to name them param/params

Also if param is called with > 1 parameter, how about it treats the remaining parameters as a sequence. Allowing:

var dudu = param('dudu'); 

but also:

param('dudu', 3, 4, 2).speed(2) 
param('dudu', "3 4 2").speed(2) 

Also as a pattern method:

note("a3 a4").param('dudu', "3 4 2")

As sometimes you might want to send a one-time-only parameter.

In fact in tidal, this function is just p (although they have to be specialised with a type so pF for floats,, pS for strings etc)

@felixroos
Copy link
Collaborator Author

felixroos commented May 5, 2022

In that case param('dudu') shouldn't add .dudu to Pattern i suppose?

@yaxu
Copy link
Member

yaxu commented May 5, 2022

Hmm. Maybe param('dudu') should but param('dudu', <pattern>) shouldn't?

@yaxu
Copy link
Member

yaxu commented May 5, 2022

and .param('dudu') should be a no-op (or maybe raise an error)

@felixroos
Copy link
Collaborator Author

or just separate param and createParam(s) ?

@yaxu
Copy link
Member

yaxu commented May 5, 2022

Yes could be..

@felixroos
Copy link
Collaborator Author

or maybe it looks cooler to do Pattern.createParam('dududu') . I think most of the time, there will be a hand full of custom patterns used that are created beforehand as a setup step, but still the param(name, ...pats) would be useful for inline usage and or patternified param names

@yaxu
Copy link
Member

yaxu commented May 5, 2022

Hmm I think this is tangentially related to #34 . Being able to stick pF in patterns is particularly useful in tidal due to block based evaluation. When you evaluate everything then there's less cost to having separate statements.

@yaxu
Copy link
Member

yaxu commented May 9, 2022

(I talked in a circle here but happy for you to merge whatever feels right!)

@felixroos
Copy link
Collaborator Author

I'll merge this now, we can add the inline param function in a separate feature

@felixroos felixroos merged commit d10b6f0 into main Jun 13, 2022
@felixroos felixroos deleted the create-param branch June 13, 2022 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improves an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants