module Sound.Tidal.Params where
import qualified Data.Map.Strict as Map
import Sound.Tidal.Pattern
import Sound.Tidal.Utils
import Data.Maybe (fromMaybe)
import Data.Word (Word8)
grp :: [String -> ControlMap] -> Pattern String -> ControlPattern
grp [] _ = empty
grp fs p = splitby <$> p
where splitby name = Map.unions $ map (\(v, f) -> f v) $ zip (split name) fs
split :: String -> [String]
split = wordsBy (==':')
mF :: String -> String -> ControlMap
mF name v = fromMaybe Map.empty $ do f <- readMaybe v
return $ Map.singleton name (VF f)
mI :: String -> String -> ControlMap
mI name v = fromMaybe Map.empty $ do i <- readMaybe v
return $ Map.singleton name (VI i)
mS :: String -> String -> ControlMap
mS name v = Map.singleton name (VS v)
sound :: Pattern String -> ControlPattern
sound = grp [mS "s", mF "n"]
s :: Pattern String -> ControlPattern
s = sound
cc :: Pattern String -> ControlPattern
cc = grp [mF "ccn", mF "ccv"]
nrpn :: Pattern String -> ControlPattern
nrpn = grp [mI "nrpn", mI "val"]
pF :: String -> Pattern Double -> ControlPattern
pF name = fmap (Map.singleton name . VF)
pI :: String -> Pattern Int -> ControlPattern
pI name = fmap (Map.singleton name . VI)
pS :: String -> Pattern String -> ControlPattern
pS name = fmap (Map.singleton name . VS)
pX :: String -> Pattern [Word8] -> ControlPattern
pX name = fmap (Map.singleton name . VX)
toArg :: Pattern String -> ControlPattern
toArg = pS "toArg"
from :: Pattern Double -> ControlPattern
from = pF "from"
to :: Pattern Double -> ControlPattern
to = pF "to"
accelerate :: Pattern Double -> ControlPattern
accelerate = pF "accelerate"
amp :: Pattern Double -> ControlPattern
amp = pF "amp"
attack :: Pattern Double -> ControlPattern
attack = pF "attack"
bandf :: Pattern Double -> ControlPattern
bandf = pF "bandf"
bandq :: Pattern Double -> ControlPattern
bandq = pF "bandq"
begin, legato, clhatdecay, crush :: Pattern Double -> ControlPattern
channel, coarse :: Pattern Int -> ControlPattern
begin = pF "begin"
channel = pI "channel"
legato = pF "legato"
clhatdecay = pF "clhatdecay"
coarse = pI "coarse"
crush = pF "crush"
cut :: Pattern Int -> ControlPattern
cut = pI "cut"
cutoff :: Pattern Double -> ControlPattern
cutoff = pF "cutoff"
cutoffegint :: Pattern Double -> ControlPattern
cutoffegint = pF "cutoffegint"
decay :: Pattern Double -> ControlPattern
decay = pF "decay"
delay :: Pattern Double -> ControlPattern
delay = pF "delay"
delayfeedback :: Pattern Double -> ControlPattern
delayfeedback = pF "delayfeedback"
delaytime :: Pattern Double -> ControlPattern
delaytime = pF "delaytime"
detune :: Pattern Double -> ControlPattern
detune = pF "detune"
djf :: Pattern Double -> ControlPattern
djf = pF "djf"
dry :: Pattern Double -> ControlPattern
dry = pF "dry"
end :: Pattern Double -> ControlPattern
end = pF "end"
freq :: Pattern Double -> ControlPattern
freq = pF "freq"
gain :: Pattern Double -> ControlPattern
gain = pF "gain"
gate :: Pattern Double -> ControlPattern
gate = pF "gate"
hatgrain :: Pattern Double -> ControlPattern
hatgrain = pF "hatgrain"
hcutoff :: Pattern Double -> ControlPattern
hcutoff = pF "hcutoff"
hold :: Pattern Double -> ControlPattern
hold = pF "hold"
hresonance :: Pattern Double -> ControlPattern
hresonance = pF "hresonance"
kriole :: Pattern Int -> ControlPattern
kriole = pI "kriole"
lagogo :: Pattern Double -> ControlPattern
lagogo = pF "lagogo"
lclap :: Pattern Double -> ControlPattern
lclap = pF "lclap"
lclaves :: Pattern Double -> ControlPattern
lclaves = pF "lclaves"
lclhat :: Pattern Double -> ControlPattern
lclhat = pF "lclhat"
lcrash :: Pattern Double -> ControlPattern
lcrash = pF "lcrash"
leslie :: Pattern Double -> ControlPattern
leslie = pF "leslie"
lrate :: Pattern Double -> ControlPattern
lrate = pF "lrate"
lsize :: Pattern Double -> ControlPattern
lsize = pF "lsize"
lfo :: Pattern Double -> ControlPattern
lfo = pF "lfo"
lfocutoffint :: Pattern Double -> ControlPattern
lfocutoffint = pF "lfocutoffint"
lfodelay :: Pattern Double -> ControlPattern
lfodelay = pF "lfodelay"
lfoint :: Pattern Double -> ControlPattern
lfoint = pF "lfoint"
lfopitchint :: Pattern Double -> ControlPattern
lfopitchint = pF "lfopitchint"
lfoshape :: Pattern Double -> ControlPattern
lfoshape = pF "lfoshape"
lfosync :: Pattern Double -> ControlPattern
lfosync = pF "lfosync"
lhitom :: Pattern Double -> ControlPattern
lhitom = pF "lhitom"
lkick :: Pattern Double -> ControlPattern
lkick = pF "lkick"
llotom :: Pattern Double -> ControlPattern
llotom = pF "llotom"
lock :: Pattern Double -> ControlPattern
lock = pF "lock"
loop :: Pattern Double -> ControlPattern
loop = pF "loop"
lophat :: Pattern Double -> ControlPattern
lophat = pF "lophat"
lsnare :: Pattern Double -> ControlPattern
lsnare = pF "lsnare"
n :: Pattern Double -> ControlPattern
n = pF "n"
note :: Pattern Double -> ControlPattern
note = pF "note"
degree, mtranspose, ctranspose, harmonic, stepsPerOctave, octaveRatio :: Pattern Double -> ControlPattern
degree = pF "degree"
mtranspose = pF "mtranspose"
ctranspose = pF "ctranspose"
harmonic = pF "ctranspose"
stepsPerOctave = pF "stepsPerOctave"
octaveRatio = pF "octaveRatio"
nudge :: Pattern Double -> ControlPattern
nudge = pF "nudge"
octave :: Pattern Int -> ControlPattern
octave = pI "octave"
offset :: Pattern Double -> ControlPattern
offset = pF "offset"
ophatdecay :: Pattern Double -> ControlPattern
ophatdecay = pF "ophatdecay"
orbit :: Pattern Int -> ControlPattern
orbit = pI "orbit"
overgain :: Pattern Double -> ControlPattern
overgain = pF "overgain"
overshape :: Pattern Double -> ControlPattern
overshape = pF "overshape"
pan :: Pattern Double -> ControlPattern
pan = pF "pan"
panspan :: Pattern Double -> ControlPattern
panspan = pF "span"
pansplay :: Pattern Double -> ControlPattern
pansplay = pF "splay"
panwidth :: Pattern Double -> ControlPattern
panwidth = pF "panwidth"
panorient :: Pattern Double -> ControlPattern
panorient = pF "orientation"
pitch1 :: Pattern Double -> ControlPattern
pitch1 = pF "pitch1"
pitch2 :: Pattern Double -> ControlPattern
pitch2 = pF "pitch2"
pitch3 :: Pattern Double -> ControlPattern
pitch3 = pF "pitch3"
portamento :: Pattern Double -> ControlPattern
portamento = pF "portamento"
rate :: Pattern Double -> ControlPattern
rate = pF "rate"
release :: Pattern Double -> ControlPattern
release = pF "release"
resonance :: Pattern Double -> ControlPattern
resonance = pF "resonance"
room :: Pattern Double -> ControlPattern
room = pF "room"
sagogo :: Pattern Double -> ControlPattern
sagogo = pF "sagogo"
sclap :: Pattern Double -> ControlPattern
sclap = pF "sclap"
sclaves :: Pattern Double -> ControlPattern
sclaves = pF "sclaves"
scrash :: Pattern Double -> ControlPattern
scrash = pF "scrash"
semitone :: Pattern Double -> ControlPattern
semitone = pF "semitone"
shape :: Pattern Double -> ControlPattern
shape = pF "shape"
size :: Pattern Double -> ControlPattern
size = pF "size"
slide :: Pattern Double -> ControlPattern
slide = pF "slide"
speed :: Pattern Double -> ControlPattern
speed = pF "speed"
squiz :: Pattern Double -> ControlPattern
squiz = pF "squiz"
s' :: Pattern String -> ControlPattern
s' = pS "s"
stutterdepth :: Pattern Double -> ControlPattern
stutterdepth = pF "stutterdepth"
stuttertime :: Pattern Double -> ControlPattern
stuttertime = pF "stuttertime"
sustain :: Pattern Double -> ControlPattern
sustain = pF "sustain"
tomdecay :: Pattern Double -> ControlPattern
tomdecay = pF "tomdecay"
unit :: Pattern String -> ControlPattern
unit = pS "unit"
velocity :: Pattern Double -> ControlPattern
velocity = pF "velocity"
vcfegint :: Pattern Double -> ControlPattern
vcfegint = pF "vcfegint"
vcoegint :: Pattern Double -> ControlPattern
vcoegint = pF "vcoegint"
voice :: Pattern Double -> ControlPattern
voice = pF "voice"
vowel :: Pattern String -> ControlPattern
vowel = pS "vowel"
waveloss :: Pattern Double -> ControlPattern
waveloss = pF "waveloss"
dur :: Pattern Double -> ControlPattern
dur = pF "dur"
modwheel :: Pattern Double -> ControlPattern
modwheel = pF "modwheel"
expression :: Pattern Double -> ControlPattern
expression = pF "expression"
sustainpedal :: Pattern Double -> ControlPattern
sustainpedal = pF "sustainpedal"
tremolorate, tremolodepth :: Pattern Double -> ControlPattern
tremolorate = pF "tremolorate"
tremolodepth = pF "tremolodepth"
phaserrate, phaserdepth :: Pattern Double -> ControlPattern
phaserrate = pF "phaserrate"
phaserdepth = pF "phaserdepth"
fshift, fshiftphase, fshiftnote :: Pattern Double -> ControlPattern
fshift = pF "fshift"
fshiftphase = pF "fshiftphase"
fshiftnote = pF "fshiftnote"
triode :: Pattern Double -> ControlPattern
triode = pF "triode"
krush, kcutoff :: Pattern Double -> ControlPattern
krush = pF "krush"
kcutoff = pF "kcutoff"
octer, octersub, octersubsub :: Pattern Double -> ControlPattern
octer = pF "octer"
octersub = pF "octersub"
octersubsub = pF "octersubsub"
ring, ringf, ringdf :: Pattern Double -> ControlPattern
ring = pF "ring"
ringf = pF "ringf"
ringdf = pF "ringdf"
distort :: Pattern Double -> ControlPattern
distort = pF "distort"
freeze :: Pattern Double -> ControlPattern
freeze = pF "freeze"
xsdelay :: Pattern Double -> ControlPattern
xsdelay = pF "xsdelay"
tsdelay :: Pattern Double -> ControlPattern
tsdelay = pF "tsdelay"
real :: Pattern Double -> ControlPattern
real = pF "real"
imag :: Pattern Double -> ControlPattern
imag = pF "imag"
enhance :: Pattern Double -> ControlPattern
enhance = pF "enhance"
partials :: Pattern Double -> ControlPattern
partials = pF "partials"
comb :: Pattern Double -> ControlPattern
comb = pF "comb"
smear :: Pattern Double -> ControlPattern
smear = pF "smear"
scram :: Pattern Double -> ControlPattern
scram = pF "scram"
binshift :: Pattern Double -> ControlPattern
binshift = pF "binshift"
hbrick :: Pattern Double -> ControlPattern
hbrick = pF "hbrick"
lbrick :: Pattern Double -> ControlPattern
lbrick = pF "lbrick"
att, bpf, bpq, chdecay, ctf, ctfg, delayfb, delayt, det, gat, hg, hpf, hpq, lag, lbd, lch, lcl, lcp, lcr, lfoc, lfoi
, lfop, lht, llt, loh, lpf, lpq, lsn, ohdecay, phasdp, phasr, pit1, pit2, pit3, por, rel, sz, sag, scl, scp
, scr, sld, std, stt, sus, tdecay, tremdp, tremr, vcf, vco, voi
:: Pattern Double -> ControlPattern
att = attack
bpf = bandf
bpq = bandq
chdecay = clhatdecay
ctf = cutoff
ctfg = cutoffegint
delayfb = delayfeedback
delayt = delaytime
det = detune
gat = gate
hg = hatgrain
hpf = hcutoff
hpq = hresonance
lag = lagogo
lbd = lkick
lch = lclhat
lcl = lclaves
lcp = lclap
lcr = lcrash
lfoc = lfocutoffint
lfoi = lfoint
lfop = lfopitchint
lht = lhitom
llt = llotom
loh = lophat
lpf = cutoff
lpq = resonance
lsn = lsnare
ohdecay = ophatdecay
phasdp = phaserdepth
phasr = phaserrate
pit1 = pitch1
pit2 = pitch2
pit3 = pitch3
por = portamento
rel = release
sag = sagogo
scl = sclaves
scp = sclap
scr = scrash
sz = size
sld = slide
std = stutterdepth
stt = stuttertime
sus = sustain
tdecay = tomdecay
tremdp = tremolodepth
tremr = tremolorate
vcf = vcfegint
vco = vcoegint
voi = voice
midinote :: Pattern Double -> ControlPattern
midinote = note . (subtract 60 <$>)
drum :: Pattern String -> ControlPattern
drum = n . (subtract 60 . drumN <$>)
drumN :: Num a => String -> a
drumN "bd" = 36
drumN "sn" = 38
drumN "lt" = 43
drumN "ht" = 50
drumN "ch" = 42
drumN "oh" = 46
drumN "cp" = 39
drumN "cl" = 75
drumN "ag" = 67
drumN "cr" = 49
drumN _ = 0
array :: Pattern [Word8] -> ControlPattern
array = pX "array"
midichan :: Pattern Double -> ControlPattern
midichan = pF "midichan"
control :: Pattern Double -> ControlPattern
control = pF "control"
ccn :: Pattern Double -> ControlPattern
ccn = pF "ccn"
ccv :: Pattern Double -> ControlPattern
ccv = pF "ccv"
polyTouch :: Pattern Double -> ControlPattern
polyTouch = pF "polyTouch"
midibend :: Pattern Double -> ControlPattern
midibend = pF "midibend"
miditouch :: Pattern Double -> ControlPattern
miditouch = pF "miditouch"
nrpnn :: Pattern Int -> ControlPattern
nrpnn = pI "nrpn"
nrpnv :: Pattern Int -> ControlPattern
nrpnv = pI "val"
ctlNum :: Pattern Double -> ControlPattern
ctlNum = pF "ctlNum"
frameRate :: Pattern Double -> ControlPattern
frameRate = pF "frameRate"
frames :: Pattern Double -> ControlPattern
frames = pF "frames"
hours :: Pattern Double -> ControlPattern
hours = pF "hours"
midicmd :: Pattern String -> ControlPattern
midicmd = pS "midicmd"
command :: Pattern String -> ControlPattern
command = midicmd
minutes :: Pattern Double -> ControlPattern
minutes = pF "minutes"
progNum :: Pattern Double -> ControlPattern
progNum = pF "progNum"
seconds :: Pattern Double -> ControlPattern
seconds = pF "seconds"
songPtr :: Pattern Double -> ControlPattern
songPtr = pF "songPtr"
uid :: Pattern Double -> ControlPattern
uid = pF "uid"
val :: Pattern Double -> ControlPattern
val = pF "val"
up :: Pattern Double -> ControlPattern
up = note
cps :: Pattern Double -> ControlPattern
cps = pF "cps"
button0 :: Pattern Double -> ControlPattern
button0 = pF "button0"
button1 :: Pattern Double -> ControlPattern
button1 = pF "button1"
button2 :: Pattern Double -> ControlPattern
button2 = pF "button2"
button3 :: Pattern Double -> ControlPattern
button3 = pF "button3"
button4 :: Pattern Double -> ControlPattern
button4 = pF "button4"
button5 :: Pattern Double -> ControlPattern
button5 = pF "button5"
button6 :: Pattern Double -> ControlPattern
button6 = pF "button6"
button7 :: Pattern Double -> ControlPattern
button7 = pF "button7"
button8 :: Pattern Double -> ControlPattern
button8 = pF "button8"
button9 :: Pattern Double -> ControlPattern
button9 = pF "button9"
button10 :: Pattern Double -> ControlPattern
button10 = pF "button10"
button11 :: Pattern Double -> ControlPattern
button11 = pF "button11"
button12 :: Pattern Double -> ControlPattern
button12 = pF "button12"
button13 :: Pattern Double -> ControlPattern
button13 = pF "button13"
button14 :: Pattern Double -> ControlPattern
button14 = pF "button14"
button15 :: Pattern Double -> ControlPattern
button15 = pF "button15"
button16 :: Pattern Double -> ControlPattern
button16 = pF "button16"
button17 :: Pattern Double -> ControlPattern
button17 = pF "button17"
button18 :: Pattern Double -> ControlPattern
button18 = pF "button18"
button19 :: Pattern Double -> ControlPattern
button19 = pF "button19"
button20 :: Pattern Double -> ControlPattern
button20 = pF "button20"
button21 :: Pattern Double -> ControlPattern
button21 = pF "button21"
button22 :: Pattern Double -> ControlPattern
button22 = pF "button22"
button23 :: Pattern Double -> ControlPattern
button23 = pF "button23"
button24 :: Pattern Double -> ControlPattern
button24 = pF "button24"
button25 :: Pattern Double -> ControlPattern
button25 = pF "button25"
button26 :: Pattern Double -> ControlPattern
button26 = pF "button26"
button27 :: Pattern Double -> ControlPattern
button27 = pF "button27"
button28 :: Pattern Double -> ControlPattern
button28 = pF "button28"
button29 :: Pattern Double -> ControlPattern
button29 = pF "button29"
button30 :: Pattern Double -> ControlPattern
button30 = pF "button30"
button31 :: Pattern Double -> ControlPattern
button31 = pF "button31"
slider0 :: Pattern Double -> ControlPattern
slider0 = pF "slider0"
slider1 :: Pattern Double -> ControlPattern
slider1 = pF "slider1"
slider2 :: Pattern Double -> ControlPattern
slider2 = pF "slider2"
slider3 :: Pattern Double -> ControlPattern
slider3 = pF "slider3"
slider4 :: Pattern Double -> ControlPattern
slider4 = pF "slider4"
slider5 :: Pattern Double -> ControlPattern
slider5 = pF "slider5"
slider6 :: Pattern Double -> ControlPattern
slider6 = pF "slider6"
slider7 :: Pattern Double -> ControlPattern
slider7 = pF "slider7"
slider8 :: Pattern Double -> ControlPattern
slider8 = pF "slider8"
slider9 :: Pattern Double -> ControlPattern
slider9 = pF "slider9"
slider10 :: Pattern Double -> ControlPattern
slider10 = pF "slider10"
slider11 :: Pattern Double -> ControlPattern
slider11 = pF "slider11"
slider12 :: Pattern Double -> ControlPattern
slider12 = pF "slider12"
slider13 :: Pattern Double -> ControlPattern
slider13 = pF "slider13"
slider14 :: Pattern Double -> ControlPattern
slider14 = pF "slider14"
slider15 :: Pattern Double -> ControlPattern
slider15 = pF "slider15"
slider16 :: Pattern Double -> ControlPattern
slider16 = pF "slider16"
slider17 :: Pattern Double -> ControlPattern
slider17 = pF "slider17"
slider18 :: Pattern Double -> ControlPattern
slider18 = pF "slider18"
slider19 :: Pattern Double -> ControlPattern
slider19 = pF "slider19"
slider20 :: Pattern Double -> ControlPattern
slider20 = pF "slider20"
slider21 :: Pattern Double -> ControlPattern
slider21 = pF "slider21"
slider22 :: Pattern Double -> ControlPattern
slider22 = pF "slider22"
slider23 :: Pattern Double -> ControlPattern
slider23 = pF "slider23"
slider24 :: Pattern Double -> ControlPattern
slider24 = pF "slider24"
slider25 :: Pattern Double -> ControlPattern
slider25 = pF "slider25"
slider26 :: Pattern Double -> ControlPattern
slider26 = pF "slider26"
slider27 :: Pattern Double -> ControlPattern
slider27 = pF "slider27"
slider28 :: Pattern Double -> ControlPattern
slider28 = pF "slider28"
slider29 :: Pattern Double -> ControlPattern
slider29 = pF "slider29"
slider30 :: Pattern Double -> ControlPattern
slider30 = pF "slider30"
slider31 :: Pattern Double -> ControlPattern
slider31 = pF "slider31"