-- | Real-time Performance Control
module CsoundExpr.Opcodes.Control.Realtime
    (activeI,
     activeK,
     cpuprc,
     maxalloc,
     preallocI,
     preallocS,
     jacktransport)
where



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



-- | * opcode : active
--  
--  
-- * syntax : 
--  
--  >   ir active insnum
--  >   kres active kinsnum
--  
--  
-- * description : 
--  
--  Returns the number of active instances of an instrument.
--  
--  
-- * url : <http://www.csounds.com/manual/html/active.html>
 
activeI :: Irate -> Irate
activeI i0nsnum = opcode "active" args
  where args = [to i0nsnum]


-- | * opcode : active
--  
--  
-- * syntax : 
--  
--  >   ir active insnum
--  >   kres active kinsnum
--  
--  
-- * description : 
--  
--  Returns the number of active instances of an instrument.
--  
--  
-- * url : <http://www.csounds.com/manual/html/active.html>
 
activeK :: (K k0) => k0 -> Krate
activeK k0insnum = opcode "active" args
  where args = [to k0insnum]


-- | * opcode : cpuprc
--  
--  
-- * syntax : 
--  
--  >   cpuprc insnum, ipercent
--  
--  
-- * description : 
--  
--  Control allocation of cpu resources on a per-instrument basis,
-- to optimize realtime output.
--  
--  
-- * url : <http://www.csounds.com/manual/html/cpuprc.html>
 
cpuprc :: Irate -> Irate -> SignalOut
cpuprc i0nsnum i1percent = outOpcode "cpuprc" args
  where args = [to i0nsnum, to i1percent]


-- | * opcode : maxalloc
--  
--  
-- * syntax : 
--  
--  >   maxalloc insnum, icount
--  
--  
-- * description : 
--  
--  Limits the number of allocations of an instrument.
--  
--  
-- * url : <http://www.csounds.com/manual/html/maxalloc.html>
 
maxalloc :: Irate -> Irate -> SignalOut
maxalloc i0nsnum i1count = outOpcode "maxalloc" args
  where args = [to i0nsnum, to i1count]


-- | * opcode : prealloc
--  
--  
-- * syntax : 
--  
--  >   prealloc insnum, icount
--  >   prealloc "insname", icount
--  
--  
-- * description : 
--  
--  Creates space for instruments but does not run them.
--  
--  
-- * url : <http://www.csounds.com/manual/html/prealloc.html>
 
preallocI :: Irate -> Irate -> SignalOut
preallocI i0nsnum i1count = outOpcode "prealloc" args
  where args = [to i0nsnum, to i1count]


-- | * opcode : prealloc
--  
--  
-- * syntax : 
--  
--  >   prealloc insnum, icount
--  >   prealloc "insname", icount
--  
--  
-- * description : 
--  
--  Creates space for instruments but does not run them.
--  
--  
-- * url : <http://www.csounds.com/manual/html/prealloc.html>
 
preallocS :: String -> Irate -> SignalOut
preallocS s0insname i1count = outOpcode "prealloc" args
  where args = [to s0insname, to i1count]


-- | * opcode : jacktransport
--  
--  
-- * syntax : 
--  
--  >   jacktransport icommand [, ilocation]
--  
--  
-- * description : 
--  
--  Start/stop jack_transport and can optionally relocate the
-- playback head.
--  
--  
-- * url : <http://www.csounds.com/manual/html/jacktransport.html>
 
jacktransport :: [Irate] -> Irate -> SignalOut
jacktransport i0init i1command = outOpcode "jacktransport" args
  where args = [to i1command] ++ map to i0init