-- Reb00t minimaliste


do
-- sets the amount of operator 'op' in the superfm output mix
-- (1 <= op <= 6)
-- fmamp :: Int -> Pattern Double -> ControlPattern
let fmamp op = pF ("amp" ++ show op)
-- sets the ratio for operator 'op'.
-- the frequency is note * ratio + detune Hz
-- (1 <= op <= 6)
-- fmratio :: Int -> Pattern Double -> ControlPattern
let fmratio op = pF ("ratio" ++ show op)
-- set the detune for operator 'op'
-- fmdetune :: Int -> Pattern Double -> ControlPattern
let fmdetune op = pF ("detune" ++ show op)
-- set the modulation of oerator opa by operator opb
-- if opa == opb, then the modulation amount is multiplied by the
-- 'feedback' parameter
-- fmmod :: Int -> Int -> Pattern Double -> ControlPattern
let fmmod opa opb = pF ("mod" ++ show opa ++ show opb)
-- feedback
-- fmfeedback :: Pattern Double -> ControlPattern
let fmfeedback = pF "feedback"
-- Envelope definition: each operator has an envelop with 4 steps
-- fmeglevel :: Int -> Int -> Pattern Double -> ControlPattern
let fmeglevel op step = pF ("eglevel" ++ show op ++ show step)
-- Envelope definition: sets the rate at which the envelope moves
-- between steps.  Low numbers are slow, high numbers are fast.
-- fmegrate :: Int -> Int -> Pattern Double -> ControlPattern
let fmegrate op step = pF ("egrate" ++ show op ++ show step)
let fmparam function (x:xs) = foldr (#) (function 1 x) (zipWith function [2..] xs)
let fmamps = fmparam fmamp
let fmratios = fmparam fmratio
let fmdetunes = fmparam fmdetune
let envrate op = fmparam (fmegrate op)
let envlevel op = fmparam (fmeglevel op)
-- Params
let lfodepth = pF "lfodepth"
let lfofreq = pF "lfofreq"
-- Nova
let midiOn  ch pat = someCyclesBy ch pat
let midiOff ch pat = someCyclesBy (1 - ch) (pat)
let gDJF = (# djfbus 1 (range 0.05 0.95 "^49"))
let g = gDJF
-- Track
let prog = "<c'maj'4 d'maj'4 c'min'4 g'maj'4>"
let mel = (scale "aeolian" (slow (4 - (3 * "^57")) $ arp "updown" prog))
setcps (0.5)
d1 -- Kick 4/4
  $ g
  $ midiOn  "^41"  (<| "k <<k!8 ~ k!7> k!3 ~ k!3> k <k <k*2 [~ k]>>")
  $ midiOff "^41" (<| "k <k!2 <k k?> ~>")
  $ "[jazz,kick:5]*4"
  # midiG' ("^77" * "^55") 0 1
d2 -- Hats contretemps
  $ ply "1 1 <1 <[2|1] 2>> 1"
  $ mask "<f!12 t!24>"
  $ mask "<f!4 t!12>"
  $ "[~ hh]*4"
  # n "<8!7 [8!3 10]>"
  # release (slow 16 (range 1 0.05 saw))
  # gain (1.4 * (slow 4 $ range 1 1.48 saw) * "^77" * "^56")
  # pan (slow 4 $ range 0.98 0.5 saw)
d3 $ g -- Running Hats
  $ mask "<f!4 t!12>"
  $ midiOn "^41"  (fast 2)
  $ fast ("<1!4 2!4 4!24>" * "<1!8 2!8>" * "1 1 1 <1 [1 2] [2 1] 2>")
  $ "hh"
  # pan (slow 16 $ range 0.2 0.8 saw)
  # gain (1.7 * "^77" * "^56")
d5 $ g
  $ off "h" id
  $ midiOn "^42" (scramble 4 . ply 2 . often (chop "<2!3 4 2 [2 4] 2 4>"))
  $ midiOn "^43" (off "q" ((# room 0.2) . (|* gain 0.8)))
  $ degradeBy ("<0 0.5> 1!7" * "^50")
  $ midiOn "^44" (degradeBy "0 1!5 0.5 0.25")
  $ note mel
  # s "superfm"
  # midiG' "^78" 0 1.3
  # crushbus 51 (range 10 2.65 "^29")
  # pan "[<0.2 0.8> <0.8 0.2>]"
  # octave (3 + "^59" + "^60")
  # fmfeedback "^79"
  # fmamps                        ["^15", "^16", "^17", 0, 0, 0]
  # fmratios                      [1, 4, (slow 8 $ "<0.126 0.26 [0.51 0.52]>"), 0, 0, 0]
  # fmdetunes                     ["^51", 1 - "^52", "^53", 0, 0, 0]
  # fmmod 1 1 ("<0 1.25>" + "^31")
  # fmmod 1 2 (range 0 2 "^32")
  # fmmod 1 3 (range 0 4 "^33")
  -- # fmmod 3 2 (range 0 3 (slow 4 sine + "^52"))
  # envlevel 1 [1, 0.5, 0, 0, 0, 0]
  # envrate 1 [10, 0.1, 0.1, 1, 0, 0]
  # envlevel 2 [1, 0, 0, 0, 0, 0]
  # envrate 2 [1, 0.3, 0.7, 1, 0, 0]
  # envlevel 3 [1, 0.2, 0, 1, 0, 0]
  # envlevel 3 [1, 0.2, 0, 1, 0, 0]
  # envrate 3 [10, 0.5, 0.4, 1, 0, 0]
  # room 0.5 # sz 0.5
