module Sound.Sc3.Ugen.Pp where
import Data.List
import Sound.Sc3.Common.Math
import Sound.Sc3.Common.Mce
import Sound.Sc3.Ugen.Types
ugen_concise_pp :: Ugen -> String
ugen_concise_pp :: Ugen -> String
ugen_concise_pp Ugen
u =
let bracketed :: (a, a) -> [a] -> [a]
bracketed (a
l, a
r) [a]
x = a
l a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
x [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
r]
prim_pp :: Primitive t -> String
prim_pp (Primitive Rate
_ String
nm [t]
_ [Rate]
_ Special
sp UgenId
_ Brackets
_) = String -> Special -> String
ugen_user_name String
nm Special
sp
k :: Int
k = Int
5
in case Ugen
u of
Constant_U (Constant Double
n Brackets
_) -> Int -> Double -> String
real_pp Int
k Double
n
Control_U (Control Rate
_ Maybe Int
_ String
nm Double
def Bool
_ Maybe (Control_Meta Double)
_ Brackets
_) -> String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"=" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> Double -> String
real_pp Int
k Double
def
Label_U (Label String
s) -> (Char, Char) -> String -> String
forall {a}. (a, a) -> [a] -> [a]
bracketed (Char
'"', Char
'"') String
s
Primitive_U Primitive Ugen
p -> Primitive Ugen -> String
forall {t}. Primitive t -> String
prim_pp Primitive Ugen
p
Proxy_U (Proxy Primitive Ugen
p Int
n) -> Primitive Ugen -> String
forall {t}. Primitive t -> String
prim_pp Primitive Ugen
p String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"@" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
Mce_U (Mce_Scalar Ugen
s) -> Ugen -> String
ugen_concise_pp Ugen
s
Mce_U (Mce_Vector [Mce Ugen]
v) -> (Char, Char) -> String -> String
forall {a}. (a, a) -> [a] -> [a]
bracketed (Char
'[', Char
']') ([String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (String -> [String] -> [String]
forall a. a -> [a] -> [a]
intersperse String
"," ((Mce Ugen -> String) -> [Mce Ugen] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (Ugen -> String
ugen_concise_pp (Ugen -> String) -> (Mce Ugen -> Ugen) -> Mce Ugen -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mce Ugen -> Ugen
forall t. Mce t -> t
mce_scalar_value) [Mce Ugen]
v)))
Mrg_U (Mrg Ugen
l Ugen
r) -> [String] -> String
unwords [Ugen -> String
ugen_concise_pp Ugen
l, String
"&", Ugen -> String
ugen_concise_pp Ugen
r]