zwirn-0.2.3.1: src/zwirn-lang/Zwirn/Language/Builtin/DouxParameters.hs
module Zwirn.Language.Builtin.DouxParameters where
import qualified Data.Map as Map
import Data.Text (Text)
import qualified Data.Text as T
import Zwirn.Core.Lib.Map
import Zwirn.Core.Lib.State (cycleToSecond)
import Zwirn.Language.Builtin.Internal
import qualified Zwirn.Language.Builtin.Parameters as P
import Zwirn.Language.Environment
import Zwirn.Language.Evaluate (Expression, ExpressionMap, Zwirn, toExp)
import Zwirn.Language.Evaluate.Expression (Expression (..))
builtinParams :: Map.Map Text AnnotatedExpression
builtinParams = Map.unions [builtinTextParams, builtinNumberParams, builtinSecondParams, builtinSources, orbitGlobalFX, noteExpressions, chordExpressions]
noteExpressions :: Map.Map Text AnnotatedExpression
noteExpressions = Map.unions $ map (\n -> noDesc $ n === toExp ((pure $ P.toNote n + 60) :: Zwirn Int) <:: "Number") P.notes
chordExpressions :: Map.Map Text AnnotatedExpression
chordExpressions = P.chordExpressions
builtinTextParams :: Map.Map Text AnnotatedExpression
builtinTextParams = Map.unions $ map (\(name, range, d) -> name === toExp ((fmap toExp . singleton (pure name)) :: Zwirn Expression -> Zwirn Expression) <:: "Text -> Map" --| ((if T.null range then "" else "range: " <> range) <> if T.null d then "" else "\ndefault: " <> d)) textParams
builtinSources :: Map.Map Text AnnotatedExpression
builtinSources = Map.unions $ exceptions : map (\name -> noDesc $ name === EZwirn (pure (EMap $ Map.singleton "s" (EText name))) <:: "Map") sources
builtinNumberParams :: Map.Map Text AnnotatedExpression
builtinNumberParams = Map.unions $ map (\(name, range, d) -> name === toExp ((fmap toExp . singleton (pure name)) :: Zwirn Double -> Zwirn Expression) <:: "Number -> Map" --| ((if T.null range then "" else "range: " <> range) <> if T.null d then "" else "\ndefault: " <> d)) numberParams
builtinSecondParams :: Map.Map Text AnnotatedExpression
builtinSecondParams = Map.unions $ map (\(name, range, d) -> name === toExp ((fmap toExp . singleton (pure name) . cycleToSecond) :: Zwirn Double -> Zwirn Expression) <:: "Number -> Map" --| ((if T.null range then "" else "range: " <> range) <> if T.null d then "" else "\ndefault: " <> d)) secondParams
exceptions :: Map.Map Text AnnotatedExpression
exceptions =
Map.unions
[ noDesc $ "sinus" === EZwirn (pure (EMap $ Map.singleton "s" (EText "sine"))) <:: "Map",
noDesc $ "triangle" === EZwirn (pure (EMap $ Map.singleton "s" (EText "tri"))) <:: "Map",
noDesc $ "sawtooth" === EZwirn (pure (EMap $ Map.singleton "s" (EText "saw"))) <:: "Map"
]
sources :: [Text]
sources =
["zaw", "pulse", "pulze", "white", "pink", "brown", "vosc", "pluck"]
++ ["kick", "snare", "hat", "tom", "rim", "cowbell", "cymbal", "plate", "clap"]
++ ["plmodal", "plva", "plws", "plfm", "plgrain", "pladd", "plwt", "plchord", "plswarm", "plnoise"]
++ ["live"]
++ ["vox"]
textParams :: [(Text, Text, Text)]
textParams =
[ ("s", "source", ""),
("sound", "source", ""),
("bank", "", ""),
("subwave", "tri | sine | square", ""),
("syncmode", "hard | soft", ""),
("vibshape", "sine | tri | saw | square | sh", "sine"),
("fmshape", "sine | tri | saw | square | sh", "sine"),
("amshape", "sine | tri | saw | square | sh", "sine"),
("rmshape", "sine | tri | saw | square | sh", "sine"),
("flangermode", "classic | throughzero", "classic"),
("chorusmode", "classic | ensemble | dimension", "classic"),
("delaytype", "standard | pingpong | tape | multitap", "standard"),
("verbtype", "space | plate", "space"),
("foldmode", "triangle | sine | wrap", "triangle"),
("distortmode", "soft | tanh | arctan | hardclip | parabolic | sinarctan", "soft"),
("vinyltype", "dull | clear | cassette", "dull")
]
numberParams :: [(Text, Text, Text)]
numberParams =
[("shape", "0-1", "0.5"), ("punch", "0-1", "0.5"), ("grit", "0-1", "0.5"), ("drumkit", "0-7", "0")]
++ [("inchan", ">=0", "0")]
++ [("scan", "0-1", "0"), ("wtlen", ">=0", "0")]
++ [("tense", "0-1", "0.6"), ("tonguex", "0-1", "0.06"), ("tonguey", "0-1", "0.69"), ("velum", "0-1", "0")]
++ [("freq", "20-20000Hz", "330"), ("note", "0-127midi", ""), ("speed", "", "1"), ("detune", "cents", "0"), ("glide", ">=0", "0")]
++ [("body", "0-1", "0"), ("sustain", "0-1", "1")]
++ [("attackcurve", "-8-8", "-2"), ("decaycurve", "-8-8", "-2"), ("releasecurve", "-8-8", "-2")]
++ [("orbit", "0-7", "0"), ("voice", ">=0", ""), ("reset", "0 | 1", "0")] -- chord?
++ [("pw", "0-1", "0.5"), ("spread", "0-100", "0"), ("uni", "1-7", "2")]
++ [("size", "0-256", "0"), ("warp", "-1-1", "0"), ("mirror", "0-1", "0")]
++ [("sub", "0-1", "0"), ("suboct", "1-3", "1")]
++ [("sync", "1-64", "1"), ("syncphase", "0-1", "0")]
++ [("gain", ">=0", "1"), ("drive", "0-1", "0.12"), ("postgain", ">=0", "1"), ("velocity", "0-1", "1"), ("pan", "0-1", "0.5"), ("width", "0-2", "1"), ("haas", "0-35ms", "0")]
++ [("vib", ">=0Hz", "0"), ("vibmod", ">=0semitones", "0")]
++ [("drift", "0-100cents", "2")]
++ [("fm", ">=0", "0"), ("fmh", ">=0", "1"), ("fm2", ">=0", "0"), ("fm2h", ">=0", "1"), ("fmpivot", "0-1", "0"), ("fmfb", ">=0", "0"), ("fmloop", "0-1", "0")]
++ [("am", ">=0Hz", "0"), ("amdepth", "0-1", "0.5")]
++ [("rm", ">=0Hz", "0"), ("rmdepth", "0-1", "1")]
++ [("n", ">=0", "0"), ("begin", "0-1", "0"), ("end", "0-1", "1"), ("cut", ">=0", ""), ("stretch", ">=0", "1"), ("grain", "0-1000", "0"), ("spray", "0-1", "0"), ("dens", "1-8", "2")]
-- recroder ?
-- multichan ?
-- busses ?
++ [("lpf", "20-20000Hz", ""), ("lpq", "0-1", "0.2"), ("kf", "0-1", "0")]
++ [("hpf", "20-20000Hz", ""), ("hpq", "0-1", "0.2")]
++ [("bpf", "20-20000Hz", ""), ("bpq", "0-1", "0.2")]
++ [("combfreq", "20-20000Hz", "220"), ("combfeedback", "0-0.99", "0.9"), ("combdamp", "0-1", "0.1")]
++ [("llpf", "20-20000Hz", ""), ("llpq", "0-1", "0.2"), ("lhpf", "20-20000Hz", ""), ("lhpq", "0-1", "0.2"), ("lbpf", "20-20000Hz", ""), ("lbpq", "0-1", "0.2")]
++ [("slpf", "20-20000Hz", ""), ("slpq", "0-1", "0.2")]
++ [("shpf", "20-20000Hz", ""), ("shpq", "0-1", "0.2")]
++ [("sbpf", "20-20000Hz", ""), ("sbpq", "0-1", "0.2")]
++ [("modal", "0-1", "0"), ("modalfreq", "20-20000Hz", "220"), ("modaldecay", "0.05-20s", "2"), ("modalstruct", "0-1", "0"), ("modalbright", "0-1", "0.5")]
++ [("phaser", ">=0", "0"), ("phaserdepth", "0-1", "0.5"), ("phasersweep", ">=0Hz", "2000"), ("phasercenter", "20-20000Hz", "1000")]
++ [("flanger", ">=0Hz", "0"), ("flangerdepth", "0-1", "0.5"), ("flangerfeedback", "0-0.95", "0")]
++ [("fshift", "-2000-2000Hz", "0")]
++ [("pshift", "-24-24semitones", "0"), ("pshiftwin", "5-200ms", "40")]
++ [("chorus", ">=0Hz", "0"), ("chorusdepth", "0-1", "0.5"), ("chorusdelay", ">=0ms", "20")]
++ [("fbtime", "0.1-680ms", "10"), ("fbdamp", "0-1", "0"), ("fbcross", "0-1", "0")]
++ [("delayfeedback", "0-1", "0.5")]
++ [("verbdecay", "0-1", "0.75"), ("verbdamp", "0-1", "0.95"), ("verbpredelay", "0-1", "0"), ("verbdiff", "0-1", "0.7"), ("verbchorus", "0-1", "0.3"), ("verbchorusfreq", "0-1", "0.2"), ("verbprelow", "0-1", "0.2"), ("verbprehigh", "0-1", "0.8"), ("verblowcut", "0-1", "0.5"), ("verbhighcut", "0-1", "0.7"), ("verblowgain", "0-1", "0.4")]
++ [("coarse", ">=1", "1"), ("crush", "1-16bits", "16"), ("fold", "0-1", "0"), ("wrap", ">=1", "1"), ("distort", ">=0", "1"), ("distortvol", ">=0", "1"), ("distortasym", "-1-1", "0")]
++ [("eqlo", "dB", "0"), ("eqmid", "dB", "0"), ("eqhi", "dB", "0")]
++ [("eqlofreq", "Hz", "200"), ("eqmidfreq", "Hz", "1000"), ("eqhifreq", "Hz", "5000"), ("eqmidq", "0.2-8", "0.7")]
++ [("tilt", "-1-1", "0")]
++ [("smear", "0-1", "0"), ("smearfreq", ">=20Hz", "1000"), ("smearfb", "0-0.95", "0")]
++ [("wah", "0-1", "0"), ("wahpeak", "0-1", "0.5"), ("wahsens", "0-1", "0.5"), ("wahmanual", "100-4000Hz", "400")]
++ [("vowel", "0-4", "0"), ("vowtype", "0-4", "1")]
++ [("vinyl", "0-1", "0"), ("vinylwow", "0-1", "0.3"), ("vinylnoise", "0-1", "0.2"), ("vinyltone", "-1-1", "0")]
++ [("comp", "0-1", "0"), ("comprelease", "0.001-2s", "0.15"), ("comporbit", "0-7", "0")]
secondParams :: [(Text, Text, Text)]
secondParams =
[("gate", ">=0cycles", "1")] -- time?
++ [("envdelay", ">=0s", "0"), ("attack", ">=0s", "0.003"), ("hold", ">=0s", "0"), ("decay", ">=0s", "0"), ("release", ">=0s", "0.005")]
++ [("delaytime", ">=0", "0.25")]
++ [("compattack", "0.001-1s", "0.01")]
orbitGlobalFX :: Map.Map Text AnnotatedExpression
orbitGlobalFX =
Map.unions
[ "verb" === toExp verb <:: "Number -> Map" --| "range: 0-1\ndefault: 0",
"feedback" === toExp feedback <:: "Number -> Map" --| "range: 0-1\ndefault: 0",
"delay" === toExp delay <:: "Number -> Map" --| "range: 0-1\ndefault: 0",
"comb" === toExp comb <:: "Number -> Map" --| "range: 0-1\ndefault: 0"
]
where
verb :: Zwirn Double -> Zwirn ExpressionMap
verb =
fmap
( \d ->
Map.fromList
[ ("verb", ENum d),
("verbdecay", 0.75),
("verbdamp", 0.95),
("verbpredelay", 0),
("verbdiff", 0.7),
("verbchorus", 0.3),
("verbchorusfreq", 0.2),
("verbprelow", 0.2),
("verbprehigh", 0.8),
("verblowcut", 0.5),
("verbhighcut", 0.7),
("verblowgain", 0.4),
("verbtype", "space")
]
)
delay :: Zwirn Double -> Zwirn ExpressionMap
delay dz =
liftA2
( \d t ->
Map.fromList
[ ("delay", ENum d),
("delayfeedback", 0.5),
("delaytime", ENum t),
("delaytype", "standard")
]
)
dz
(cycleToSecond 0.25)
feedback :: Zwirn Double -> Zwirn ExpressionMap
feedback =
fmap
( \d ->
Map.fromList
[ ("feedback", ENum d),
("fbtime", 10),
("fbdamp", 0),
("fbcross", 0)
]
)
comb :: Zwirn Double -> Zwirn ExpressionMap
comb =
fmap
( \d ->
Map.fromList
[ ("comb", ENum d),
("combfreq", 220),
("combfeedback", 0.9),
("combdamp", 0.1)
]
)