module Vivid.SynthDef.CrazyTypes where
import Vivid.SynthDef.Types
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS8
class ToSig s where
toSig :: s -> Signal
instance ToSig Signal where
toSig = id
instance (Num a, Real a) => ToSig a where
toSig = Constant . fromRational . toRational
instance ToSig String where
toSig = Param . BS8.pack
class ToSigM s where
toSigM :: s -> SDState Signal
instance (ToSig i) => ToSigM i where
toSigM = return . toSig
instance ToSigM (SDState Signal) where
toSigM = id
class HasSynthRef a where
getSynthRef :: a -> Either ByteString SynthDef
instance HasSynthRef String where
getSynthRef = Left . BS8.pack
instance HasSynthRef SynthDef where
getSynthRef = Right