{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}

{-# LANGUAGE NoIncoherentInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE NoUndecidableInstances #-}

module Vivid.UGens.Delays (

     -- * Delays > Buffer

---     bufAllpassC
---   , bufAllpassL
---   , bufAllpassN
---   , bufCombC
---   , bufCombL
---   , bufCombN
---   , bufDelayC
---   , bufDelayL
---   , bufDelayN
     -- in Vivid.UGens.Buffer:
   -- , multiTap
---   , pingPong
     -- in Vivid.UGens.Buffer:
   -- , tap

     -- * Delays

     allpassC
   , allpassL
   , allpassN
   , combC
   , combL
   , combN
     -- in Vivid.UGens.Buffer:
   -- , delTapRd
   -- , delTapWr
   , delay1
   , delay2
   , delayC
   , delayL
   , delayN
   , pluck
---   , tDelay
   ) where

-- import Data.ByteString (ByteString)

import Vivid.SC.SynthDef.Types (CalculationRate(..))
import Vivid.SynthDef
import Vivid.SynthDef.FromUA
import Vivid.UGens.Args

--- bufAllpassC ::
--- bufAllpassC =
--- bufAllpassL ::
--- bufAllpassL =
--- bufAllpassN ::
--- bufAllpassN =
--- bufCombC ::
--- bufCombC =
--- bufCombL ::
--- bufCombL =
--- bufCombN ::
--- bufCombN =
--- bufDelayC ::
--- bufDelayC =
--- bufDelayL ::
--- bufDelayL =
--- bufDelayN ::
--- bufDelayN =
--- pingPong ::
--- pingPong =


allpassC :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
allpassC :: a -> SDBody a Signal
allpassC = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"AllpassC"

allpassL :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
allpassL :: a -> SDBody a Signal
allpassL = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"AllpassL"

allpassN :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
allpassN :: a -> SDBody a Signal
allpassN = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"AllpassN"

-- These 3 have a delay -- the above 3 you hear yourself right away:

combC :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
combC :: a -> SDBody a Signal
combC = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"CombC"

combL :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
combL :: a -> SDBody a Signal
combL = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"CombL"

combN :: (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
combN :: a -> SDBody a Signal
combN = String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
forall a.
String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
"CombN"

makeDelay :: String -> (Args '["in"] ["maxDelaySecs", "delaySecs", "decaySecs"] a) => a -> SDBody a Signal
makeDelay :: String
-> Args '["in"] '["maxDelaySecs", "delaySecs", "decaySecs"] a =>
   a -> SDBody a Signal
makeDelay String
delayName =
   String
-> CalculationRate
-> Vs '["in", "maxDelaySecs", "delaySecs", "decaySecs"]
-> (UA "maxDelaySecs" (SDBodyArgs a),
    UA "delaySecs" (SDBodyArgs a), UA "decaySecs" (SDBodyArgs a))
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen String
delayName CalculationRate
AR
   (Vs '["in", "maxDelaySecs", "delaySecs", "decaySecs"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in", "maxDelaySecs", "delaySecs", "decaySecs"])
   (Float -> UA "maxDelaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "maxDelaySecs" as
maxDelayTime_ (Float
0.2::Float), Float -> UA "delaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "delaySecs" as
delayTime_ (Float
0.2::Float), Float -> UA "decaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "decaySecs" as
decayTime_ ((Float
1)::Float))

delay1 :: (Args '["in"] '[] a) => a -> SDBody a Signal
delay1 :: a -> SDBody a Signal
delay1 = String
-> CalculationRate
-> Vs '["in"]
-> NoDefaults (SDBodyArgs a)
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"Delay1" CalculationRate
AR
   (Vs '["in"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in"])
   NoDefaults (SDBodyArgs a)
forall (args :: [Symbol]). NoDefaults args
NoDefaults

delay2 :: (Args '["in"] '[] a) => a -> SDBody a Signal
delay2 :: a -> SDBody a Signal
delay2 = String
-> CalculationRate
-> Vs '["in"]
-> NoDefaults (SDBodyArgs a)
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"Delay2" CalculationRate
AR
   (Vs '["in"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in"])
   NoDefaults (SDBodyArgs a)
forall (args :: [Symbol]). NoDefaults args
NoDefaults

delayC :: (Args '["in"] '["maxDelaySecs", "delaySecs"] a) => a -> SDBody a Signal
delayC :: a -> SDBody a Signal
delayC = String
-> CalculationRate
-> Vs '["in", "maxDelaySecs", "delaySecs"]
-> (UA "maxDelaySecs" (SDBodyArgs a),
    UA "delaySecs" (SDBodyArgs a))
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"DelayC" CalculationRate
AR
   (Vs '["in", "maxDelaySecs", "delaySecs"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in", "maxDelaySecs", "delaySecs"])
   (Float -> UA "maxDelaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "maxDelaySecs" as
maxDelayTime_ (Float
0.2::Float), Float -> UA "delaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "delaySecs" as
delayTime_ (Float
0.2::Float))

delayL :: (Args '["in"] '["maxDelaySecs", "delaySecs"] a) => a -> SDBody a Signal
delayL :: a -> SDBody a Signal
delayL =  String
-> CalculationRate
-> Vs '["in", "maxDelaySecs", "delaySecs"]
-> (UA "maxDelaySecs" (SDBodyArgs a),
    UA "delaySecs" (SDBodyArgs a))
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"DelayL" CalculationRate
AR
   (Vs '["in", "maxDelaySecs", "delaySecs"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in", "maxDelaySecs", "delaySecs"])
   (Float -> UA "maxDelaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "maxDelaySecs" as
maxDelayTime_ (Float
0.2::Float), Float -> UA "delaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "delaySecs" as
delayTime_ (Float
0.2::Float))

delayN :: (Args '["in"] '["maxDelaySecs", "delaySecs"] a) => a -> SDBody a Signal
delayN :: a -> SDBody a Signal
delayN =  String
-> CalculationRate
-> Vs '["in", "maxDelaySecs", "delaySecs"]
-> (UA "maxDelaySecs" (SDBodyArgs a),
    UA "delaySecs" (SDBodyArgs a))
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"DelayN" CalculationRate
AR
   (Vs '["in", "maxDelaySecs", "delaySecs"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in", "maxDelaySecs", "delaySecs"])
   (Float -> UA "maxDelaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "maxDelaySecs" as
maxDelayTime_ (Float
0.2::Float), Float -> UA "delaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "delaySecs" as
delayTime_ (Float
0.2::Float))

pluck :: Args '[] '["in","trigger","maxDelaySecs","delaySecs","decaySecs","coef"] a => a -> SDBody a Signal
pluck :: a -> SDBody a Signal
pluck = String
-> CalculationRate
-> Vs
     '["in", "trigger", "maxDelaySecs", "delaySecs", "decaySecs",
       "coef"]
-> (UA "in" (SDBodyArgs a), UA "trigger" (SDBodyArgs a),
    UA "maxDelaySecs" (SDBodyArgs a), UA "delaySecs" (SDBodyArgs a),
    UA "decaySecs" (SDBodyArgs a), UA "coef" (SDBodyArgs a))
-> a
-> SDBody a Signal
forall (tags :: [Symbol]) optional userSupplied (args :: [Symbol]).
(GetSymbolVals (Vs tags), FromUA optional, FromUA userSupplied,
 SDBodyArgs optional ~ SDBodyArgs userSupplied,
 SDBodyArgs optional ~ args) =>
String
-> CalculationRate
-> Vs tags
-> optional
-> userSupplied
-> SDBody' args Signal
makeUGen
   String
"Pluck" CalculationRate
AR
   (Vs
  '["in", "trigger", "maxDelaySecs", "delaySecs", "decaySecs",
    "coef"]
forall (a :: [Symbol]). Vs a
Vs::Vs '["in","trigger","maxDelaySecs","delaySecs","decaySecs","coef"])
   (Float -> UA "in" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "in" as
in_ (Float
0::Float), Float -> UA "trigger" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "trigger" as
trigger_ (Float
1::Float), Float -> UA "maxDelaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "maxDelaySecs" as
maxDelaySecs_ (Float
0.2::Float)
   ,Float -> UA "delaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "delaySecs" as
delaySecs_ (Float
0.2::Float), Float -> UA "decaySecs" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "decaySecs" as
decaySecs_ (Float
1::Float), Float -> UA "coef" (SDBodyArgs a)
forall s (as :: [Symbol]). ToSig s as => s -> UA "coef" as
coef_ (Float
0.5::Float))

--- tDelay ::
--- tDelay =