module Sound.SC3.UGen.UGen ( Name, UGenId(..), UGen(..), Output, Special(..)
, constant, control
, mce, mce2
, mrg, mrg2
, proxy
, clone, uid ) where
import Control.Monad (liftM, replicateM)
import Sound.SC3.UGen.Rate (Rate)
import Sound.SC3.UGen.UId
type Name = String
type Output = Rate
newtype Special = Special Int deriving (Eq, Show)
newtype UGenId = UGenId Int deriving (Eq, Show)
data UGen = Constant { constantValue :: Double }
| Control { controlRate_ :: Rate
, controlName :: Name
, controlDefault :: Double }
| Primitive { ugenRate :: Rate
, ugenName :: Name
, ugenInputs :: [UGen]
, ugenOutputs :: [Output]
, ugenSpecial :: Special
, ugenId :: Maybe UGenId }
| Proxy { proxySource :: UGen
, proxyIndex :: Int }
| MCE { mceProxies :: [UGen] }
| MRG { mrgLeft :: UGen
, mrgRight :: UGen }
deriving (Eq, Show)
uid :: Int -> UGenId
uid = UGenId
constant :: (Real a) => a -> UGen
constant = Constant . realToFrac
control :: Rate -> Name -> Double -> UGen
control = Control
mce :: [UGen] -> UGen
mce = MCE
mce2 :: UGen -> UGen -> UGen
mce2 x y = mce [x, y]
mrg :: [UGen] -> UGen
mrg [] = undefined
mrg [x] = x
mrg (x:xs) = MRG x (mrg xs)
mrg2 :: UGen -> UGen -> UGen
mrg2 = MRG
proxy :: UGen -> Int -> UGen
proxy = Proxy
clone :: (UId m) => Int -> m UGen -> m UGen
clone n u = liftM mce (replicateM n u)