Hi! I'm trying to retrieve a Pattern from a ControlPattern or ControlMap function, so that I can use it somewhere else, but I'm a bit lost.
-- Example 1
let var = mI "var"
in d1
$ s "bd*4"
# var "1 2 3 4"
# up (pI "var" 0)
-- Example 2
let myshift = mF "myshift"
in d1
$ note ("0 4 7 12" |+ (pF "myshift"))
# s "superpiano"
# myshift "1 2 3 4"
I went through @bgold's boot.tidal as reference, but I don't understand how to properly use pF, mF, pI, mI and query or what are their limitations and alternatives to acheive this. Is there a way to do this?
import qualified Data.Map as M
:set +t
cpat = s "superpiano" >| n "[e d f g]"
cpat :: Pattern ControlMap
maybe 0 fvalue <$> M.lookup "n" <$> cpat
(0>¼)|4.0
(¼>½)|2.0
(½>¾)|5.0
(¾>1)|7.0
it :: Pattern Double
functions used:
pF :: String -> Pattern Double -> ControlPattern
-- Defined in ‘Sound.Tidal.Params’
data Value = ... | VF {fvalue :: Double} | ...
-- Defined in ‘Sound.Tidal.Pattern’
M.lookup :: Ord k => k -> M.Map k a -> Maybe a
-- Defined in ‘Data.Map.Internal’
maybe :: b -> (a -> b) -> Maybe a -> b -- Defined in ‘Data.Maybe’
(<$>) :: Functor f => (a -> b) -> f a -> f b
-- Defined in ‘Data.Functor’
Took me a while to understand what this code is doing (my haskell is not too good)
Thanks a lot for putting this together, it's been super helpful already