module Sound.Sc3.Server.Nrt.Ugen where
import qualified Sound.Osc.Datum as Osc
import qualified Sound.Osc.Packet as Osc
import Sound.Sc3.Common.Rate
import Sound.Sc3.Server.Command.Plain
import Sound.Sc3.Server.Enum
import Sound.Sc3.Server.Nrt
import Sound.Sc3.Server.Nrt.Render
import Sound.Sc3.Server.Synthdef
import Sound.Sc3.Ugen.Bindings.Db
import Sound.Sc3.Ugen.Ugen
nrt_ugen_rec :: Osc.Time -> Ugen -> Nrt
nrt_ugen_rec :: Time -> Ugen -> Nrt
nrt_ugen_rec Time
dur Ugen
u =
let sg :: Ugen
sg = case Ugen -> Rate
rateOf Ugen
u of
Rate
AudioRate -> Ugen
u
Rate
ControlRate -> Ugen -> Ugen
k2a Ugen
u
Rate
_ -> forall a. HasCallStack => [Char] -> a
error [Char]
"nrt_ugen_rec: rate?"
sy :: Synthdef
sy = [Char] -> Ugen -> Synthdef
synthdef [Char]
"anonymous" (Ugen -> Ugen -> Ugen
out Ugen
0 Ugen
sg)
m0 :: Message
m0 = Synthdef -> Message
d_recv Synthdef
sy
m1 :: Message
m1 = [Char] -> Synth_Id -> AddAction -> Synth_Id -> Message
s_new0 [Char]
"anonymous" Synth_Id
1 AddAction
AddToHead Synth_Id
0
in [Bundle] -> Nrt
Nrt [Time -> [Message] -> Bundle
Osc.bundle Time
0 [Message
m0, Message
m1], Time -> [Message] -> Bundle
Osc.bundle Time
dur [Message
nrt_end]]
type Nrt_Ugen_Opt = (FilePath, FilePath, Int, SampleFormat, [String])
nrt_ugen_render :: Nrt_Ugen_Opt -> Osc.Time -> Ugen -> IO ()
nrt_ugen_render :: Nrt_Ugen_Opt -> Time -> Ugen -> IO ()
nrt_ugen_render ([Char]
osc_fn,[Char]
sf_fn,Synth_Id
sample_rate,SampleFormat
fmt,[[Char]]
opt) Time
dur Ugen
u = do
let sc :: Nrt
sc = Time -> Ugen -> Nrt
nrt_ugen_rec Time
dur Ugen
u
nc :: Synth_Id
nc = forall (t :: * -> *) a. Foldable t => t a -> Synth_Id
length (Ugen -> [Ugen]
mceChannels Ugen
u)
Nrt_Render_Plain -> Nrt -> IO ()
nrt_render_plain ([Char]
osc_fn,[Char]
sf_fn,Synth_Id
nc,Synth_Id
sample_rate,SampleFormat
fmt,[[Char]]
opt) Nrt
sc