The approach I'd use might be a little different. Vivid offers a "toI" function which takes any number and converts it to an "I".
So for example:
```
myNums = [1..10] :: [Double]
sd0 = undefined :: SynthDef '["freq"]
sd1 = undefined :: SynthDef '["amp"]
main = do
s0 <- synth sd0
s1 <- synth sd1
forM_ myNums $ \n -> do
set s0 (toI n :: I "freq")
set s1 (toI n :: I "amp")
```
Also: "toI" works on any numeric type (any "Real n"), and "I" itself is a numeric type. So you can always write:
x = 5 :: I "freq"
y = toI x :: I "amp"
Tom
> El 4 jul 2018, a las 08:30, Jeffrey Brown <jeffbrown.the_at_gmail.com> escribió:
>
> Composers reuse melodic material across different instruments. I would like to do that in Vivid. I would keep a sequence of values and send it sometimes to one parameter of one synth, sometimes to a different parameter of a different synth.
>
> To do that I would have to coerce those numbers to values of type `I a`, where the string `a` is known only at runtime. I tried to write a function to do that:
>
> import GHC.TypeLits
> toIOf :: (Real n, GHC.TypeLits.KnownSymbol a) => String -> n -> I a
> toIOf "freq" n = toI n :: I "freq"
> toIOf "amp" n = toI n :: I "amp"
>
> but it won't compile, because the outputs of `toIOf "freq"` and `toIOf "amp"` have different types.
>
> Is this possible?
>
> --
> Jeff Brown | Jeffrey Benjamin Brown
> Website | Facebook | LinkedIn(spammy, so I often miss messages here) | Github
> _______________________________________________
> Livecode mailing list -- livecode_at_we.lurk.org
> To unsubscribe send an email to livecode-leave_at_we.lurk.org
_______________________________________________
Livecode mailing list -- livecode_at_we.lurk.org
To unsubscribe send an email to livecode-leave_at_we.lurk.org
Received on Wed Jul 04 2018 - 16:50:47 BST