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

Represent a [VarList]? Convert a Map String Float to a VarList? #6

Open
JeffreyBenjaminBrown opened this issue Aug 2, 2020 · 1 comment

Comments

@JeffreyBenjaminBrown
Copy link

In Montevideo I'm using maps from string to float to represent messages. This lets me represent arbitrary sequences of SuperCollider events, something I was unable to do using tuples because GHC is picky about their types.

But Vivid's set expects a VarList, which is a family of tuples:

set :: (Subset (InnerVars params) sdArgs, VividAction m,
    VarList params) =>
    Synth sdArgs -> params -> m ()

Currently my hack has been to extract a separate tuple for each key-value pair in the Map String Float, and set that tuple. But since the sequences I generate can be pretty complicated, that leads me to unbundle gobs of messages that really ought to be sent together.

The only solution I'm aware of would be to hard-code how to respond to every possible set of message keys. I'm using a synth with more than 33 parameters, so that would mean 2^30 = more than a billion definitions. I'm not even sure that would compile.

Can this be worked around?

@JeffreyBenjaminBrown JeffreyBenjaminBrown changed the title convert a Map String Float to a VarList Represent a [VarList]? Convert a Map String Float to a VarList? Aug 2, 2020
@JeffreyBenjaminBrown
Copy link
Author

Maybe I can broaden the audience of this issue by noting that it's hard in Vivid even to represent a list of VarLists.

It turns out to be possible -- somehow, a year or two ago, I came up with the following:

data ScMsg' sdArgs where
  ScMsg' :: forall params sdArgs.
          ( Vivid.VarList params
          , Vivid.Subset (Vivid.InnerVars params) sdArgs)
       => params -> ScMsg' sdArgs

But that has the disadvantage that each ScMsg has "forgotten" its type. They can be used to set' a synth, but they cannot be analyzed, say, to convert a pattern in one parameter to a pattern in another.

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

No branches or pull requests

1 participant