{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
module Synthesizer.Dimensional.Causal.ControlledProcess (
C(process),
RateDep(RateDep, unRateDep),
runSynchronous1,
runSynchronous2,
runAsynchronous1,
runAsynchronousBuffered1,
processAsynchronous1,
runAsynchronous2,
processAsynchronous2,
processAsynchronousBuffered2,
) where
import qualified Synthesizer.Dimensional.Sample as Sample
import qualified Synthesizer.Dimensional.Process as Proc
import qualified Synthesizer.Dimensional.Rate as Rate
import qualified Synthesizer.Dimensional.Signal.Private as SigA
import qualified Synthesizer.Dimensional.Causal.Process as CausalD
import qualified Synthesizer.Dimensional.Arrow as ArrowD
import qualified Synthesizer.Dimensional.Map as MapD
import qualified Synthesizer.Dimensional.Amplitude as Amp
import qualified Synthesizer.Causal.Process as Causal
import qualified Synthesizer.Causal.Interpolation as Interpolation
import qualified Synthesizer.Interpolation.Class as Interpol
import qualified Synthesizer.State.Signal as Sig
import qualified Number.DimensionTerm as DN
import qualified Algebra.DimensionTerm as Dim
import qualified Algebra.RealField as RealField
import Control.Applicative (liftA2, )
import Foreign.Storable.Newtype as Store
import Foreign.Storable (Storable(..))
import NumericPrelude.Numeric
class
Amp.C global =>
C global parameter a b |
global parameter a -> b,
global parameter b -> a where
process ::
(Dim.C u) =>
Proc.T s u t
(CausalD.T s
(Sample.T global (RateDep s parameter), a) b)
newtype RateDep s ic = RateDep {forall s ic. RateDep s ic -> ic
unRateDep :: ic}
instance Interpol.C a ic => Interpol.C a (RateDep s ic) where
scaleAndAccumulate :: (a, RateDep s ic) -> (RateDep s ic, RateDep s ic -> RateDep s ic)
scaleAndAccumulate =
forall a x v.
C a x =>
(x -> v) -> (v -> x) -> (a, v) -> (v, v -> v)
Interpol.makeMac forall s ic. ic -> RateDep s ic
RateDep forall s ic. RateDep s ic -> ic
unRateDep
instance Storable ic => Storable (RateDep s ic) where
sizeOf :: RateDep s ic -> Int
sizeOf = forall core wrapper.
Storable core =>
(wrapper -> core) -> wrapper -> Int
Store.sizeOf forall s ic. RateDep s ic -> ic
unRateDep
alignment :: RateDep s ic -> Int
alignment = forall core wrapper.
Storable core =>
(wrapper -> core) -> wrapper -> Int
Store.alignment forall s ic. RateDep s ic -> ic
unRateDep
peek :: Ptr (RateDep s ic) -> IO (RateDep s ic)
peek = forall core wrapper.
Storable core =>
(core -> wrapper) -> Ptr wrapper -> IO wrapper
Store.peek forall s ic. ic -> RateDep s ic
RateDep
poke :: Ptr (RateDep s ic) -> RateDep s ic -> IO ()
poke = forall core wrapper.
Storable core =>
(wrapper -> core) -> Ptr wrapper -> wrapper -> IO ()
Store.poke forall s ic. RateDep s ic -> ic
unRateDep
type Signal s ecAmp ec =
SigA.T (Rate.Phantom s) ecAmp (Sig.T ec)
{-# INLINE runSynchronous1 #-}
runSynchronous1 ::
(C global parameter sampleIn sampleOut, Dim.C u,
Amp.C ecAmp) =>
Proc.T s u t
(MapD.T
(Sample.T ecAmp ec)
(Sample.T global (RateDep s parameter))) ->
Proc.T s u t
(Signal s ecAmp ec ->
CausalD.T s sampleIn sampleOut)
runSynchronous1 :: forall global parameter sampleIn sampleOut u ecAmp s t ec.
(C global parameter sampleIn sampleOut, C u, C ecAmp) =>
T s u t (T (T ecAmp ec) (T global (RateDep s parameter)))
-> T s u t (Signal s ecAmp ec -> T s sampleIn sampleOut)
runSynchronous1 =
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
(\T s (T global (RateDep s parameter), sampleIn) sampleOut
proc T (T ecAmp ec) (T global (RateDep s parameter))
causal ->
forall (sig :: * -> *) yv s amp restSampleIn restSampleOut.
Read sig yv =>
T s (T amp yv, restSampleIn) restSampleOut
-> T (Phantom s) amp (sig yv) -> T s restSampleIn restSampleOut
CausalD.applyFst T s (T global (RateDep s parameter), sampleIn) sampleOut
proc forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp ec) (T global (RateDep s parameter))
causal)
forall global parameter a b u s t.
(C global parameter a b, C u) =>
T s u t (T s (T global (RateDep s parameter), a) b)
process
{-# INLINE runSynchronous2 #-}
runSynchronous2 ::
(C global parameter sampleIn sampleOut, Dim.C u,
Amp.C ecAmp0, Amp.C ecAmp1) =>
Proc.T s u t
(MapD.T
(Sample.T ecAmp0 ec0, Sample.T ecAmp1 ec1)
(Sample.T global (RateDep s parameter))) ->
Proc.T s u t
(Signal s ecAmp0 ec0 ->
Signal s ecAmp1 ec1 ->
CausalD.T s sampleIn sampleOut)
runSynchronous2 :: forall global parameter sampleIn sampleOut u ecAmp0 ecAmp1 s t ec0
ec1.
(C global parameter sampleIn sampleOut, C u, C ecAmp0, C ecAmp1) =>
T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s parameter)))
-> T s
u
t
(Signal s ecAmp0 ec0
-> Signal s ecAmp1 ec1 -> T s sampleIn sampleOut)
runSynchronous2 T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s parameter)))
causalp =
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
(\T s (T global (RateDep s parameter), sampleIn) sampleOut
proc T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s parameter))
causal Signal s ecAmp0 ec0
x Signal s ecAmp1 ec1
y ->
forall (sig :: * -> *) yv s amp restSampleIn restSampleOut.
Read sig yv =>
T s (T amp yv, restSampleIn) restSampleOut
-> T (Phantom s) amp (sig yv) -> T s restSampleIn restSampleOut
CausalD.applyFst T s (T global (RateDep s parameter), sampleIn) sampleOut
proc forall a b. (a -> b) -> a -> b
$
forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s parameter))
causal forall a b. (a -> b) -> a -> b
$
forall (sig :: * -> *) y1 y0 s amp0 amp1.
(Transform sig y1, Transform sig (y0, y1), Read sig y0) =>
T (Phantom s) amp0 (sig y0)
-> T (Phantom s) amp1 (sig y1)
-> T (Phantom s) (amp0, amp1) (sig (y0, y1))
SigA.zip Signal s ecAmp0 ec0
x Signal s ecAmp1 ec1
y)
forall global parameter a b u s t.
(C global parameter a b, C u) =>
T s u t (T s (T global (RateDep s parameter), a) b)
process T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s parameter)))
causalp
resample ::
(Amp.C amp, Dim.C u, RealField.C t) =>
Interpolation.T t y ->
SigA.T (Rate.Dimensional u t) amp (Sig.T y) ->
Proc.T s u t
(SigA.T (Rate.Phantom s) amp (Sig.T y))
resample :: forall amp u t y s.
(C amp, C u, C t) =>
T t y
-> T (Dimensional u t) amp (T y)
-> T s u t (T (Phantom s) amp (T y))
resample T t y
ip T (Dimensional u t) amp (T y)
sig =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
(\t
k ->
forall rate amplitude body.
rate -> amplitude -> body -> T rate amplitude body
SigA.Cons
forall s. Phantom s
Rate.Phantom
(forall rate amplitude body. T rate amplitude body -> amplitude
SigA.amplitude T (Dimensional u t) amp (T y)
sig)
(forall a b. T a b -> a -> T b
Causal.applyConst
(forall t y. C t => T t y -> t -> T y -> T t y
Interpolation.relativeConstantPad T t y
ip forall a. C a => a
zero (forall rate amplitude body. T rate amplitude body -> body
SigA.body T (Dimensional u t) amp (T y)
sig)) t
k))
(forall t u s. (C t, C u) => T (Recip u) t -> T s u t t
Proc.toFrequencyScalar (forall rate amp sig. T (Actual rate) amp sig -> rate
SigA.actualSampleRate T (Dimensional u t) amp (T y)
sig))
{-# INLINE zipRate #-}
zipRate ::
(Amp.C amp0, Amp.C amp1, Eq t) =>
SigA.T (Rate.Dimensional u t) amp0 (Sig.T y0) ->
SigA.T (Rate.Dimensional u t) amp1 (Sig.T y1) ->
SigA.T (Rate.Dimensional u t) (amp0,amp1) (Sig.T (y0,y1))
zipRate :: forall amp0 amp1 t u y0 y1.
(C amp0, C amp1, Eq t) =>
T (Dimensional u t) amp0 (T y0)
-> T (Dimensional u t) amp1 (T y1)
-> T (Dimensional u t) (amp0, amp1) (T (y0, y1))
zipRate T (Dimensional u t) amp0 (T y0)
x T (Dimensional u t) amp1 (T y1)
y =
forall rate amplitude body.
rate -> amplitude -> body -> T rate amplitude body
SigA.Cons
(forall rate. rate -> Actual rate
Rate.Actual forall a b. (a -> b) -> a -> b
$
forall rate. Eq rate => String -> rate -> rate -> rate
Rate.common String
"ControlledProcess.zipRate"
(forall rate amp sig. T (Actual rate) amp sig -> rate
SigA.actualSampleRate T (Dimensional u t) amp0 (T y0)
x) (forall rate amp sig. T (Actual rate) amp sig -> rate
SigA.actualSampleRate T (Dimensional u t) amp1 (T y1)
y))
(forall rate amplitude body. T rate amplitude body -> amplitude
SigA.amplitude T (Dimensional u t) amp0 (T y0)
x, forall rate amplitude body. T rate amplitude body -> amplitude
SigA.amplitude T (Dimensional u t) amp1 (T y1)
y)
(forall a b. T a -> T b -> T (a, b)
Sig.zip (forall rate amplitude body. T rate amplitude body -> body
SigA.body T (Dimensional u t) amp0 (T y0)
x) (forall rate amplitude body. T rate amplitude body -> body
SigA.body T (Dimensional u t) amp1 (T y1)
y))
{-# INLINE runAsynchronous #-}
runAsynchronous ::
(C global ic sampleIn sampleOut,
Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
SigA.T (Rate.Dimensional u t) global (Sig.T (RateDep s ic)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
runAsynchronous :: forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip T (Dimensional u t) global (T (RateDep s ic))
sig =
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (sig :: * -> *) yv s amp restSampleIn restSampleOut.
Read sig yv =>
T s (T amp yv, restSampleIn) restSampleOut
-> T (Phantom s) amp (sig yv) -> T s restSampleIn restSampleOut
CausalD.applyFst forall global parameter a b u s t.
(C global parameter a b, C u) =>
T s u t (T s (T global (RateDep s parameter), a) b)
process (forall amp u t y s.
(C amp, C u, C t) =>
T t y
-> T (Dimensional u t) amp (T y)
-> T s u t (T (Phantom s) amp (T y))
resample T t (RateDep s ic)
ip T (Dimensional u t) global (T (RateDep s ic))
sig)
{-# INLINE runAsynchronousBuffered #-}
runAsynchronousBuffered ::
(C global ic sampleIn sampleOut,
Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
SigA.T (Rate.Dimensional u t) global (Sig.T (RateDep s ic)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
runAsynchronousBuffered :: forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronousBuffered T t (RateDep s ic)
ip =
forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall sig0 sig1 rate amp.
(sig0 -> sig1) -> T rate amp sig0 -> T rate amp sig1
SigA.processBody (forall y. [y] -> T y
Sig.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall y. T y -> [y]
Sig.toList)
{-# INLINE runAsynchronous1 #-}
runAsynchronous1 ::
(C global ic sampleIn sampleOut,
Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp ec)
(Sample.T global (RateDep s ic))) ->
SigA.T (Rate.Dimensional u t) ecAmp (Sig.T ec) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
runAsynchronous1 :: forall global ic sampleIn sampleOut u t s ecAmp ec.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
-> T (Dimensional u t) ecAmp (T ec)
-> T s u t (T s sampleIn sampleOut)
runAsynchronous1 T t (RateDep s ic)
ip T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp T (Dimensional u t) ecAmp (T ec)
sig =
T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp ec) (T global (RateDep s ic))
p -> forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip (forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp ec) (T global (RateDep s ic))
p T (Dimensional u t) ecAmp (T ec)
sig)
{-# INLINE runAsynchronousBuffered1 #-}
runAsynchronousBuffered1 ::
(C global ic sampleIn sampleOut,
Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp ec)
(Sample.T global (RateDep s ic))) ->
SigA.T (Rate.Dimensional u t) ecAmp (Sig.T ec) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
runAsynchronousBuffered1 :: forall global ic sampleIn sampleOut u t s ecAmp ec.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
-> T (Dimensional u t) ecAmp (T ec)
-> T s u t (T s sampleIn sampleOut)
runAsynchronousBuffered1 T t (RateDep s ic)
ip T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp T (Dimensional u t) ecAmp (T ec)
sig =
T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp ec) (T global (RateDep s ic))
p -> forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronousBuffered T t (RateDep s ic)
ip (forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp ec) (T global (RateDep s ic))
p T (Dimensional u t) ecAmp (T ec)
sig)
{-# INLINE processAsynchronous1 #-}
processAsynchronous1 ::
(
C global ic sampleIn sampleOut,
Amp.C ecAmp, Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp ec)
(Sample.T global (RateDep s ic))) ->
DN.T (Dim.Recip u) t ->
(forall r. Proc.T r u t (Signal r ecAmp ec)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
processAsynchronous1 :: forall global ic sampleIn sampleOut ecAmp u t s ec.
(C global ic sampleIn sampleOut, C ecAmp, C u, C t) =>
T t (RateDep s ic)
-> T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
-> T (Recip u) t
-> (forall r. T r u t (Signal r ecAmp ec))
-> T s u t (T s sampleIn sampleOut)
processAsynchronous1 T t (RateDep s ic)
ip T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp T (Recip u) t
rate forall r. T r u t (Signal r ecAmp ec)
sig =
T s u t (T (T ecAmp ec) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp ec) (T global (RateDep s ic))
p -> forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip (forall u t amp sig.
C u =>
T (Recip u) t
-> (forall s. T s u t (T (Phantom s) amp sig))
-> T (Dimensional u t) amp sig
SigA.render T (Recip u) t
rate (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp ec) (T global (RateDep s ic))
p) forall r. T r u t (Signal r ecAmp ec)
sig))
{-# INLINE runAsynchronous2 #-}
runAsynchronous2 ::
(C global ic sampleIn sampleOut,
Amp.C ecAmp0, Amp.C ecAmp1, Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp0 ec0, Sample.T ecAmp1 ec1)
(Sample.T global (RateDep s ic))) ->
SigA.T (Rate.Dimensional u t) (ecAmp0) (Sig.T ec0) ->
SigA.T (Rate.Dimensional u t) (ecAmp1) (Sig.T ec1) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
runAsynchronous2 :: forall global ic sampleIn sampleOut ecAmp0 ecAmp1 u t s ec0 ec1.
(C global ic sampleIn sampleOut, C ecAmp0, C ecAmp1, C u, C t) =>
T t (RateDep s ic)
-> T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
-> T (Dimensional u t) ecAmp0 (T ec0)
-> T (Dimensional u t) ecAmp1 (T ec1)
-> T s u t (T s sampleIn sampleOut)
runAsynchronous2 T t (RateDep s ic)
ip T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp T (Dimensional u t) ecAmp0 (T ec0)
x T (Dimensional u t) ecAmp1 (T ec1)
y =
T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p ->
forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip forall a b. (a -> b) -> a -> b
$ forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p forall a b. (a -> b) -> a -> b
$ forall amp0 amp1 t u y0 y1.
(C amp0, C amp1, Eq t) =>
T (Dimensional u t) amp0 (T y0)
-> T (Dimensional u t) amp1 (T y1)
-> T (Dimensional u t) (amp0, amp1) (T (y0, y1))
zipRate T (Dimensional u t) ecAmp0 (T ec0)
x T (Dimensional u t) ecAmp1 (T ec1)
y
{-# INLINE processAsynchronous2 #-}
processAsynchronous2 ::
(C global ic sampleIn sampleOut,
Amp.C ecAmp0, Amp.C ecAmp1, Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp0 ec0, Sample.T ecAmp1 ec1)
(Sample.T global (RateDep s ic))) ->
DN.T (Dim.Recip u) t ->
(forall r. Proc.T r u t (Signal r ecAmp0 ec0)) ->
(forall r. Proc.T r u t (Signal r ecAmp1 ec1)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
processAsynchronous2 :: forall global ic sampleIn sampleOut ecAmp0 ecAmp1 u t s ec0 ec1.
(C global ic sampleIn sampleOut, C ecAmp0, C ecAmp1, C u, C t) =>
T t (RateDep s ic)
-> T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
-> T (Recip u) t
-> (forall r. T r u t (Signal r ecAmp0 ec0))
-> (forall r. T r u t (Signal r ecAmp1 ec1))
-> T s u t (T s sampleIn sampleOut)
processAsynchronous2 T t (RateDep s ic)
ip T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp T (Recip u) t
rate forall r. T r u t (Signal r ecAmp0 ec0)
x forall r. T r u t (Signal r ecAmp1 ec1)
y =
T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p ->
forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronous T t (RateDep s ic)
ip
(forall u t amp sig.
C u =>
T (Recip u) t
-> (forall s. T s u t (T (Phantom s) amp sig))
-> T (Dimensional u t) amp sig
SigA.render T (Recip u) t
rate (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (sig :: * -> *) y1 y0 s amp0 amp1.
(Transform sig y1, Transform sig (y0, y1), Read sig y0) =>
T (Phantom s) amp0 (sig y0)
-> T (Phantom s) amp1 (sig y1)
-> T (Phantom s) (amp0, amp1) (sig (y0, y1))
SigA.zip forall r. T r u t (Signal r ecAmp0 ec0)
x forall r. T r u t (Signal r ecAmp1 ec1)
y))
{-# INLINE _processAsynchronousNaive2 #-}
_processAsynchronousNaive2 ::
(C global ic sampleIn sampleOut,
Amp.C ecAmp0, Amp.C ecAmp1, Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp0 ec0, Sample.T ecAmp1 ec1)
(Sample.T global (RateDep s ic))) ->
DN.T (Dim.Recip u) t ->
(forall r. Proc.T r u t (Signal r ecAmp0 ec0)) ->
(forall r. Proc.T r u t (Signal r ecAmp1 ec1)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
_processAsynchronousNaive2 :: forall global ic sampleIn sampleOut ecAmp0 ecAmp1 u t s ec0 ec1.
(C global ic sampleIn sampleOut, C ecAmp0, C ecAmp1, C u, C t) =>
T t (RateDep s ic)
-> T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
-> T (Recip u) t
-> (forall r. T r u t (Signal r ecAmp0 ec0))
-> (forall r. T r u t (Signal r ecAmp1 ec1))
-> T s u t (T s sampleIn sampleOut)
_processAsynchronousNaive2 T t (RateDep s ic)
ip T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp T (Recip u) t
rate forall r. T r u t (Signal r ecAmp0 ec0)
x forall r. T r u t (Signal r ecAmp1 ec1)
y =
forall global ic sampleIn sampleOut ecAmp0 ecAmp1 u t s ec0 ec1.
(C global ic sampleIn sampleOut, C ecAmp0, C ecAmp1, C u, C t) =>
T t (RateDep s ic)
-> T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
-> T (Dimensional u t) ecAmp0 (T ec0)
-> T (Dimensional u t) ecAmp1 (T ec1)
-> T s u t (T s sampleIn sampleOut)
runAsynchronous2 T t (RateDep s ic)
ip T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp
(forall u t amp sig.
C u =>
T (Recip u) t
-> (forall s. T s u t (T (Phantom s) amp sig))
-> T (Dimensional u t) amp sig
SigA.render T (Recip u) t
rate forall r. T r u t (Signal r ecAmp0 ec0)
x) (forall u t amp sig.
C u =>
T (Recip u) t
-> (forall s. T s u t (T (Phantom s) amp sig))
-> T (Dimensional u t) amp sig
SigA.render T (Recip u) t
rate forall r. T r u t (Signal r ecAmp1 ec1)
y)
{-# INLINE processAsynchronousBuffered2 #-}
processAsynchronousBuffered2 ::
(
C global ic sampleIn sampleOut,
Amp.C ecAmp0, Amp.C ecAmp1, Dim.C u, RealField.C t) =>
Interpolation.T t (RateDep s ic) ->
Proc.T s u t
(MapD.T
(Sample.T ecAmp0 ec0, Sample.T ecAmp1 ec1)
(Sample.T global (RateDep s ic))) ->
DN.T (Dim.Recip u) t ->
(forall r. Proc.T r u t (Signal r ecAmp0 ec0)) ->
(forall r. Proc.T r u t (Signal r ecAmp1 ec1)) ->
Proc.T s u t (CausalD.T s sampleIn sampleOut)
processAsynchronousBuffered2 :: forall global ic sampleIn sampleOut ecAmp0 ecAmp1 u t s ec0 ec1.
(C global ic sampleIn sampleOut, C ecAmp0, C ecAmp1, C u, C t) =>
T t (RateDep s ic)
-> T s
u
t
(T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
-> T (Recip u) t
-> (forall r. T r u t (Signal r ecAmp0 ec0))
-> (forall r. T r u t (Signal r ecAmp1 ec1))
-> T s u t (T s sampleIn sampleOut)
processAsynchronousBuffered2 T t (RateDep s ic)
ip T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp T (Recip u) t
rate forall r. T r u t (Signal r ecAmp0 ec0)
x forall r. T r u t (Signal r ecAmp1 ec1)
y =
T s u t (T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic)))
cp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p ->
forall global ic sampleIn sampleOut u t s.
(C global ic sampleIn sampleOut, C u, C t) =>
T t (RateDep s ic)
-> T (Dimensional u t) global (T (RateDep s ic))
-> T s u t (T s sampleIn sampleOut)
runAsynchronousBuffered T t (RateDep s ic)
ip
(forall u t amp sig.
C u =>
T (Recip u) t
-> (forall s. T s u t (T (Phantom s) amp sig))
-> T (Dimensional u t) amp sig
SigA.render T (Recip u) t
rate (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (sig :: * -> *) sample0 sample1 (arrow :: * -> * -> *) rate.
(Transform sig (Displacement sample0),
Transform sig (Displacement sample1), Applicable arrow rate) =>
T arrow sample0 sample1
-> T rate (Amplitude sample0) (sig (Displacement sample0))
-> T rate (Amplitude sample1) (sig (Displacement sample1))
ArrowD.apply T (T ecAmp0 ec0, T ecAmp1 ec1) (T global (RateDep s ic))
p) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (sig :: * -> *) y1 y0 s amp0 amp1.
(Transform sig y1, Transform sig (y0, y1), Read sig y0) =>
T (Phantom s) amp0 (sig y0)
-> T (Phantom s) amp1 (sig y1)
-> T (Phantom s) (amp0, amp1) (sig (y0, y1))
SigA.zip forall r. T r u t (Signal r ecAmp0 ec0)
x forall r. T r u t (Signal r ecAmp1 ec1)
y))