module Csound.Typed.Plugins.LiveRow(
  liveRow,
  liveRows
) where

import Csound.Dynamic

import Csound.Typed.Types
import Csound.Typed.GlobalState
import qualified Csound.Typed.GlobalState.Elements as E(liveRowPlugin, liveRowsPlugin)

liveRow :: D -> TabList -> D -> D -> Sig -> Tab -> Sig
liveRow :: D -> TabList -> D -> D -> Sig -> Tab -> Sig
liveRow D
iTabSize TabList
iTabs D
iBpm D
iBeatDur Sig
kUserIndex Tab
iAuxParams = 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.liveRowPlugin
  E -> E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E -> E)
-> GE E -> GE (E -> E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
forall a. Val a => a -> GE E
toGE D
iTabSize GE (E -> E -> E -> E -> E -> E)
-> GE E -> GE (E -> E -> E -> E -> E)
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TabList -> GE E
forall a. Val a => a -> GE E
toGE TabList
iTabs GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall a b. GE (a -> b) -> GE a -> GE b
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
iBpm GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall a b. GE (a -> b) -> GE a -> GE b
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
iBeatDur GE (E -> E -> E) -> GE E -> GE (E -> E)
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kUserIndex GE (E -> E) -> GE E -> GE E
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
iAuxParams
  where f :: E -> E -> E -> E -> E -> E -> E
f E
iTabSize' E
iTabs' E
iBpm' E
iBeatDur' E
kUserIndex' E
iAuxParams' = Name -> Spec1 -> [E] -> E
opcs Name
"liveRow" [(Rate
Ar, [Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Kr, Rate
Ir])] [E
iTabSize', E
iTabs', E
iBpm', E
iBeatDur', E
kUserIndex', E
iAuxParams']

liveRows :: D -> TabList -> TabList -> D -> D -> Sig -> Tab -> Sig2
liveRows :: D -> TabList -> TabList -> D -> D -> Sig -> Tab -> Sig2
liveRows D
iTabSize TabList
iLeftTabs TabList
iRightTabs D
iBpm D
iBeatDur Sig
kUserIndex Tab
iAuxParams = GE [E] -> Sig2
forall a. Tuple a => GE [E] -> a
toTuple (GE [E] -> Sig2) -> GE [E] -> Sig2
forall a b. (a -> b) -> a -> b
$ ((Int -> [E]) -> [E]) -> GE (Int -> [E]) -> GE [E]
forall a b. (a -> b) -> GE a -> GE b
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.liveRowsPlugin
  E -> E -> E -> E -> E -> E -> E -> Int -> [E]
f (E -> E -> E -> E -> E -> E -> E -> Int -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> E -> Int -> [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
forall a. Val a => a -> GE E
toGE D
iTabSize GE (E -> E -> E -> E -> E -> E -> Int -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TabList -> GE E
forall a. Val a => a -> GE E
toGE TabList
iLeftTabs GE (E -> E -> E -> E -> E -> Int -> [E])
-> GE E -> GE (E -> E -> E -> E -> Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TabList -> GE E
forall a. Val a => a -> GE E
toGE TabList
iRightTabs GE (E -> E -> E -> E -> Int -> [E])
-> GE E -> GE (E -> E -> E -> Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
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
iBpm GE (E -> E -> E -> Int -> [E]) -> GE E -> GE (E -> E -> Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
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
iBeatDur GE (E -> E -> Int -> [E]) -> GE E -> GE (E -> Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kUserIndex GE (E -> Int -> [E]) -> GE E -> GE (Int -> [E])
forall a b. GE (a -> b) -> GE a -> GE b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Tab -> GE E
forall a. Val a => a -> GE E
toGE Tab
iAuxParams
  where f :: E -> E -> E -> E -> E -> E -> E -> Int -> [E]
f E
iTabSize' E
iLeftTabs' E
iRightTabs' E
iBpm' E
iBeatDur' E
kUserIndex' E
iAuxParams' = Name -> Specs -> [E] -> Int -> [E]
mopcs Name
"liveRows" ([Rate
Ar, Rate
Ar], [Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Kr, Rate
Ir]) [E
iTabSize', E
iLeftTabs', E
iRightTabs', E
iBpm', E
iBeatDur', E
kUserIndex', E
iAuxParams']