{-# Language TypeFamilies #-}
module Csound.Typed.Control.Sf2(
Sf(..), unSf
) where
import Data.Boolean
import Data.Default
import Data.Text (Text)
import qualified Csound.Dynamic as D
import Csound.Typed.Types
import Csound.Typed.GlobalState
data Sf = Sf
{ Sf -> Text
sfName :: Text
, Sf -> Int
sfBank :: Int
, Sf -> Int
sfProg :: Int }
| SfId (GE E)
instance Val Sf where
fromGE :: GE E -> Sf
fromGE = GE E -> Sf
SfId
toGE :: Sf -> GE E
toGE = Sf -> GE E
unSf
unSf :: Sf -> GE E
unSf :: Sf -> GE E
unSf Sf
x = case Sf
x of
SfId GE E
a -> GE E
a
Sf Text
name Int
bank Int
prog -> (Int -> E) -> GE Int -> 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
D.int (GE Int -> GE E) -> GE Int -> GE E
forall a b. (a -> b) -> a -> b
$ SfSpec -> GE Int
saveSf (Text -> Int -> Int -> SfSpec
SfSpec Text
name Int
bank Int
prog)
instance Default Sf where
def :: Sf
def = E -> Sf
forall a. Val a => E -> a
fromE E
0
type instance BooleanOf Sf = BoolD
instance IfB Sf where ifB :: forall bool. (bool ~ BooleanOf Sf) => bool -> Sf -> Sf -> Sf
ifB = (E -> E -> E -> E) -> bool -> Sf -> Sf -> Sf
forall a b c d.
(Val a, Val b, Val c, Val d) =>
(E -> E -> E -> E) -> a -> b -> c -> d
on3 (IfRate -> E -> E -> E -> E
D.ifExp IfRate
D.IfIr)