{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveTraversable #-} module Synthesizer.LLVM.Filter.Moog ( Parameter, parameter, causal, causalInit, ) where import qualified Synthesizer.LLVM.Filter.FirstOrder as Filt1 () import qualified Synthesizer.Plain.Filter.Recursive.FirstOrder as FirstOrder import qualified Synthesizer.Plain.Filter.Recursive.Moog as Moog import Synthesizer.Plain.Filter.Recursive (Pole(..)) import qualified Synthesizer.LLVM.Causal.Process as Causal import qualified LLVM.DSL.Expression as Expr import qualified LLVM.Extra.Vector as Vector import qualified LLVM.Extra.Memory as Memory import qualified LLVM.Extra.Tuple as Tuple import qualified LLVM.Core as LLVM import qualified Type.Data.Num.Decimal as TypeNum import Type.Data.Num.Decimal (d0, d1) import Type.Base.Proxy (Proxy(Proxy)) import qualified Control.Arrow as Arrow import qualified Control.Applicative as App import qualified Data.Foldable as Fold import qualified Data.Traversable as Trav import Control.Arrow (arr, (>>>), (&&&)) import Control.Applicative (liftA2) import qualified Algebra.Transcendental as Trans import qualified Algebra.Module as Module import NumericPrelude.Numeric import NumericPrelude.Base newtype Parameter n a = Parameter {forall n a. Parameter n a -> Parameter a getParam :: Moog.Parameter a} deriving ((forall a b. (a -> b) -> Parameter n a -> Parameter n b) -> (forall a b. a -> Parameter n b -> Parameter n a) -> Functor (Parameter n) forall a b. a -> Parameter n b -> Parameter n a forall a b. (a -> b) -> Parameter n a -> Parameter n b forall n a b. a -> Parameter n b -> Parameter n a forall n a b. (a -> b) -> Parameter n a -> Parameter n b forall (f :: * -> *). (forall a b. (a -> b) -> f a -> f b) -> (forall a b. a -> f b -> f a) -> Functor f $cfmap :: forall n a b. (a -> b) -> Parameter n a -> Parameter n b fmap :: forall a b. (a -> b) -> Parameter n a -> Parameter n b $c<$ :: forall n a b. a -> Parameter n b -> Parameter n a <$ :: forall a b. a -> Parameter n b -> Parameter n a Functor, Functor (Parameter n) Functor (Parameter n) -> (forall a. a -> Parameter n a) -> (forall a b. Parameter n (a -> b) -> Parameter n a -> Parameter n b) -> (forall a b c. (a -> b -> c) -> Parameter n a -> Parameter n b -> Parameter n c) -> (forall a b. Parameter n a -> Parameter n b -> Parameter n b) -> (forall a b. Parameter n a -> Parameter n b -> Parameter n a) -> Applicative (Parameter n) forall n. Functor (Parameter n) forall a. a -> Parameter n a forall n a. a -> Parameter n a forall a b. Parameter n a -> Parameter n b -> Parameter n a forall a b. Parameter n a -> Parameter n b -> Parameter n b forall a b. Parameter n (a -> b) -> Parameter n a -> Parameter n b forall n a b. Parameter n a -> Parameter n b -> Parameter n a forall n a b. Parameter n a -> Parameter n b -> Parameter n b forall n a b. Parameter n (a -> b) -> Parameter n a -> Parameter n b forall a b c. (a -> b -> c) -> Parameter n a -> Parameter n b -> Parameter n c forall n a b c. (a -> b -> c) -> Parameter n a -> Parameter n b -> Parameter n c forall (f :: * -> *). Functor f -> (forall a. a -> f a) -> (forall a b. f (a -> b) -> f a -> f b) -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c) -> (forall a b. f a -> f b -> f b) -> (forall a b. f a -> f b -> f a) -> Applicative f $cpure :: forall n a. a -> Parameter n a pure :: forall a. a -> Parameter n a $c<*> :: forall n a b. Parameter n (a -> b) -> Parameter n a -> Parameter n b <*> :: forall a b. Parameter n (a -> b) -> Parameter n a -> Parameter n b $cliftA2 :: forall n a b c. (a -> b -> c) -> Parameter n a -> Parameter n b -> Parameter n c liftA2 :: forall a b c. (a -> b -> c) -> Parameter n a -> Parameter n b -> Parameter n c $c*> :: forall n a b. Parameter n a -> Parameter n b -> Parameter n b *> :: forall a b. Parameter n a -> Parameter n b -> Parameter n b $c<* :: forall n a b. Parameter n a -> Parameter n b -> Parameter n a <* :: forall a b. Parameter n a -> Parameter n b -> Parameter n a App.Applicative, (forall m. Monoid m => Parameter n m -> m) -> (forall m a. Monoid m => (a -> m) -> Parameter n a -> m) -> (forall m a. Monoid m => (a -> m) -> Parameter n a -> m) -> (forall a b. (a -> b -> b) -> b -> Parameter n a -> b) -> (forall a b. (a -> b -> b) -> b -> Parameter n a -> b) -> (forall b a. (b -> a -> b) -> b -> Parameter n a -> b) -> (forall b a. (b -> a -> b) -> b -> Parameter n a -> b) -> (forall a. (a -> a -> a) -> Parameter n a -> a) -> (forall a. (a -> a -> a) -> Parameter n a -> a) -> (forall a. Parameter n a -> [a]) -> (forall a. Parameter n a -> Bool) -> (forall a. Parameter n a -> Int) -> (forall a. Eq a => a -> Parameter n a -> Bool) -> (forall a. Ord a => Parameter n a -> a) -> (forall a. Ord a => Parameter n a -> a) -> (forall a. Num a => Parameter n a -> a) -> (forall a. Num a => Parameter n a -> a) -> Foldable (Parameter n) forall a. Eq a => a -> Parameter n a -> Bool forall a. Num a => Parameter n a -> a forall a. Ord a => Parameter n a -> a forall m. Monoid m => Parameter n m -> m forall a. Parameter n a -> Bool forall a. Parameter n a -> Int forall a. Parameter n a -> [a] forall a. (a -> a -> a) -> Parameter n a -> a forall n a. Eq a => a -> Parameter n a -> Bool forall n a. Num a => Parameter n a -> a forall n a. Ord a => Parameter n a -> a forall m a. Monoid m => (a -> m) -> Parameter n a -> m forall n m. Monoid m => Parameter n m -> m forall n a. Parameter n a -> Bool forall n a. Parameter n a -> Int forall n a. Parameter n a -> [a] forall b a. (b -> a -> b) -> b -> Parameter n a -> b forall a b. (a -> b -> b) -> b -> Parameter n a -> b forall n a. (a -> a -> a) -> Parameter n a -> a forall n m a. Monoid m => (a -> m) -> Parameter n a -> m forall n b a. (b -> a -> b) -> b -> Parameter n a -> b forall n a b. (a -> b -> b) -> b -> Parameter n a -> b forall (t :: * -> *). (forall m. Monoid m => t m -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. t a -> [a]) -> (forall a. t a -> Bool) -> (forall a. t a -> Int) -> (forall a. Eq a => a -> t a -> Bool) -> (forall a. Ord a => t a -> a) -> (forall a. Ord a => t a -> a) -> (forall a. Num a => t a -> a) -> (forall a. Num a => t a -> a) -> Foldable t $cfold :: forall n m. Monoid m => Parameter n m -> m fold :: forall m. Monoid m => Parameter n m -> m $cfoldMap :: forall n m a. Monoid m => (a -> m) -> Parameter n a -> m foldMap :: forall m a. Monoid m => (a -> m) -> Parameter n a -> m $cfoldMap' :: forall n m a. Monoid m => (a -> m) -> Parameter n a -> m foldMap' :: forall m a. Monoid m => (a -> m) -> Parameter n a -> m $cfoldr :: forall n a b. (a -> b -> b) -> b -> Parameter n a -> b foldr :: forall a b. (a -> b -> b) -> b -> Parameter n a -> b $cfoldr' :: forall n a b. (a -> b -> b) -> b -> Parameter n a -> b foldr' :: forall a b. (a -> b -> b) -> b -> Parameter n a -> b $cfoldl :: forall n b a. (b -> a -> b) -> b -> Parameter n a -> b foldl :: forall b a. (b -> a -> b) -> b -> Parameter n a -> b $cfoldl' :: forall n b a. (b -> a -> b) -> b -> Parameter n a -> b foldl' :: forall b a. (b -> a -> b) -> b -> Parameter n a -> b $cfoldr1 :: forall n a. (a -> a -> a) -> Parameter n a -> a foldr1 :: forall a. (a -> a -> a) -> Parameter n a -> a $cfoldl1 :: forall n a. (a -> a -> a) -> Parameter n a -> a foldl1 :: forall a. (a -> a -> a) -> Parameter n a -> a $ctoList :: forall n a. Parameter n a -> [a] toList :: forall a. Parameter n a -> [a] $cnull :: forall n a. Parameter n a -> Bool null :: forall a. Parameter n a -> Bool $clength :: forall n a. Parameter n a -> Int length :: forall a. Parameter n a -> Int $celem :: forall n a. Eq a => a -> Parameter n a -> Bool elem :: forall a. Eq a => a -> Parameter n a -> Bool $cmaximum :: forall n a. Ord a => Parameter n a -> a maximum :: forall a. Ord a => Parameter n a -> a $cminimum :: forall n a. Ord a => Parameter n a -> a minimum :: forall a. Ord a => Parameter n a -> a $csum :: forall n a. Num a => Parameter n a -> a sum :: forall a. Num a => Parameter n a -> a $cproduct :: forall n a. Num a => Parameter n a -> a product :: forall a. Num a => Parameter n a -> a Fold.Foldable, Functor (Parameter n) Foldable (Parameter n) Functor (Parameter n) -> Foldable (Parameter n) -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Parameter n a -> f (Parameter n b)) -> (forall (f :: * -> *) a. Applicative f => Parameter n (f a) -> f (Parameter n a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> Parameter n a -> m (Parameter n b)) -> (forall (m :: * -> *) a. Monad m => Parameter n (m a) -> m (Parameter n a)) -> Traversable (Parameter n) forall n. Functor (Parameter n) forall n. Foldable (Parameter n) forall n (m :: * -> *) a. Monad m => Parameter n (m a) -> m (Parameter n a) forall n (f :: * -> *) a. Applicative f => Parameter n (f a) -> f (Parameter n a) forall n (m :: * -> *) a b. Monad m => (a -> m b) -> Parameter n a -> m (Parameter n b) forall n (f :: * -> *) a b. Applicative f => (a -> f b) -> Parameter n a -> f (Parameter n b) forall (t :: * -> *). Functor t -> Foldable t -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> t a -> f (t b)) -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)) -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a)) -> Traversable t forall (m :: * -> *) a. Monad m => Parameter n (m a) -> m (Parameter n a) forall (f :: * -> *) a. Applicative f => Parameter n (f a) -> f (Parameter n a) forall (m :: * -> *) a b. Monad m => (a -> m b) -> Parameter n a -> m (Parameter n b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Parameter n a -> f (Parameter n b) $ctraverse :: forall n (f :: * -> *) a b. Applicative f => (a -> f b) -> Parameter n a -> f (Parameter n b) traverse :: forall (f :: * -> *) a b. Applicative f => (a -> f b) -> Parameter n a -> f (Parameter n b) $csequenceA :: forall n (f :: * -> *) a. Applicative f => Parameter n (f a) -> f (Parameter n a) sequenceA :: forall (f :: * -> *) a. Applicative f => Parameter n (f a) -> f (Parameter n a) $cmapM :: forall n (m :: * -> *) a b. Monad m => (a -> m b) -> Parameter n a -> m (Parameter n b) mapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> Parameter n a -> m (Parameter n b) $csequence :: forall n (m :: * -> *) a. Monad m => Parameter n (m a) -> m (Parameter n a) sequence :: forall (m :: * -> *) a. Monad m => Parameter n (m a) -> m (Parameter n a) Trav.Traversable) instance (Tuple.Phi a, TypeNum.Natural n) => Tuple.Phi (Parameter n a) where phi :: forall r. BasicBlock -> Parameter n a -> CodeGenFunction r (Parameter n a) phi = BasicBlock -> Parameter n a -> CodeGenFunction r (Parameter n a) forall a (f :: * -> *) r. (Phi a, Traversable f) => BasicBlock -> f a -> CodeGenFunction r (f a) Tuple.phiTraversable addPhi :: forall r. BasicBlock -> Parameter n a -> Parameter n a -> CodeGenFunction r () addPhi = BasicBlock -> Parameter n a -> Parameter n a -> CodeGenFunction r () forall a (f :: * -> *) r. (Phi a, Foldable f, Applicative f) => BasicBlock -> f a -> f a -> CodeGenFunction r () Tuple.addPhiFoldable instance (Tuple.Undefined a, TypeNum.Natural n) => Tuple.Undefined (Parameter n a) where undef :: Parameter n a undef = Parameter n a forall a (f :: * -> *). (Undefined a, Applicative f) => f a Tuple.undefPointed instance (Tuple.Zero a, TypeNum.Natural n) => Tuple.Zero (Parameter n a) where zero :: Parameter n a zero = Parameter n a forall a (f :: * -> *). (Zero a, Applicative f) => f a Tuple.zeroPointed type ParameterStruct a = LLVM.Struct (Memory.Struct a, (Memory.Struct (FirstOrder.Parameter a), ())) parameterMemory :: (Memory.C a, TypeNum.Natural n) => Memory.Record r (ParameterStruct a) (Parameter n a) parameterMemory :: forall a n r. (C a, Natural n) => Record r (ParameterStruct a) (Parameter n a) parameterMemory = (a -> Parameter a -> Parameter n a) -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) a -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) (Parameter a) -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) (Parameter n a) forall a b c. (a -> b -> c) -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) a -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) b -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) c forall (f :: * -> *) a b c. Applicative f => (a -> b -> c) -> f a -> f b -> f c liftA2 (\a f Parameter a k -> Parameter a -> Parameter n a forall n a. Parameter a -> Parameter n a Parameter (a -> Parameter a -> Parameter a forall a. a -> Parameter a -> Parameter a Moog.Parameter a f Parameter a k)) ((Parameter n a -> a) -> Proxy D0 -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) a forall x o n v r. (C x, GetValue o n, ValueType o n ~ Struct x, GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) => (v -> x) -> n -> Element r o v x Memory.element (Parameter a -> a forall a. Parameter a -> a Moog.feedback (Parameter a -> a) -> (Parameter n a -> Parameter a) -> Parameter n a -> a forall b c a. (b -> c) -> (a -> b) -> a -> c . Parameter n a -> Parameter a forall n a. Parameter n a -> Parameter a getParam) Proxy D0 d0) ((Parameter n a -> Parameter a) -> Proxy D1 -> Element r (Struct (Struct a, (Struct a, ()))) (Parameter n a) (Parameter a) forall x o n v r. (C x, GetValue o n, ValueType o n ~ Struct x, GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) => (v -> x) -> n -> Element r o v x Memory.element (Parameter a -> Parameter a forall a. Parameter a -> Parameter a Moog.lowpassParam (Parameter a -> Parameter a) -> (Parameter n a -> Parameter a) -> Parameter n a -> Parameter a forall b c a. (b -> c) -> (a -> b) -> a -> c . Parameter n a -> Parameter a forall n a. Parameter n a -> Parameter a getParam) Proxy D1 d1) instance (Memory.C a, TypeNum.Natural n) => Memory.C (Parameter n a) where type Struct (Parameter n a) = ParameterStruct a load :: forall r. Value (Ptr (Struct (Parameter n a))) -> CodeGenFunction r (Parameter n a) load = Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) -> Value (Ptr (Struct (Struct a, (Struct a, ())))) -> CodeGenFunction r (Parameter n a) forall r o llvmValue. Record r o llvmValue -> Value (Ptr o) -> CodeGenFunction r llvmValue Memory.loadRecord Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) Record r (ParameterStruct a) (Parameter n a) forall a n r. (C a, Natural n) => Record r (ParameterStruct a) (Parameter n a) parameterMemory store :: forall r. Parameter n a -> Value (Ptr (Struct (Parameter n a))) -> CodeGenFunction r () store = Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) -> Parameter n a -> Value (Ptr (Struct (Struct a, (Struct a, ())))) -> CodeGenFunction r () forall r o llvmValue. Record r o llvmValue -> llvmValue -> Value (Ptr o) -> CodeGenFunction r () Memory.storeRecord Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) Record r (ParameterStruct a) (Parameter n a) forall a n r. (C a, Natural n) => Record r (ParameterStruct a) (Parameter n a) parameterMemory decompose :: forall r. Value (Struct (Parameter n a)) -> CodeGenFunction r (Parameter n a) decompose = Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) -> Value (Struct (Struct a, (Struct a, ()))) -> CodeGenFunction r (Parameter n a) forall r o llvmValue. Record r o llvmValue -> Value o -> CodeGenFunction r llvmValue Memory.decomposeRecord Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) Record r (ParameterStruct a) (Parameter n a) forall a n r. (C a, Natural n) => Record r (ParameterStruct a) (Parameter n a) parameterMemory compose :: forall r. Parameter n a -> CodeGenFunction r (Value (Struct (Parameter n a))) compose = Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) -> Parameter n a -> CodeGenFunction r (Value (Struct (Struct a, (Struct a, ())))) forall o r llvmValue. IsType o => Record r o llvmValue -> llvmValue -> CodeGenFunction r (Value o) Memory.composeRecord Record r (Struct (Struct a, (Struct a, ()))) (Parameter n a) Record r (ParameterStruct a) (Parameter n a) forall a n r. (C a, Natural n) => Record r (ParameterStruct a) (Parameter n a) parameterMemory instance (Vector.Simple v, TypeNum.Natural n) => Vector.Simple (Parameter n v) where type Element (Parameter n v) = Parameter n (Vector.Element v) type Size (Parameter n v) = Vector.Size v shuffleMatch :: forall r. ConstValue (Vector (Size (Parameter n v)) Word32) -> Parameter n v -> CodeGenFunction r (Parameter n v) shuffleMatch = ConstValue (Vector (Size v) Word32) -> Parameter n v -> CodeGenFunction r (Parameter n v) ConstValue (Vector (Size (Parameter n v)) Word32) -> Parameter n v -> CodeGenFunction r (Parameter n v) forall v (f :: * -> *) r. (Simple v, Traversable f) => ConstValue (Vector (Size v) Word32) -> f v -> CodeGenFunction r (f v) Vector.shuffleMatchTraversable extract :: forall r. Value Word32 -> Parameter n v -> CodeGenFunction r (Element (Parameter n v)) extract = Value Word32 -> Parameter n v -> CodeGenFunction r (Element (Parameter n v)) Value Word32 -> Parameter n v -> CodeGenFunction r (Parameter n (Element v)) forall v (f :: * -> *) r. (Simple v, Traversable f) => Value Word32 -> f v -> CodeGenFunction r (f (Element v)) Vector.extractTraversable instance (Vector.C v, TypeNum.Natural n) => Vector.C (Parameter n v) where insert :: forall r. Value Word32 -> Element (Parameter n v) -> Parameter n v -> CodeGenFunction r (Parameter n v) insert = Value Word32 -> Element (Parameter n v) -> Parameter n v -> CodeGenFunction r (Parameter n v) Value Word32 -> Parameter n (Element v) -> Parameter n v -> CodeGenFunction r (Parameter n v) forall v (f :: * -> *) r. (C v, Traversable f, Applicative f) => Value Word32 -> f (Element v) -> f v -> CodeGenFunction r (f v) Vector.insertTraversable parameter :: (TypeNum.Natural n, Trans.C a) => Proxy n -> a -> a -> Parameter n a parameter :: forall n a. (Natural n, C a) => Proxy n -> a -> a -> Parameter n a parameter Proxy n order a reson a freq = Parameter a -> Parameter n a forall n a. Parameter a -> Parameter n a Parameter (Parameter a -> Parameter n a) -> Parameter a -> Parameter n a forall a b. (a -> b) -> a -> b $ Int -> Pole a -> Parameter a forall a. C a => Int -> Pole a -> Parameter a Moog.parameter (Proxy n -> Int forall n a. (Integer n, Num a) => Proxy n -> a TypeNum.integralFromProxy Proxy n order) (a -> a -> Pole a forall a. a -> a -> Pole a Pole a reson a freq) instance (n ~ m, Expr.Aggregate e mv) => Expr.Aggregate (Parameter n e) (Parameter m mv) where type MultiValuesOf (Parameter n e) = Parameter n (Expr.MultiValuesOf e) type ExpressionsOf (Parameter m mv) = Parameter m (Expr.ExpressionsOf mv) bundle :: forall r. Parameter n e -> CodeGenFunction r (Parameter m mv) bundle (Parameter (Moog.Parameter e f Parameter e k)) = (Parameter mv -> Parameter m mv) -> CodeGenFunction r (Parameter mv) -> CodeGenFunction r (Parameter m mv) forall a b. (a -> b) -> CodeGenFunction r a -> CodeGenFunction r b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Parameter mv -> Parameter m mv forall n a. Parameter a -> Parameter n a Parameter (CodeGenFunction r (Parameter mv) -> CodeGenFunction r (Parameter m mv)) -> CodeGenFunction r (Parameter mv) -> CodeGenFunction r (Parameter m mv) forall a b. (a -> b) -> a -> b $ (mv -> Parameter mv -> Parameter mv) -> CodeGenFunction r mv -> CodeGenFunction r (Parameter mv) -> CodeGenFunction r (Parameter mv) forall a b c. (a -> b -> c) -> CodeGenFunction r a -> CodeGenFunction r b -> CodeGenFunction r c forall (f :: * -> *) a b c. Applicative f => (a -> b -> c) -> f a -> f b -> f c liftA2 mv -> Parameter mv -> Parameter mv forall a. a -> Parameter a -> Parameter a Moog.Parameter (e -> CodeGenFunction r mv forall r. e -> CodeGenFunction r mv forall exp mv r. Aggregate exp mv => exp -> CodeGenFunction r mv Expr.bundle e f) (Parameter e -> CodeGenFunction r (Parameter mv) forall r. Parameter e -> CodeGenFunction r (Parameter mv) forall exp mv r. Aggregate exp mv => exp -> CodeGenFunction r mv Expr.bundle Parameter e k) dissect :: Parameter m mv -> Parameter n e dissect (Parameter (Moog.Parameter mv f Parameter mv k)) = Parameter e -> Parameter n e forall n a. Parameter a -> Parameter n a Parameter (e -> Parameter e -> Parameter e forall a. a -> Parameter a -> Parameter a Moog.Parameter (mv -> e forall exp mv. Aggregate exp mv => mv -> exp Expr.dissect mv f) (Parameter mv -> Parameter e forall exp mv. Aggregate exp mv => mv -> exp Expr.dissect Parameter mv k)) merge :: (Module.C a v) => (Parameter n a, v) -> v -> (FirstOrder.Parameter a, v) merge :: forall a v n. C a v => (Parameter n a, v) -> v -> (Parameter a, v) merge (Parameter (Moog.Parameter a f Parameter a k), v x) v y0 = (Parameter a k, v x v -> v -> v forall a. C a => a -> a -> a - a f a -> v -> v forall a v. C a v => a -> v -> v *> v y0) amplify :: (Module.C a v) => Parameter n a -> v -> v amplify :: forall a v n. C a v => Parameter n a -> v -> v amplify Parameter n a p v y1 = (a 1 a -> a -> a forall a. C a => a -> a -> a + Parameter a -> a forall a. Parameter a -> a Moog.feedback (Parameter n a -> Parameter a forall n a. Parameter n a -> Parameter a getParam Parameter n a p)) a -> v -> v forall a v. C a v => a -> v -> v *> v y1 causal :: (TypeNum.Natural n, Memory.C v, Module.C ae ve, Expr.Aggregate ae a, Expr.Aggregate ve v) => Causal.T (Parameter n a, v) v causal :: forall n v ae ve a. (Natural n, C v, C ae ve, Aggregate ae a, Aggregate ve v) => T (Parameter n a, v) v causal = (T ((Parameter n a, v), v) v -> T (Parameter n a, v) v) -> Proxy n -> T (Parameter n a, v) v forall n v ae ve a. (Natural n, C v, C ae ve, Aggregate ae a, Aggregate ve v) => (T ((Parameter n a, v), v) v -> T (Parameter n a, v) v) -> Proxy n -> T (Parameter n a, v) v causalSize ((T ((Parameter n a, v), v) v -> T (Parameter n a, v) v -> T (Parameter n a, v) v) -> T (Parameter n a, v) v -> T ((Parameter n a, v), v) v -> T (Parameter n a, v) v forall a b c. (a -> b -> c) -> b -> a -> c flip (ve -> T ((Parameter n a, v), v) v -> T (Parameter n a, v) v -> T (Parameter n a, v) v forall ce c ctrl a b. (Aggregate ce c, C c) => ce -> T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b Causal.feedbackControlled ve forall a. C a => a zero) (((Parameter n a, v) -> v) -> T (Parameter n a, v) v forall b c. (b -> c) -> T b c forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c arr (Parameter n a, v) -> v forall a b. (a, b) -> b snd)) Proxy n forall a. Proxy a Proxy causalInit :: (TypeNum.Natural n, Memory.C v, Module.C ae ve, Expr.Aggregate ae a, Expr.Aggregate ve v) => ve -> Causal.T (Parameter n a, v) v causalInit :: forall n v ae ve a. (Natural n, C v, C ae ve, Aggregate ae a, Aggregate ve v) => ve -> T (Parameter n a, v) v causalInit ve initial = (T ((Parameter n a, v), v) v -> T (Parameter n a, v) v) -> Proxy n -> T (Parameter n a, v) v forall n v ae ve a. (Natural n, C v, C ae ve, Aggregate ae a, Aggregate ve v) => (T ((Parameter n a, v), v) v -> T (Parameter n a, v) v) -> Proxy n -> T (Parameter n a, v) v causalSize ((T ((Parameter n a, v), v) v -> T (Parameter n a, v) v -> T (Parameter n a, v) v) -> T (Parameter n a, v) v -> T ((Parameter n a, v), v) v -> T (Parameter n a, v) v forall a b c. (a -> b -> c) -> b -> a -> c flip (ve -> T ((Parameter n a, v), v) v -> T (Parameter n a, v) v -> T (Parameter n a, v) v forall ce c ctrl a b. (Aggregate ce c, C c) => ce -> T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b Causal.feedbackControlled ve initial) (((Parameter n a, v) -> v) -> T (Parameter n a, v) v forall b c. (b -> c) -> T b c forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c arr (Parameter n a, v) -> v forall a b. (a, b) -> b snd)) Proxy n forall a. Proxy a Proxy causalSize :: (TypeNum.Natural n, Memory.C v, Module.C ae ve, Expr.Aggregate ae a, Expr.Aggregate ve v) => (Causal.T ((Parameter n a, v), v) v -> Causal.T (Parameter n a, v) v) -> Proxy n -> Causal.T (Parameter n a, v) v causalSize :: forall n v ae ve a. (Natural n, C v, C ae ve, Aggregate ae a, Aggregate ve v) => (T ((Parameter n a, v), v) v -> T (Parameter n a, v) v) -> Proxy n -> T (Parameter n a, v) v causalSize T ((Parameter n a, v), v) v -> T (Parameter n a, v) v feedback Proxy n n = let order :: Exp Word order = Proxy n -> Exp Word forall n a. (Integer n, Num a) => Proxy n -> a TypeNum.integralFromProxy Proxy n n in ((Parameter n a, v) -> Parameter n a) -> T (Parameter n a, v) (Parameter n a) forall b c. (b -> c) -> T b c forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c Arrow.arr (Parameter n a, v) -> Parameter n a forall a b. (a, b) -> a fst T (Parameter n a, v) (Parameter n a) -> T (Parameter n a, v) v -> T (Parameter n a, v) (Parameter n a, v) forall b c c'. T b c -> T b c' -> T b (c, c') forall (a :: * -> * -> *) b c c'. Arrow a => a b c -> a b c' -> a b (c, c') &&& T ((Parameter n a, v), v) v -> T (Parameter n a, v) v feedback (((Parameter n ae, ve) -> ve -> (Parameter ae, ve)) -> T ((Parameter n a, v), v) (Parameter (MultiValuesOf ae), v) forall ae a be b ce c. (Aggregate ae a, Aggregate be b, Aggregate ce c) => (ae -> be -> ce) -> T (a, b) c Causal.zipWith (Parameter n ae, ve) -> ve -> (Parameter ae, ve) forall a v n. C a v => (Parameter n a, v) -> v -> (Parameter a, v) merge T ((Parameter n a, v), v) (Parameter (MultiValuesOf ae), v) -> T (Parameter (MultiValuesOf ae), v) v -> T ((Parameter n a, v), v) v forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c >>> Exp Word -> T (Parameter (MultiValuesOf ae), v) v -> T (Parameter (MultiValuesOf ae), v) v forall a c. (Undefined a, Phi a) => Exp Word -> T (c, a) a -> T (c, a) a Causal.replicateControlled Exp Word order (Simple ve (Parameter ae) ve ve -> T (Parameter (MultiValuesOf ae), v) v forall ae al be bl ce cl se sl. (Aggregate ae al, Aggregate be bl, Aggregate ce cl, Aggregate se sl, C sl) => Simple se ce ae be -> T (cl, al) bl Causal.fromModifier Simple ve (Parameter ae) ve ve forall a v. (C a, C a v) => Simple v (Parameter a) v v FirstOrder.lowpassModifier)) T (Parameter n a, v) (Parameter n a, v) -> T (Parameter n a, v) v -> T (Parameter n a, v) v forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c >>> (Parameter n ae -> ve -> ve) -> T (Parameter n a, v) v forall ae a be b ce c. (Aggregate ae a, Aggregate be b, Aggregate ce c) => (ae -> be -> ce) -> T (a, b) c Causal.zipWith Parameter n ae -> ve -> ve forall a v n. C a v => Parameter n a -> v -> v amplify