-- | Data types for enumerated and non signal unit generator inputs.
module Sound.Sc3.Common.Enum where

-- * Loop

-- | Loop indicator input.
data Loop t =
    NoLoop -- ^ 0
  | Loop -- ^ 1
  | WithLoop t
  deriving (Loop t -> Loop t -> Bool
forall t. Eq t => Loop t -> Loop t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Loop t -> Loop t -> Bool
$c/= :: forall t. Eq t => Loop t -> Loop t -> Bool
== :: Loop t -> Loop t -> Bool
$c== :: forall t. Eq t => Loop t -> Loop t -> Bool
Eq, Int -> Loop t -> ShowS
forall t. Show t => Int -> Loop t -> ShowS
forall t. Show t => [Loop t] -> ShowS
forall t. Show t => Loop t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Loop t] -> ShowS
$cshowList :: forall t. Show t => [Loop t] -> ShowS
show :: Loop t -> String
$cshow :: forall t. Show t => Loop t -> String
showsPrec :: Int -> Loop t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> Loop t -> ShowS
Show)

-- | Apply /f/ at 'WithLoop'.
loop_map :: (t -> u) -> Loop t -> Loop u
loop_map :: forall t u. (t -> u) -> Loop t -> Loop u
loop_map t -> u
f Loop t
lp =
  case Loop t
lp of
    Loop t
NoLoop -> forall t. Loop t
NoLoop
    Loop t
Loop -> forall t. Loop t
Loop
    WithLoop t
t -> forall t. t -> Loop t
WithLoop (t -> u
f t
t)

-- | fmap is 'loop_map'
instance Functor Loop where
  fmap :: forall t u. (t -> u) -> Loop t -> Loop u
fmap = forall t u. (t -> u) -> Loop t -> Loop u
loop_map

-- | Resolve 'Loop'.
from_loop :: Num t => Loop t -> t
from_loop :: forall t. Num t => Loop t -> t
from_loop Loop t
e =
    case Loop t
e of
      Loop t
NoLoop -> t
0
      Loop t
Loop -> t
1
      WithLoop t
u -> t
u

-- * Interpolation

-- | Interpolation indicator input.
data Interpolation t =
    NoInterpolation
  | LinearInterpolation
  | CubicInterpolation
  | WithInterpolation t
  deriving (Interpolation t -> Interpolation t -> Bool
forall t. Eq t => Interpolation t -> Interpolation t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Interpolation t -> Interpolation t -> Bool
$c/= :: forall t. Eq t => Interpolation t -> Interpolation t -> Bool
== :: Interpolation t -> Interpolation t -> Bool
$c== :: forall t. Eq t => Interpolation t -> Interpolation t -> Bool
Eq, Int -> Interpolation t -> ShowS
forall t. Show t => Int -> Interpolation t -> ShowS
forall t. Show t => [Interpolation t] -> ShowS
forall t. Show t => Interpolation t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interpolation t] -> ShowS
$cshowList :: forall t. Show t => [Interpolation t] -> ShowS
show :: Interpolation t -> String
$cshow :: forall t. Show t => Interpolation t -> String
showsPrec :: Int -> Interpolation t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> Interpolation t -> ShowS
Show)

-- | Resolve 'Interpolation'.
from_interpolation :: Num t => Interpolation t -> t
from_interpolation :: forall t. Num t => Interpolation t -> t
from_interpolation Interpolation t
e =
    case Interpolation t
e of
      Interpolation t
NoInterpolation -> t
1
      Interpolation t
LinearInterpolation -> t
2
      Interpolation t
CubicInterpolation -> t
4
      WithInterpolation t
u -> t
u

-- * DoneAction

-- | Completion mode indicator input.
data DoneAction t
  = DoNothing
  | PauseSynth
  | RemoveSynth
  | RemoveGroup
  | WithDoneAction t
  deriving (DoneAction t -> DoneAction t -> Bool
forall t. Eq t => DoneAction t -> DoneAction t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoneAction t -> DoneAction t -> Bool
$c/= :: forall t. Eq t => DoneAction t -> DoneAction t -> Bool
== :: DoneAction t -> DoneAction t -> Bool
$c== :: forall t. Eq t => DoneAction t -> DoneAction t -> Bool
Eq, Int -> DoneAction t -> ShowS
forall t. Show t => Int -> DoneAction t -> ShowS
forall t. Show t => [DoneAction t] -> ShowS
forall t. Show t => DoneAction t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DoneAction t] -> ShowS
$cshowList :: forall t. Show t => [DoneAction t] -> ShowS
show :: DoneAction t -> String
$cshow :: forall t. Show t => DoneAction t -> String
showsPrec :: Int -> DoneAction t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> DoneAction t -> ShowS
Show)

-- | Apply /f/ at 'WithDoneAction'.
done_action_map :: (t -> u) -> DoneAction t -> DoneAction u
done_action_map :: forall t u. (t -> u) -> DoneAction t -> DoneAction u
done_action_map t -> u
f DoneAction t
e =
    case DoneAction t
e of
      DoneAction t
DoNothing -> forall t. DoneAction t
DoNothing
      DoneAction t
PauseSynth -> forall t. DoneAction t
PauseSynth
      DoneAction t
RemoveSynth -> forall t. DoneAction t
RemoveSynth
      DoneAction t
RemoveGroup -> forall t. DoneAction t
RemoveGroup
      WithDoneAction t
x -> forall t. t -> DoneAction t
WithDoneAction (t -> u
f t
x)

-- | fmap is 'done_action_map'
instance Functor DoneAction where
  fmap :: forall t u. (t -> u) -> DoneAction t -> DoneAction u
fmap = forall t u. (t -> u) -> DoneAction t -> DoneAction u
done_action_map

-- | Resolve 'DoneAction'.
from_done_action :: Num t => DoneAction t -> t
from_done_action :: forall t. Num t => DoneAction t -> t
from_done_action DoneAction t
e =
    case DoneAction t
e of
      DoneAction t
DoNothing -> t
0
      DoneAction t
PauseSynth -> t
1
      DoneAction t
RemoveSynth -> t
2
      DoneAction t
RemoveGroup -> t
14
      WithDoneAction t
x -> t
x

-- * Warp

-- | Warp interpolation indicator input.
data Warp t =
    Linear
  | Exponential
  | WithWarp t
  deriving (Warp t -> Warp t -> Bool
forall t. Eq t => Warp t -> Warp t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Warp t -> Warp t -> Bool
$c/= :: forall t. Eq t => Warp t -> Warp t -> Bool
== :: Warp t -> Warp t -> Bool
$c== :: forall t. Eq t => Warp t -> Warp t -> Bool
Eq, Int -> Warp t -> ShowS
forall t. Show t => Int -> Warp t -> ShowS
forall t. Show t => [Warp t] -> ShowS
forall t. Show t => Warp t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Warp t] -> ShowS
$cshowList :: forall t. Show t => [Warp t] -> ShowS
show :: Warp t -> String
$cshow :: forall t. Show t => Warp t -> String
showsPrec :: Int -> Warp t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> Warp t -> ShowS
Show)

-- | Resolve 'Warp'.
--
-- > map from_warp [Linear,Exponential] == [0,1]
from_warp :: Num t => Warp t -> t
from_warp :: forall t. Num t => Warp t -> t
from_warp Warp t
e =
    case Warp t
e of
      Warp t
Linear -> t
0
      Warp t
Exponential -> t
1
      WithWarp t
u -> t
u

-- | Apply /f/ at 'WithWarp'
warp_map :: (t -> u) -> Warp t -> Warp u
warp_map :: forall t u. (t -> u) -> Warp t -> Warp u
warp_map t -> u
f Warp t
e =
    case Warp t
e of
      Warp t
Linear -> forall t. Warp t
Linear
      Warp t
Exponential -> forall t. Warp t
Exponential
      WithWarp t
u -> forall t. t -> Warp t
WithWarp (t -> u
f t
u)

-- | fmap = 'warp_map'
instance Functor Warp where
  fmap :: forall t u. (t -> u) -> Warp t -> Warp u
fmap = forall t u. (t -> u) -> Warp t -> Warp u
warp_map

-- * Buffer

-- | Unification of integer and 'Ugen' buffer identifiers.
data Buffer t =
    Buffer_Id Int
  | Buffer t
  deriving (Buffer t -> Buffer t -> Bool
forall t. Eq t => Buffer t -> Buffer t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Buffer t -> Buffer t -> Bool
$c/= :: forall t. Eq t => Buffer t -> Buffer t -> Bool
== :: Buffer t -> Buffer t -> Bool
$c== :: forall t. Eq t => Buffer t -> Buffer t -> Bool
Eq, Int -> Buffer t -> ShowS
forall t. Show t => Int -> Buffer t -> ShowS
forall t. Show t => [Buffer t] -> ShowS
forall t. Show t => Buffer t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Buffer t] -> ShowS
$cshowList :: forall t. Show t => [Buffer t] -> ShowS
show :: Buffer t -> String
$cshow :: forall t. Show t => Buffer t -> String
showsPrec :: Int -> Buffer t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> Buffer t -> ShowS
Show)