module Sound.SC3.Server.Synthdef where
import qualified Data.ByteString.Lazy as L
import qualified Sound.SC3.UGen.Graph as UGen.Graph
import qualified Sound.SC3.UGen.Help.Graph as Help.Graph
import qualified Sound.SC3.UGen.Type as UGen
import qualified Sound.SC3.Server.Graphdef as Graphdef
import qualified Sound.SC3.Server.Graphdef.Graph as Graph
import qualified Sound.SC3.Server.Param as Param
data Synthdef = Synthdef {Synthdef -> String
synthdefName :: String
,Synthdef -> UGen
synthdefUGen :: UGen.UGen}
deriving (Synthdef -> Synthdef -> Bool
(Synthdef -> Synthdef -> Bool)
-> (Synthdef -> Synthdef -> Bool) -> Eq Synthdef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Synthdef -> Synthdef -> Bool
$c/= :: Synthdef -> Synthdef -> Bool
== :: Synthdef -> Synthdef -> Bool
$c== :: Synthdef -> Synthdef -> Bool
Eq,Int -> Synthdef -> ShowS
[Synthdef] -> ShowS
Synthdef -> String
(Int -> Synthdef -> ShowS)
-> (Synthdef -> String) -> ([Synthdef] -> ShowS) -> Show Synthdef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Synthdef] -> ShowS
$cshowList :: [Synthdef] -> ShowS
show :: Synthdef -> String
$cshow :: Synthdef -> String
showsPrec :: Int -> Synthdef -> ShowS
$cshowsPrec :: Int -> Synthdef -> ShowS
Show)
synthdef :: String -> UGen.UGen -> Synthdef
synthdef :: String -> UGen -> Synthdef
synthdef = String -> UGen -> Synthdef
Synthdef
defaultSynthdef :: Synthdef
defaultSynthdef :: Synthdef
defaultSynthdef = String -> UGen -> Synthdef
synthdef String
"default" UGen
Help.Graph.default_ugen_graph
defaultSampler :: Bool -> Synthdef
defaultSampler :: Bool -> Synthdef
defaultSampler Bool
use_gate =
let nm :: String
nm = String
"default-sampler-" String -> ShowS
forall a. [a] -> [a] -> [a]
++ if Bool
use_gate then String
"gate" else String
"fixed"
in String -> UGen -> Synthdef
synthdef String
nm (Bool -> UGen
Help.Graph.default_sampler_ugen_graph Bool
use_gate)
synthdefGraph :: Synthdef -> UGen.Graph.U_Graph
synthdefGraph :: Synthdef -> U_Graph
synthdefGraph = UGen -> U_Graph
UGen.Graph.ugen_to_graph (UGen -> U_Graph) -> (Synthdef -> UGen) -> Synthdef -> U_Graph
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthdef -> UGen
synthdefUGen
synthdefParam :: Synthdef -> Param.Param
synthdefParam :: Synthdef -> Param
synthdefParam =
(U_Node -> (String, Sample)) -> [U_Node] -> Param
forall a b. (a -> b) -> [a] -> [b]
map (\U_Node
n -> (U_Node -> String
UGen.Graph.u_node_k_name U_Node
n,U_Node -> Sample
UGen.Graph.u_node_k_default U_Node
n)) ([U_Node] -> Param) -> (Synthdef -> [U_Node]) -> Synthdef -> Param
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
U_Graph -> [U_Node]
UGen.Graph.ug_controls (U_Graph -> [U_Node])
-> (Synthdef -> U_Graph) -> Synthdef -> [U_Node]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Synthdef -> U_Graph
synthdefGraph
synthdef_to_graphdef :: Synthdef -> Graphdef.Graphdef
synthdef_to_graphdef :: Synthdef -> Graphdef
synthdef_to_graphdef (Synthdef String
nm UGen
u) = String -> U_Graph -> Graphdef
Graph.graph_to_graphdef String
nm (UGen -> U_Graph
UGen.Graph.ugen_to_graph UGen
u)
ugen_to_graphdef :: UGen.UGen -> Graphdef.Graphdef
ugen_to_graphdef :: UGen -> Graphdef
ugen_to_graphdef = Synthdef -> Graphdef
synthdef_to_graphdef (Synthdef -> Graphdef) -> (UGen -> Synthdef) -> UGen -> Graphdef
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> UGen -> Synthdef
Synthdef String
"anonymous"
synthdefData :: Synthdef -> L.ByteString
synthdefData :: Synthdef -> ByteString
synthdefData = Graphdef -> ByteString
Graphdef.encode_graphdef (Graphdef -> ByteString)
-> (Synthdef -> Graphdef) -> Synthdef -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthdef -> Graphdef
synthdef_to_graphdef
synthdefWrite :: FilePath -> Synthdef -> IO ()
synthdefWrite :: String -> Synthdef -> IO ()
synthdefWrite String
fn = String -> Graphdef -> IO ()
Graphdef.graphdefWrite String
fn (Graphdef -> IO ()) -> (Synthdef -> Graphdef) -> Synthdef -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthdef -> Graphdef
synthdef_to_graphdef
synthdefWrite_dir :: FilePath -> Synthdef -> IO ()
synthdefWrite_dir :: String -> Synthdef -> IO ()
synthdefWrite_dir String
dir = String -> Graphdef -> IO ()
Graphdef.graphdefWrite_dir String
dir (Graphdef -> IO ()) -> (Synthdef -> Graphdef) -> Synthdef -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Synthdef -> Graphdef
synthdef_to_graphdef
synthstat_ln :: UGen.UGen -> [String]
synthstat_ln :: UGen -> [String]
synthstat_ln = U_Graph -> [String]
UGen.Graph.ug_stat_ln (U_Graph -> [String]) -> (UGen -> U_Graph) -> UGen -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UGen -> U_Graph
UGen.Graph.ugen_to_graph
synthstat :: UGen.UGen -> String
synthstat :: UGen -> String
synthstat = [String] -> String
unlines ([String] -> String) -> (UGen -> [String]) -> UGen -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UGen -> [String]
synthstat_ln
synthstat_wr :: UGen.UGen -> IO ()
synthstat_wr :: UGen -> IO ()
synthstat_wr = String -> IO ()
putStrLn (String -> IO ()) -> (UGen -> String) -> UGen -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UGen -> String
synthstat
synthstat_concise :: UGen.UGen -> String
synthstat_concise :: UGen -> String
synthstat_concise = [String] -> String
unlines ([String] -> String) -> (UGen -> [String]) -> UGen -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> [String]
forall a. [a] -> [a]
reverse ([String] -> [String]) -> (UGen -> [String]) -> UGen -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [String] -> [String]
forall a. Int -> [a] -> [a]
drop Int
1 ([String] -> [String]) -> (UGen -> [String]) -> UGen -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> [String]
forall a. [a] -> [a]
reverse ([String] -> [String]) -> (UGen -> [String]) -> UGen -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UGen -> [String]
synthstat_ln
ugen_dump_ugens :: UGen.UGen -> IO ()
ugen_dump_ugens :: UGen -> IO ()
ugen_dump_ugens = Graphdef -> IO ()
Graphdef.graphdef_dump_ugens (Graphdef -> IO ()) -> (UGen -> Graphdef) -> UGen -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UGen -> Graphdef
ugen_to_graphdef