module Sound.Sc3.Server.Synthdef where
import qualified Data.ByteString.Lazy as L
import qualified Sound.Sc3.Ugen.Graph as Graph
import qualified Sound.Sc3.Ugen.Help.Graph as Help.Graph
import qualified Sound.Sc3.Ugen.Ugen as Ugen
import qualified Sound.Sc3.Server.Graphdef as Graphdef
import qualified Sound.Sc3.Server.Graphdef.Binary as Graphdef.Binary
import qualified Sound.Sc3.Server.Graphdef.Graph as Graphdef.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
$c== :: Synthdef -> Synthdef -> Bool
== :: Synthdef -> Synthdef -> Bool
$c/= :: Synthdef -> Synthdef -> Bool
/= :: 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
$cshowsPrec :: Int -> Synthdef -> ShowS
showsPrec :: Int -> Synthdef -> ShowS
$cshow :: Synthdef -> String
show :: Synthdef -> String
$cshowList :: [Synthdef] -> ShowS
showList :: [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 -> Graph.U_Graph
synthdefGraph :: Synthdef -> U_Graph
synthdefGraph = Ugen -> U_Graph
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 -> Param1) -> [U_Node] -> Param
forall a b. (a -> b) -> [a] -> [b]
map (\U_Node
n -> (U_Node -> String
Graph.u_node_k_name U_Node
n, U_Node -> Sample
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]
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
Graphdef.Graph.graph_to_graphdef String
nm (Ugen -> U_Graph
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.Binary.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.Binary.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.Binary.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]
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
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