-- | OSC
module CsoundExpr.Opcodes.OSCNetwork.OSC
    (oscInit,
     oscListen,
     oscSend)
where



import CsoundExpr.Base.Types
import CsoundExpr.Base.MultiOut
import CsoundExpr.Base.SideEffect
import CsoundExpr.Base.UserDefined



-- | * opcode : OSCinit
--  
--  
-- * syntax : 
--  
--  >   ihandle OSCinit iport
--  
--  
-- * description : 
--  
--  Starts a listening process, which can be used by OSClisten.
--  
--  
-- * url : <http://www.csounds.com/manual/html/OSCinit.html>
 
oscInit :: Irate -> Irate
oscInit i0port = opcode "OSCinit" args
  where args = [to i0port]


-- | * opcode : OSClisten
--  
--  
-- * syntax : 
--  
--  >   kans OSClisten ihandle, idest, itype [, xdata1, xdata2,...]
--  
--  
-- * description : 
--  
--  On each k-cycle looks to see if an OSC message has been send to
-- a given path of a given type.
--  
--  
-- * url : <http://www.csounds.com/manual/html/OSClisten.html>
 
oscListen :: (X x0) => Irate -> Irate -> Irate -> [x0] -> Krate
oscListen i0handle i1dest i2type x3dataN = opcode "OSClisten" args
  where args = [to i0handle, to i1dest, to i2type] ++ map to x3dataN


-- | * opcode : OSCsend
--  
--  
-- * syntax : 
--  
--  >   OSCsend kwhen, ihost, iport, idestination, itype [, kdata1, kdata2,...]
--  
--  
-- * description : 
--  
--  Uses the OSC protocol to send message to other OSC listening
-- processes.
--  
--  
-- * url : <http://www.csounds.com/manual/html/OSCsend.html>
 
oscSend ::
          (K k0, K k1) =>
          k0 -> Irate -> Irate -> Irate -> Irate -> [k1] -> SignalOut
oscSend k0when i1host i2port i3destination i4type k5dataN
  = outOpcode "OSCsend" args
  where args
          = [to k0when, to i1host, to i2port, to i3destination, to i4type] ++
              map to k5dataN