import Control.Monad {- base -}
import qualified Network.WebSockets as W {- websockets -}
import qualified U
go :: U.WithT -> W.Connection -> IO ()
go withT c = do
d <- W.receiveData c
print d
U.proc_lb withT d
json_ws :: U.WithT -> W.ServerApp
json_ws withT rq = do
c <- W.acceptRequest rq
forever (go withT c)
main :: IO ()
main = do
U.Opt t h w <- U.opt_arg
W.runServer h w (json_ws t)
{-
json-ws.00
import Sound.SC3
let {kin = in' 1 KR
;o = sinOsc AR (kin 0) 0}
in audition (out 0 (pan2 o (kin 2) (kin 1)))
json-ws.02
let {kin = in' 1 KR
;f = kin 0 * 600 + 400
;a = kin 1 * 0.1}
in audition (out 0 (sinOsc AR f 0 * a))
json-ws.03
let {k0 = control KR "k0" 440
;k1 = control KR "k1" 0
;k2 = control KR "k2" 0.1
;k3 = control KR "k3" 0}
in draw (out k3 (sinOsc AR k0 k1 * k2))
withSC3 (send (n_set (-1) [("k0",660)]))
withSC3 (send (n_set (-1) [("k2",0.01)]))
json-ws.04
withSC3 (send (dumpOSC TextPrinter))
let {c1 = control KR "c1" 60
;c2 = control KR "c2" 0
;c3 = control KR "c3" (-12)
;c4 = control KR "c4" 0}
in audition (out c4 (sinOsc AR (midiCPS c1) c2 * dbAmp c3))
-}