module Sound.DF.Audition where
import Sound.DF.CGen
import Sound.DF.Node
import Sound.OpenSoundControl
import System.Directory
import System.FilePath
b_alloc :: Int -> Int -> OSC
b_alloc b n = Message "/b_alloc" [Int b, Int n]
g_load :: Int -> String -> OSC
g_load i s = Message "/g_load" [Int i, String s]
g_unload :: Int -> OSC
g_unload i = Message "/g_unload" [Int i]
with_jack_dl :: (UDP -> IO a) -> IO a
with_jack_dl = withTransport (openUDP "127.0.0.1" 57190)
audition :: [OSC] -> Node -> IO ()
audition is n =
do t <- getTemporaryDirectory
k <- generateID
let fn = t </> ("audition" ++ show k)
dl_gen fn n
with_jack_dl (\fd -> mapM (send fd) is)
with_jack_dl (\fd -> send fd (g_load 0 (fn <.> "so")))