-- | Envelope Generators
module CsoundExpr.Opcodes.Siggen.Envelope
    (adsrA,
     adsrK,
     madsrA,
     madsrK,
     mxadsrA,
     mxadsrK,
     xadsrA,
     xadsrK,
     linenA,
     linenK,
     linenrA,
     linenrK,
     envlpxA,
     envlpxK,
     envlpxrA,
     envlpxrK)
where



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



-- | * opcode : adsr
--  
--  
-- * syntax : 
--  
--  >   ares adsr iatt, idec, islev, irel [, idel]
--  >   kres adsr iatt, idec, islev, irel [, idel]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using linear segments.
--  
--  
-- * url : <http://www.csounds.com/manual/html/adsr.html>
 
adsrA :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Arate
adsrA i0init i1att i2dec i3slev i4rel = opcode "adsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : adsr
--  
--  
-- * syntax : 
--  
--  >   ares adsr iatt, idec, islev, irel [, idel]
--  >   kres adsr iatt, idec, islev, irel [, idel]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using linear segments.
--  
--  
-- * url : <http://www.csounds.com/manual/html/adsr.html>
 
adsrK :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Krate
adsrK i0init i1att i2dec i3slev i4rel = opcode "adsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : madsr
--  
--  
-- * syntax : 
--  
--  >   ares madsr iatt, idec, islev, irel [, idel] [, ireltim]
--  >   kres madsr iatt, idec, islev, irel [, idel] [, ireltim]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using the linsegr
-- mechanism.
--  
--  
-- * url : <http://www.csounds.com/manual/html/madsr.html>
 
madsrA :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Arate
madsrA i0init i1att i2dec i3slev i4rel = opcode "madsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : madsr
--  
--  
-- * syntax : 
--  
--  >   ares madsr iatt, idec, islev, irel [, idel] [, ireltim]
--  >   kres madsr iatt, idec, islev, irel [, idel] [, ireltim]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using the linsegr
-- mechanism.
--  
--  
-- * url : <http://www.csounds.com/manual/html/madsr.html>
 
madsrK :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Krate
madsrK i0init i1att i2dec i3slev i4rel = opcode "madsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : mxadsr
--  
--  
-- * syntax : 
--  
--  >   ares mxadsr iatt, idec, islev, irel [, idel] [, ireltim]
--  >   kres mxadsr iatt, idec, islev, irel [, idel] [, ireltim]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using the expsegr
-- mechanism.
--  
--  
-- * url : <http://www.csounds.com/manual/html/mxadsr.html>
 
mxadsrA :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Arate
mxadsrA i0init i1att i2dec i3slev i4rel = opcode "mxadsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : mxadsr
--  
--  
-- * syntax : 
--  
--  >   ares mxadsr iatt, idec, islev, irel [, idel] [, ireltim]
--  >   kres mxadsr iatt, idec, islev, irel [, idel] [, ireltim]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope using the expsegr
-- mechanism.
--  
--  
-- * url : <http://www.csounds.com/manual/html/mxadsr.html>
 
mxadsrK :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Krate
mxadsrK i0init i1att i2dec i3slev i4rel = opcode "mxadsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : xadsr
--  
--  
-- * syntax : 
--  
--  >   ares xadsr iatt, idec, islev, irel [, idel]
--  >   kres xadsr iatt, idec, islev, irel [, idel]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope
--  
--  
-- * url : <http://www.csounds.com/manual/html/xadsr.html>
 
xadsrA :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Arate
xadsrA i0init i1att i2dec i3slev i4rel = opcode "xadsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : xadsr
--  
--  
-- * syntax : 
--  
--  >   ares xadsr iatt, idec, islev, irel [, idel]
--  >   kres xadsr iatt, idec, islev, irel [, idel]
--  
--  
-- * description : 
--  
--  Calculates the classical ADSR envelope
--  
--  
-- * url : <http://www.csounds.com/manual/html/xadsr.html>
 
xadsrK :: [Irate] -> Irate -> Irate -> Irate -> Irate -> Krate
xadsrK i0init i1att i2dec i3slev i4rel = opcode "xadsr" args
  where args
          = [to i1att, to i2dec, to i3slev, to i4rel] ++ map to i0init


-- | * opcode : linen
--  
--  
-- * syntax : 
--  
--  >   ares linen xamp, irise, idur, idec
--  >   kres linen kamp, irise, idur, idec
--  
--  
-- * description : 
--  
--  linen -- apply a straight line rise and decay pattern to an
-- input amp signal.
--  
--  
-- * url : <http://www.csounds.com/manual/html/linen.html>
 
linenA :: (X x0) => x0 -> Irate -> Irate -> Irate -> Arate
linenA x0amp i1rise i2dur i3dec = opcode "linen" args
  where args = [to x0amp, to i1rise, to i2dur, to i3dec]


-- | * opcode : linen
--  
--  
-- * syntax : 
--  
--  >   ares linen xamp, irise, idur, idec
--  >   kres linen kamp, irise, idur, idec
--  
--  
-- * description : 
--  
--  linen -- apply a straight line rise and decay pattern to an
-- input amp signal.
--  
--  
-- * url : <http://www.csounds.com/manual/html/linen.html>
 
linenK :: (K k0) => k0 -> Irate -> Irate -> Irate -> Krate
linenK k0amp i1rise i2dur i3dec = opcode "linen" args
  where args = [to k0amp, to i1rise, to i2dur, to i3dec]


-- | * opcode : linenr
--  
--  
-- * syntax : 
--  
--  >   ares linenr xamp, irise, idec, iatdec
--  >   kres linenr kamp, irise, idec, iatdec
--  
--  
-- * description : 
--  
--  linenr -- same as linen except that the final segment is entered
-- only on sensing a MIDI note release. The note is then extended by
-- the decay time.
--  
--  
-- * url : <http://www.csounds.com/manual/html/linenr.html>
 
linenrA :: (X x0) => x0 -> Irate -> Irate -> Irate -> Arate
linenrA x0amp i1rise i2dec i3atdec = opcode "linenr" args
  where args = [to x0amp, to i1rise, to i2dec, to i3atdec]


-- | * opcode : linenr
--  
--  
-- * syntax : 
--  
--  >   ares linenr xamp, irise, idec, iatdec
--  >   kres linenr kamp, irise, idec, iatdec
--  
--  
-- * description : 
--  
--  linenr -- same as linen except that the final segment is entered
-- only on sensing a MIDI note release. The note is then extended by
-- the decay time.
--  
--  
-- * url : <http://www.csounds.com/manual/html/linenr.html>
 
linenrK :: (K k0) => k0 -> Irate -> Irate -> Irate -> Krate
linenrK k0amp i1rise i2dec i3atdec = opcode "linenr" args
  where args = [to k0amp, to i1rise, to i2dec, to i3atdec]


-- | * opcode : envlpx
--  
--  
-- * syntax : 
--  
--  >   ares envlpx xamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]
--  >   kres envlpx kamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]
--  
--  
-- * description : 
--  
--  envlpx -- apply an envelope consisting of 3 segments:
--  
--  
-- * url : <http://www.csounds.com/manual/html/envlpx.html>
 
envlpxA ::
          (X x0) =>
          [Irate] ->
            x0 -> Irate -> Irate -> Irate -> Irate -> Irate -> Irate -> Arate
envlpxA i0init x1amp i2rise i3dur i4dec i5fn i6atss i7atdec
  = opcode "envlpx" args
  where args
          = [to x1amp, to i2rise, to i3dur, to i4dec, to i5fn, to i6atss,
             to i7atdec]
              ++ map to i0init


-- | * opcode : envlpx
--  
--  
-- * syntax : 
--  
--  >   ares envlpx xamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]
--  >   kres envlpx kamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]
--  
--  
-- * description : 
--  
--  envlpx -- apply an envelope consisting of 3 segments:
--  
--  
-- * url : <http://www.csounds.com/manual/html/envlpx.html>
 
envlpxK ::
          (K k0) =>
          [Irate] ->
            k0 -> Irate -> Irate -> Irate -> Irate -> Irate -> Irate -> Krate
envlpxK i0init k1amp i2rise i3dur i4dec i5fn i6atss i7atdec
  = opcode "envlpx" args
  where args
          = [to k1amp, to i2rise, to i3dur, to i4dec, to i5fn, to i6atss,
             to i7atdec]
              ++ map to i0init


-- | * opcode : envlpxr
--  
--  
-- * syntax : 
--  
--  >   ares envlpxr xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
--  >   kres envlpxr kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
--  
--  
-- * description : 
--  
--  envlpxr is the same as envlpx except that the final segment is
-- entered only on sensing a MIDI note release. The note is then
-- extended by the decay time.
--  
--  
-- * url : <http://www.csounds.com/manual/html/envlpxr.html>
 
envlpxrA ::
           (X x0) =>
           [Irate] -> x0 -> Irate -> Irate -> Irate -> Irate -> Irate -> Arate
envlpxrA i0init x1amp i2rise i3dec i4fn i5atss i6atdec
  = opcode "envlpxr" args
  where args
          = [to x1amp, to i2rise, to i3dec, to i4fn, to i5atss, to i6atdec]
              ++ map to i0init


-- | * opcode : envlpxr
--  
--  
-- * syntax : 
--  
--  >   ares envlpxr xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
--  >   kres envlpxr kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
--  
--  
-- * description : 
--  
--  envlpxr is the same as envlpx except that the final segment is
-- entered only on sensing a MIDI note release. The note is then
-- extended by the decay time.
--  
--  
-- * url : <http://www.csounds.com/manual/html/envlpxr.html>
 
envlpxrK ::
           (K k0) =>
           [Irate] -> k0 -> Irate -> Irate -> Irate -> Irate -> Irate -> Krate
envlpxrK i0init k1amp i2rise i3dec i4fn i5atss i6atdec
  = opcode "envlpxr" args
  where args
          = [to k1amp, to i2rise, to i3dec, to i4fn, to i5atss, to i6atdec]
              ++ map to i0init