module Csound.Typed.Plugins.TabQueue(
tabQueue2_append, tabQueue2_delete, tabQueue2_hasElements, tabQueue2_readLastElement
) where
import Data.Boolean
import Control.Monad.Trans.Class
import Csound.Dynamic
import Csound.Typed.Types
import Csound.Typed.GlobalState
import qualified Csound.Typed.GlobalState.Elements as E(tabQueue2Plugin)
tabQueue2_append :: Tab -> (D, D) -> SE ()
tabQueue2_append :: Tab -> (D, D) -> SE ()
tabQueue2_append Tab
tab (D
pch, D
vol) = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ do
UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.tabQueue2Plugin
E -> E -> E -> E
f (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
tab GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
pch GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
vol
where f :: E -> E -> E -> E
f E
tab' E
pch' E
vol' = Name -> Spec1 -> [E] -> E
opcs Name
"TabQueue2_Append" [(Rate
Xr, [Rate
Ir, Rate
Ir, Rate
Ir])] [E
tab', E
pch', E
vol']
tabQueue2_delete :: Tab -> D -> SE ()
tabQueue2_delete :: Tab -> D -> SE ()
tabQueue2_delete Tab
tab D
pch = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ do
UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.tabQueue2Plugin
E -> E -> E
f (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
tab GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
pch
where f :: E -> E -> E
f E
tab' E
pch' = Name -> Spec1 -> [E] -> E
opcs Name
"TabQueue2_Delete" [(Rate
Xr, [Rate
Ir, Rate
Ir])] [E
tab', E
pch']
tabQueue2_hasElements :: Tab -> BoolSig
tabQueue2_hasElements :: Tab -> BoolSig
tabQueue2_hasElements = (Sig -> Sig -> BoolSig
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
1) (Sig -> BoolSig) -> (Tab -> Sig) -> Tab -> BoolSig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tab -> Sig
tabQueue2_hasElements'
tabQueue2_hasElements' :: Tab -> Sig
tabQueue2_hasElements' :: Tab -> Sig
tabQueue2_hasElements' Tab
tab = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.tabQueue2Plugin
E -> E
f (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
tab
where f :: E -> E
f E
tab' = Name -> Spec1 -> [E] -> E
opcs Name
"TabQueue2_HasElements" [(Rate
Kr, [Rate
Ir])] [E
tab']
tabQueue2_readLastElement :: Tab -> (Sig, Sig)
tabQueue2_readLastElement :: Tab -> (Sig, Sig)
tabQueue2_readLastElement Tab
tab = GE [E] -> (Sig, Sig)
forall a. Tuple a => GE [E] -> a
toTuple (GE [E] -> (Sig, Sig)) -> GE [E] -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ ((Int -> [E]) -> [E]) -> GE (Int -> [E]) -> GE [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
2) (GE (Int -> [E]) -> GE [E]) -> GE (Int -> [E]) -> GE [E]
forall a b. (a -> b) -> a -> b
$ do
UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.tabQueue2Plugin
E -> Int -> [E]
f (E -> Int -> [E]) -> GE E -> GE (Int -> [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
tab
where f :: E -> Int -> [E]
f E
tab' = Name -> Specs -> [E] -> Int -> [E]
mopcs Name
"TabQueue2_ReadLastElement" ([Rate
Kr, Rate
Kr], [Rate
Ir]) [E
tab']