module Csound.Typed.GlobalState.Opcodes(
    sprintf,
    -- * channel opcodes
    ChnRef(..), chnRefFromParg, chnRefAlloc, readChn, writeChn, overWriteChn, freeChn, chnName, chnget, chnset, chngetK, chnsetK, initSig, active, activeKr,
    readChnEvtLoop,
    chnUpdateUdo, masterUpdateChnAlive, servantUpdateChnAlive,
    masterUpdateChnRetrig, servantUpdateChnRetrig,
    servantUpdateChnEvtLoop, getRetrigVal,
    -- * trigger an instrument
    Event(..), event, eventi, event_i, appendChn, subinstr, subinstr_, changed, diff, delay1, primInstrId,
    -- * output
    out, outs, safeOut, autoOff, turnoff, turnoff2, exitnow,
    -- * vco2
    oscili, oscilikt, vco2ft, vco2ift, vco2init, ftgen,
    syncphasor, tableikt,
    -- * OSC
    oscInit, oscListen, oscSend,
    -- * channels
    chnGet, chnSet,
    -- * metro
    metro,
    -- * times
    times,
    -- * Fluid
    fluidEngine, fluidLoad, fluidProgramSelect,
    -- * Soundfonts
    sfSetList,
    -- * Midi
    midiVolumeFactor,
    -- * Hrtf Pan
    hrtfmove, hrtfstat,
    -- * Read tables
    tableK, tableI,
    -- * Portamento
    port,
    -- * Rate convertion
    downsamp
) where

import Prelude hiding ((<*))
import Control.Monad(zipWithM_, forM_)
import Data.Boolean

import Csound.Dynamic

-- channels

data ChnRef = ChnRef
    { ChnRef -> E
chnRefId      :: E
    , ChnRef -> [E]
chnRefNames   :: [E] }

chnRefFromParg :: Int -> Int -> ChnRef
chnRefFromParg :: Int -> Int -> ChnRef
chnRefFromParg Int
pargId Int
arity = E -> [E] -> ChnRef
ChnRef (Int -> E
pn Int
pargId) ([E] -> ChnRef) -> [E] -> ChnRef
forall a b. (a -> b) -> a -> b
$ (Int -> E) -> [Int] -> [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Int -> E -> E) -> E -> Int -> E
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> E -> E
chnName (Int -> E
pn Int
pargId)) [Int
1 .. Int
arity]

chnRefAlloc :: Monad m => Int -> DepT m ChnRef
chnRefAlloc :: Int -> DepT m ChnRef
chnRefAlloc Int
arity = do
    E
chnId <- DepT m E
forall (m :: * -> *). Monad m => DepT m E
freeChn
    ChnRef -> DepT m ChnRef
forall (m :: * -> *) a. Monad m => a -> m a
return (ChnRef -> DepT m ChnRef) -> ChnRef -> DepT m ChnRef
forall a b. (a -> b) -> a -> b
$ E -> [E] -> ChnRef
ChnRef E
chnId ([E] -> ChnRef) -> [E] -> ChnRef
forall a b. (a -> b) -> a -> b
$ (Int -> E) -> [Int] -> [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Int -> E -> E) -> E -> Int -> E
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> E -> E
chnName E
chnId) [Int
1 .. Int
arity]

readChn :: Monad m => ChnRef -> DepT m [E]
readChn :: ChnRef -> DepT m [E]
readChn ChnRef
ref = do
    [E]
res <- (E -> DepT m E) -> [E] -> DepT m [E]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
chnget ([E] -> DepT m [E]) -> [E] -> DepT m [E]
forall a b. (a -> b) -> a -> b
$ ChnRef -> [E]
chnRefNames ChnRef
ref
    ChnRef -> DepT m ()
forall (m :: * -> *). Monad m => ChnRef -> DepT m ()
clearChn ChnRef
ref
    [E] -> DepT m [E]
forall (m :: * -> *) a. Monad m => a -> m a
return [E]
res

writeChn :: Monad m => ChnRef -> [E] -> DepT m ()
writeChn :: ChnRef -> [E] -> DepT m ()
writeChn ChnRef
ref [E]
sigs = (E -> E -> DepT m ()) -> [E] -> [E] -> DepT m ()
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m ()
zipWithM_ E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnmix [E]
sigs ([E] -> DepT m ()) -> [E] -> DepT m ()
forall a b. (a -> b) -> a -> b
$ ChnRef -> [E]
chnRefNames ChnRef
ref

overWriteChn :: Monad m => ChnRef -> [E] -> DepT m ()
overWriteChn :: ChnRef -> [E] -> DepT m ()
overWriteChn ChnRef
ref [E]
sigs = (E -> E -> DepT m ()) -> [E] -> [E] -> DepT m ()
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m ()
zipWithM_ E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnset (ChnRef -> [E]
chnRefNames ChnRef
ref) [E]
sigs

clearChn :: Monad m => ChnRef -> DepT m ()
clearChn :: ChnRef -> DepT m ()
clearChn = (E -> DepT m ()) -> [E] -> DepT m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
chnclear ([E] -> DepT m ()) -> (ChnRef -> [E]) -> ChnRef -> DepT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChnRef -> [E]
chnRefNames

-- |
-- > chnName outputPortNumber freeChnId
chnName :: Int -> E -> E
chnName :: Int -> E -> E
chnName Int
name E
chnId = E -> [E] -> E
sprintf E
formatString [E
chnId]
    where formatString :: E
formatString = String -> E
str (String -> E) -> String -> E
forall a b. (a -> b) -> a -> b
$ Char
'p' Char -> String -> String
forall a. a -> [a] -> [a]
: Int -> String
forall a. Show a => a -> String
show Int
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"%d"

masterUpdateChnAlive :: Monad m => ChnRef -> E -> DepT m ()
masterUpdateChnAlive :: ChnRef -> E -> DepT m ()
masterUpdateChnAlive ChnRef
ref E
count = E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnsetK (E -> E
chnAliveName (E -> E) -> E -> E
forall a b. (a -> b) -> a -> b
$ ChnRef -> E
chnRefId ChnRef
ref) E
count

masterUpdateChnRetrig :: Monad m => ChnRef -> E -> DepT m ()
masterUpdateChnRetrig :: ChnRef -> E -> DepT m ()
masterUpdateChnRetrig ChnRef
ref E
count = E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnsetK (E -> E
chnRetrigName (E -> E) -> E -> E
forall a b. (a -> b) -> a -> b
$ ChnRef -> E
chnRefId ChnRef
ref) E
count

servantUpdateChnAlive :: Monad m => Int -> DepT m ()
servantUpdateChnAlive :: Int -> DepT m ()
servantUpdateChnAlive Int
pargId = do
    let sName :: E
sName = E -> E
chnAliveName (Int -> E
pn Int
pargId)
    E
kAlive <- E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
chngetK E
sName
    Rate -> E -> DepT m () -> DepT m ()
forall (m :: * -> *).
Monad m =>
Rate -> E -> DepT m () -> DepT m ()
when1 Rate
Kr (E
kAlive E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
<* -E
10) (DepT m () -> DepT m ()) -> DepT m () -> DepT m ()
forall a b. (a -> b) -> a -> b
$ do
        DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
turnoff
    E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnsetK E
sName (E
kAlive E -> E -> E
forall a. Num a => a -> a -> a
- E
1)

getRetrigVal :: Int -> E
getRetrigVal :: Int -> E
getRetrigVal Int
pargId = Int -> E
pn (Int -> E) -> Int -> E
forall a b. (a -> b) -> a -> b
$ Int
pargId Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1

servantUpdateChnRetrig :: Monad m => Int -> DepT m ()
servantUpdateChnRetrig :: Int -> DepT m ()
servantUpdateChnRetrig Int
pargId = do
    let sName :: E
sName = E -> E
chnRetrigName (Int -> E
pn Int
pargId)
    let retrigVal :: E
retrigVal = Int -> E
pn (Int -> E) -> Int -> E
forall a b. (a -> b) -> a -> b
$ Int
pargId Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
    E
kRetrig <- E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
chngetK E
sName
    Rate -> E -> DepT m () -> DepT m ()
forall (m :: * -> *).
Monad m =>
Rate -> E -> DepT m () -> DepT m ()
when1 Rate
Kr (E
kRetrig E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
/=* E
retrigVal) (DepT m () -> DepT m ()) -> DepT m () -> DepT m ()
forall a b. (a -> b) -> a -> b
$ do
        DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
turnoff

servantUpdateChnEvtLoop :: Monad m => Int -> DepT m ()
servantUpdateChnEvtLoop :: Int -> DepT m ()
servantUpdateChnEvtLoop Int
pargId = do
    let sName :: E
sName = E -> E
chnEvtLoopName (Int -> E
pn Int
pargId)
    E
kEvtLoop <- E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
chngetK E
sName
    E -> E -> DepT m ()
forall (m :: * -> *). Monad m => E -> E -> DepT m ()
chnsetK E
sName (E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB (E
kEvtLoop E -> E -> E
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* E
0) E
1 E
0)
    DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
turnoff

readChnEvtLoop :: Monad m => ChnRef -> DepT m E
readChnEvtLoop :: ChnRef -> DepT m E
readChnEvtLoop ChnRef
ref = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
chngetK (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ E -> E
chnEvtLoopName (ChnRef -> E
chnRefId ChnRef
ref)

chnAliveName :: E -> E
chnAliveName :: E -> E
chnAliveName E
chnId = E -> [E] -> E
sprintf E
formatString [E
chnId]
    where formatString :: E
formatString = String -> E
str (String -> E) -> String -> E
forall a b. (a -> b) -> a -> b
$ String
"alive" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"%d"

chnRetrigName :: E -> E
chnRetrigName :: E -> E
chnRetrigName E
chnId = E -> [E] -> E
sprintf E
formatString [E
chnId]
    where formatString :: E
formatString = String -> E
str (String -> E) -> String -> E
forall a b. (a -> b) -> a -> b
$ String
"retrig" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"%d"

chnEvtLoopName :: E -> E
chnEvtLoopName :: E -> E
chnEvtLoopName E
chnId = E -> [E] -> E
sprintf E
formatString [E
chnId]
    where formatString :: E
formatString = String -> E
str (String -> E) -> String -> E
forall a b. (a -> b) -> a -> b
$ String
"evtLoop" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"%d"

sprintf :: E -> [E] -> E
sprintf :: E -> [E] -> E
sprintf E
a [E]
as = String -> Spec1 -> [E] -> E
opcs String
"sprintf" [(Rate
Sr, Rate
SrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ir)] (E
aE -> [E] -> [E]
forall a. a -> [a] -> [a]
:[E]
as)

chnmix :: Monad m => E -> E -> DepT m ()
chnmix :: E -> E -> DepT m ()
chnmix E
asig E
name = do
    Var
var <- Rate -> m E -> DepT m Var
forall (m :: * -> *). Monad m => Rate -> m E -> DepT m Var
newLocalVar Rate
Ar (E -> m E
forall (m :: * -> *) a. Monad m => a -> m a
return E
0)
    Var -> E -> DepT m ()
forall (m :: * -> *). Monad m => Var -> E -> DepT m ()
writeVar Var
var E
asig
    E
val <- Var -> DepT m E
forall (m :: * -> *). Monad m => Var -> DepT m E
readVar Var
var
    E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcsNoInlineArgs String
"chnmix" [(Rate
Xr, [Rate
Ar, Rate
Sr])] [E
val, E
name]

chnset :: Monad m => E -> E -> DepT m ()
chnset :: E -> E -> DepT m ()
chnset E
name E
value = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnset" [(Rate
Xr, [Rate
Ar, Rate
Sr])] [E
value, E
name]

chnget :: Monad m => E -> DepT m E
chnget :: E -> DepT m E
chnget E
name = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnget" [(Rate
Ar, [Rate
Sr])] [E
name]

chngetK :: Monad m => E -> DepT m E
chngetK :: E -> DepT m E
chngetK E
name = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnget" [(Rate
Kr, [Rate
Sr])] [E
name]

chnsetK :: Monad m => E -> E -> DepT m ()
chnsetK :: E -> E -> DepT m ()
chnsetK E
name E
val = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcsNoInlineArgs String
"chnset" [(Rate
Xr, [Rate
Kr, Rate
Sr])] [E
val, E
name]

chnclear :: Monad m => E -> DepT m ()
chnclear :: E -> DepT m ()
chnclear E
name = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnclear" [(Rate
Xr, [Rate
Sr])] [E
name]

chnUpdateUdo :: Monad m => DepT m ()
chnUpdateUdo :: DepT m ()
chnUpdateUdo = String -> DepT m ()
forall (m :: * -> *). Monad m => String -> DepT m ()
verbatim (String -> DepT m ()) -> String -> DepT m ()
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines [
    String
"giPort init 1",
    String
"opcode " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
chnUpdateOpcodeName String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
", i, 0",
    String
"xout giPort",
    String
"giPort = giPort + 1",
    String
"endop"]


chnUpdateOpcodeName :: String
chnUpdateOpcodeName :: String
chnUpdateOpcodeName = String
"FreePort"

freeChn :: Monad m => DepT m E
freeChn :: DepT m E
freeChn = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
chnUpdateOpcodeName [(Rate
Ir, [])] []

-- trigger

primInstrId :: InstrId -> E
primInstrId :: InstrId -> E
primInstrId = Prim -> E
prim (Prim -> E) -> (InstrId -> Prim) -> InstrId -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InstrId -> Prim
PrimInstrId

data Event = Event
    { Event -> E
eventInstrId  :: E
    , Event -> E
eventStart    :: E
    , Event -> E
eventDur      :: E
    , Event -> [E]
eventArgs     :: [E] }

event :: Monad m => Event -> DepT m ()
event :: Event -> DepT m ()
event = String -> Rate -> Event -> DepT m ()
forall (m :: * -> *).
Monad m =>
String -> Rate -> Event -> DepT m ()
eventBy String
"event" Rate
Kr

eventi :: Monad m => Event -> DepT m ()
eventi :: Event -> DepT m ()
eventi = String -> Rate -> Event -> DepT m ()
forall (m :: * -> *).
Monad m =>
String -> Rate -> Event -> DepT m ()
eventBy String
"event" Rate
Ir

event_i :: Monad m => Event -> DepT m ()
event_i :: Event -> DepT m ()
event_i = String -> Rate -> Event -> DepT m ()
forall (m :: * -> *).
Monad m =>
String -> Rate -> Event -> DepT m ()
eventBy String
"event_i" Rate
Ir

eventBy :: Monad m => String -> Rate -> Event -> DepT m ()
eventBy :: String -> Rate -> Event -> DepT m ()
eventBy String
name Rate
rate Event
a = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
name [(Rate
Xr, Rate
Sr Rate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
: Rate -> [Rate]
forall a. a -> [a]
repeat Rate
rate)]
    (String -> E
str String
"i" E -> [E] -> [E]
forall a. a -> [a] -> [a]
: (Event -> E
eventInstrId Event
a) E -> [E] -> [E]
forall a. a -> [a] -> [a]
: (Event -> E
eventStart Event
a) E -> [E] -> [E]
forall a. a -> [a] -> [a]
: (Event -> E
eventDur Event
a) E -> [E] -> [E]
forall a. a -> [a] -> [a]
: (Event -> [E]
eventArgs Event
a))

appendChn :: E -> Event -> Event
appendChn :: E -> Event -> Event
appendChn E
chn Event
a = Event
a { eventArgs :: [E]
eventArgs = Event -> [E]
eventArgs Event
a [E] -> [E] -> [E]
forall a. [a] -> [a] -> [a]
++ [E
chn] }

subinstr :: Int -> InstrId -> [E] -> [E]
subinstr :: Int -> InstrId -> [E] -> [E]
subinstr Int
outArity InstrId
instrId [E]
args = ( (Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
outArity) ((Int -> [E]) -> [E]) -> (Int -> [E]) -> [E]
forall a b. (a -> b) -> a -> b
$ String -> Specs -> [E] -> Int -> [E]
mopcs String
"subinstr"
    (Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ar, Rate
Ir Rate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
: Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Kr)
    (Prim -> E
prim (InstrId -> Prim
PrimInstrId InstrId
instrId) E -> [E] -> [E]
forall a. a -> [a] -> [a]
: [E]
args)

subinstr_ :: Monad m => InstrId -> [E] -> DepT m ()
subinstr_ :: InstrId -> [E] -> DepT m ()
subinstr_ InstrId
instrId [E]
args = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ [E] -> E
forall a. [a] -> a
head ([E] -> E) -> [E] -> E
forall a b. (a -> b) -> a -> b
$ ((Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
1) ((Int -> [E]) -> [E]) -> (Int -> [E]) -> [E]
forall a b. (a -> b) -> a -> b
$  String -> Specs -> [E] -> Int -> [E]
mopcs String
"subinstr"
    (Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ar, Rate
Ir Rate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
: Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Kr)
    (Prim -> E
prim (InstrId -> Prim
PrimInstrId InstrId
instrId) E -> [E] -> [E]
forall a. a -> [a] -> [a]
: [E]
args)

changed :: E -> E
changed :: E -> E
changed E
x = String -> Spec1 -> [E] -> E
opcs String
"changed" [(Rate
Kr, [Rate
Kr])] [E
x]

diff :: E -> E
diff :: E -> E
diff E
x = String -> Spec1 -> [E] -> E
opcs String
"diff" [(Rate
Kr, [Rate
Kr])] [E
x]

delay1 :: E -> E
delay1 :: E -> E
delay1 E
x = String -> Spec1 -> [E] -> E
opcs String
"delay1" [(Rate
Ar, [Rate
Ar])] [E
x]

-- output

out :: Monad m => E -> DepT m ()
out :: E -> DepT m ()
out E
a = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcsNoInlineArgs String
"out" [(Rate
Xr, [Rate
Ar])] [E
a]

outs :: Monad m => [E] -> DepT m ()
outs :: [E] -> DepT m ()
outs [E]
as = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcsNoInlineArgs String
"outs" [(Rate
Xr, Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ar)] [E]
as

-- safe out

-- clipps values by 0dbfs
safeOut :: Double -> [E] -> [E]
safeOut :: Double -> [E] -> [E]
safeOut Double
gainLevel = (E -> E) -> [E] -> [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (( E -> E -> E
forall a. Num a => a -> a -> a
* Double -> E
double Double
gainLevel) (E -> E) -> (E -> E) -> E -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. E -> E
limiter)

limiter :: E -> E
limiter :: E -> E
limiter E
x = String -> Spec1 -> [E] -> E
opcs String
"compress" [(Rate
Ar, [Rate
Ar, Rate
Ar, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Ir])] [E
x, E
1, E
0, E
90, E
90, E
100, E
0, E
0, E
0]

autoOff :: Monad m => E -> [E] -> DepT m [E]
autoOff :: E -> [E] -> DepT m [E]
autoOff E
dt [E]
a = do
    DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
ihold
    Rate -> E -> DepT m () -> DepT m ()
forall (m :: * -> *).
Monad m =>
Rate -> E -> DepT m () -> DepT m ()
when1 Rate
Kr ([E] -> E
trig [E]
a)
        DepT m ()
forall (m :: * -> *). Monad m => DepT m ()
turnoff
    [E] -> DepT m [E]
forall (m :: * -> *) a. Monad m => a -> m a
return [E]
a
    where
        trig :: [E] -> E
trig = (E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
<* E
eps) (E -> E) -> ([E] -> E) -> [E] -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (E
env E -> E -> E
forall a. Num a => a -> a -> a
+ ) (E -> E) -> ([E] -> E) -> [E] -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rate -> E -> E
setRate Rate
Kr (E -> E) -> ([E] -> E) -> [E] -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (E -> E -> E) -> E -> E -> E
forall a b c. (a -> b -> c) -> b -> a -> c
flip E -> E -> E
follow E
dt (E -> E) -> ([E] -> E) -> [E] -> E
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [E] -> E
l2

        eps :: E
eps = E
1e-5

        l2 :: [E] -> E
        l2 :: [E] -> E
l2 [E]
xs = E -> E
forall a. Floating a => a -> a
sqrt (E -> E) -> E -> E
forall a b. (a -> b) -> a -> b
$ [E] -> E
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([E] -> E) -> [E] -> E
forall a b. (a -> b) -> a -> b
$ (E -> E -> E) -> [E] -> [E] -> [E]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith E -> E -> E
forall a. Num a => a -> a -> a
(*) [E]
xs [E]
xs

        env :: E
env = [E] -> E
linseg [E
1, E
dtE -> E -> E
forall a. Fractional a => a -> a -> a
/E
2, E
1, E
dtE -> E -> E
forall a. Fractional a => a -> a -> a
/E
2, E
0, E
1, E
0]

follow :: E -> E -> E
follow :: E -> E -> E
follow E
asig E
dt = String -> Spec1 -> [E] -> E
opcs String
"follow" [(Rate
Ar, [Rate
Ar, Rate
Ir])] [E
asig, E
dt]

initSig :: E -> E
initSig :: E -> E
initSig E
a = String -> Spec1 -> [E] -> E
opcs String
"init" [(Rate
Kr, [Rate
Ir])] [E
a]

turnoff :: Monad m => DepT m ()
turnoff :: DepT m ()
turnoff = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"turnoff" [(Rate
Xr, [])] []

turnoff2 :: Monad m => E -> DepT m ()
turnoff2 :: E -> DepT m ()
turnoff2 E
instrId = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"turnoff2" [(Rate
Xr, [Rate
Kr, Rate
Kr, Rate
Kr])] [E
instrId, E
0, E
0]

exitnow :: Monad m => DepT m ()
exitnow :: DepT m ()
exitnow = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"exitnow" [(Rate
Xr, [])] []

ihold :: Monad m => DepT m ()
ihold :: DepT m ()
ihold = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"ihold" [(Rate
Xr, [])] []

linseg :: [E] -> E
linseg :: [E] -> E
linseg = String -> Spec1 -> [E] -> E
opcs String
"linseg" [(Rate
Kr, Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ir)]

-- vco2

-- ares oscilikt xamp, xcps, kfn [, iphs] [, istor]
-- kres oscilikt kamp, kcps, kfn [, iphs] [, istor]
oscilikt :: E -> E -> E -> Maybe E -> E
oscilikt :: E -> E -> E -> Maybe E -> E
oscilikt E
amp E
cps E
fn Maybe E
mphase = String -> Spec1 -> [E] -> E
opcs String
"oscilikt"
    [ (Rate
Ar, [Rate
Xr, Rate
Xr, Rate
Kr, Rate
Ir, Rate
Ir])
    , (Rate
Kr, [Rate
Kr, Rate
Kr, Rate
Kr, Rate
Ir, Rate
Ir])]
    (case Maybe E
mphase of
        Maybe E
Nothing  -> [E
amp, E
cps, E
fn]
        Just E
phs -> [E
amp, E
cps, E
fn, E
phs]
    )

-- ares oscili xamp, xcps, ifn [, iphs]
-- kres oscili kamp, kcps, ifn [, iphs]
oscili :: E -> E -> E -> Maybe E -> E
oscili :: E -> E -> E -> Maybe E -> E
oscili E
amp E
cps E
fn Maybe E
mphase = String -> Spec1 -> [E] -> E
opcs String
"oscili"
    [ (Rate
Ar, [Rate
Xr, Rate
Xr, Rate
Ir, Rate
Ir, Rate
Ir])
    , (Rate
Kr, [Rate
Kr, Rate
Kr, Rate
Ir, Rate
Ir, Rate
Ir])]
    (case Maybe E
mphase of
        Maybe E
Nothing  -> [E
amp, E
cps, E
fn]
        Just E
phs -> [E
amp, E
cps, E
fn, E
phs]
    )


-- kfn vco2ft kcps, iwave [, inyx]
vco2ft :: E -> E -> E
vco2ft :: E -> E -> E
vco2ft E
cps E
iwave = String -> Spec1 -> [E] -> E
opcs String
"vco2ft" [(Rate
Kr, [Rate
Kr, Rate
Ir, Rate
Ir])] [E
cps, E
iwave]

vco2ift :: E -> E -> E
vco2ift :: E -> E -> E
vco2ift E
cps E
iwave = String -> Spec1 -> [E] -> E
opcs String
"vco2ift" [(Rate
Kr, [Rate
Ir, Rate
Ir, Rate
Ir])] [E
cps, E
iwave]

ftgen :: E -> Gen -> E
ftgen :: E -> Gen -> E
ftgen E
n Gen
g = String -> Spec1 -> [E] -> E
opcs String
"ftgen" [(Rate
Ir, Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ir)]
    ([E] -> E) -> [E] -> E
forall a b. (a -> b) -> a -> b
$ [E
n, E
0, Int -> E
int (Int -> E) -> Int -> E
forall a b. (a -> b) -> a -> b
$ Gen -> Int
genSize Gen
g, GenId -> E
genIdE (GenId -> E) -> GenId -> E
forall a b. (a -> b) -> a -> b
$ Gen -> GenId
genId Gen
g]
    [E] -> [E] -> [E]
forall a. [a] -> [a] -> [a]
++ ([E] -> (String -> [E]) -> Maybe String -> [E]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (E -> [E]
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> [E]) -> (String -> E) -> String -> [E]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> E
str) (Maybe String -> [E]) -> Maybe String -> [E]
forall a b. (a -> b) -> a -> b
$ Gen -> Maybe String
genFile Gen
g)
    [E] -> [E] -> [E]
forall a. [a] -> [a] -> [a]
++ ((Double -> E) -> [Double] -> [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Double -> E
double ([Double] -> [E]) -> [Double] -> [E]
forall a b. (a -> b) -> a -> b
$ Gen -> [Double]
genArgs Gen
g)

genIdE :: GenId -> E
genIdE :: GenId -> E
genIdE = \case
    IntGenId Int
n -> Int -> E
int Int
n
    StringGenId String
a -> String -> E
str String
a

vco2init :: [E] -> E
vco2init :: [E] -> E
vco2init = String -> Spec1 -> [E] -> E
opcs String
"vco2init" [(Rate
Ir, Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Ir)]

syncphasor :: E -> E -> Maybe E -> (E, E)
syncphasor :: E -> E -> Maybe E -> (E, E)
syncphasor E
xcps E
asyncin Maybe E
mphase = (Int -> [E]) -> (E, E)
forall a. (Int -> [a]) -> (a, a)
getPair ((Int -> [E]) -> (E, E)) -> (Int -> [E]) -> (E, E)
forall a b. (a -> b) -> a -> b
$ String -> Specs -> [E] -> Int -> [E]
mopcs String
"syncphasor" ([Rate
Ar, Rate
Ar], [Rate
Xr, Rate
Ar, Rate
Ir]) ([E] -> Int -> [E]) -> [E] -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ case Maybe E
mphase of
    Maybe E
Nothing     -> [E
xcps, E
asyncin]
    Just E
phase  -> [E
xcps, E
asyncin, E
phase]

tableikt :: E -> E -> E
tableikt :: E -> E -> E
tableikt E
xndx E
kfn  = String -> Spec1 -> [E] -> E
opcs String
"tableikt" [(Rate
Ar, [Rate
Xr, Rate
Kr, Rate
Ir, Rate
Ir, Rate
Ir])] [E
xndx, E
kfn, E
1]

-----------------------------------------------------------
-- OSC

oscInit :: E -> E
oscInit :: E -> E
oscInit E
portExpr = String -> Spec1 -> [E] -> E
opcs String
"OSCinit" [(Rate
Ir, [Rate
Ir])] [E
portExpr]

oscListen :: Monad m => E -> E -> E -> [Var] -> DepT m E
oscListen :: E -> E -> E -> [Var] -> DepT m E
oscListen E
oscHandle E
addr E
oscType [Var]
vars = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"OSClisten" [(Rate
Kr, Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Xr)] (E
oscHandle E -> [E] -> [E]
forall a. a -> [a] -> [a]
: E
addr E -> [E] -> [E]
forall a. a -> [a] -> [a]
: E
oscType E -> [E] -> [E]
forall a. a -> [a] -> [a]
: (Var -> E) -> [Var] -> [E]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Var -> E
inlineVar [Var]
vars)

oscSend :: Monad m => [E] -> DepT m ()
oscSend :: [E] -> DepT m ()
oscSend [E]
args = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"OSCsend" [(Rate
Xr, Rate
KrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate
IrRate -> [Rate] -> [Rate]
forall a. a -> [a] -> [a]
:Rate -> [Rate]
forall a. a -> [a]
repeat Rate
Xr)] [E]
args

-----------------------------------------------------------
-- Channel

chnGet :: Monad m => Rate -> E -> DepT m E
chnGet :: Rate -> E -> DepT m E
chnGet Rate
r E
chn = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnget" [(Rate
r, [Rate
Sr])] [E
chn]

chnSet :: Monad m => Rate -> E -> E -> DepT m ()
chnSet :: Rate -> E -> E -> DepT m ()
chnSet Rate
r E
val E
chn = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"chnset" [(Rate
Xr, [Rate
r, Rate
Sr])] [E
val, E
chn]

-----------------------------------------------------------
-- metro

metro :: E -> E
metro :: E -> E
metro E
a = String -> Spec1 -> [E] -> E
opcs String
"metro" [(Rate
Kr, [Rate
Kr])] [E
a]

-----------------------------------------------------------
-- times

times :: Monad m => DepT m E
times :: DepT m E
times = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"times" [(Rate
Ir, []), (Rate
Kr, [])] []

-----------------------------------------------------------
-- fluid engine

fluidEngine :: Monad m => DepT m E
fluidEngine :: DepT m E
fluidEngine = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"fluidEngine" [(Rate
Ir, [])] []

fluidLoad :: Monad m => String -> E -> DepT m E
fluidLoad :: String -> E -> DepT m E
fluidLoad String
sfName E
engine = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"fluidLoad" [(Rate
Ir, [Rate
Sr, Rate
Ir, Rate
Ir])] [String -> E
str String
sfName, E
engine, E
1]

fluidProgramSelect :: Monad m => E -> E -> Int -> Int -> DepT m E
fluidProgramSelect :: E -> E -> Int -> Int -> DepT m E
fluidProgramSelect E
engine E
sfInstr Int
bank Int
prog = E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"fluidProgramSelect"
    [(Rate
Xr, Int -> Rate -> [Rate]
forall a. Int -> a -> [a]
replicate Int
5 Rate
Ir)] [E
engine, E
1, E
sfInstr, Int -> E
int Int
bank, Int -> E
int Int
prog]

-----------------------------------------------------------
-- soundfonts

sfload :: Monad m => String -> DepT m E
sfload :: String -> DepT m E
sfload String
fileName =  E -> DepT m E
forall (m :: * -> *). Monad m => E -> DepT m E
depT (E -> DepT m E) -> E -> DepT m E
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"sfload" [(Rate
Ir, [Rate
Sr])] [String -> E
str String
fileName]

sfplist :: Monad m => E -> DepT m ()
sfplist :: E -> DepT m ()
sfplist E
sf = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"sfplist" [(Rate
Xr, [Rate
Ir])] [E
sf]

sfpreset :: Monad m => Int -> Int -> E -> Int -> DepT m ()
sfpreset :: Int -> Int -> E -> Int -> DepT m ()
sfpreset Int
bank Int
prog E
sf Int
index = E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> DepT m ()) -> E -> DepT m ()
forall a b. (a -> b) -> a -> b
$ String -> Spec1 -> [E] -> E
opcs String
"iPreset sfpreset" [(Rate
Xr, [Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir])] [Int -> E
int Int
prog, Int -> E
int Int
bank, E
sf, Int -> E
int Int
index]

sfSetList :: Monad m => String -> [(Int, Int, Int)] -> DepT m ()
sfSetList :: String -> [(Int, Int, Int)] -> DepT m ()
sfSetList String
fileName [(Int, Int, Int)]
presets = do
    E
sf <- String -> DepT m E
forall (m :: * -> *). Monad m => String -> DepT m E
sfload String
fileName
    E -> DepT m ()
forall (m :: * -> *). Monad m => E -> DepT m ()
sfplist E
sf
    [(Int, Int, Int)] -> ((Int, Int, Int) -> DepT m ()) -> DepT m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(Int, Int, Int)]
presets (((Int, Int, Int) -> DepT m ()) -> DepT m ())
-> ((Int, Int, Int) -> DepT m ()) -> DepT m ()
forall a b. (a -> b) -> a -> b
$ \(Int
bank, Int
prog, Int
index) -> Int -> Int -> E -> Int -> DepT m ()
forall (m :: * -> *).
Monad m =>
Int -> Int -> E -> Int -> DepT m ()
sfpreset Int
bank Int
prog E
sf Int
index

-----------------------------------------------------------
-- midi volume factor (normalize by number of notes)

-- if we use the scaling at I-rate we don't need to use portamento.
-- If we want to scale with signal the portamento is must
midiVolumeFactor :: E -> E
midiVolumeFactor :: E -> E
midiVolumeFactor E
idx = E -> E -> E -> E
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB (E
n E -> E -> E
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
<* E
2) E
1 (E -> E
forall a. Fractional a => a -> a
recip E
sqrtN)
    where sqrtN :: E
sqrtN = E -> E
forall a. Floating a => a -> a
sqrt E
n
          n :: E
n     = E -> E
activeIr E
idx

active :: E -> E
active :: E -> E
active E
instrId = String -> Spec1 -> [E] -> E
opcs String
"active" [(Rate
Kr, [Rate
Ir]), (Rate
Ir, [Rate
Ir])] [E
instrId]

activeIr :: E -> E
activeIr :: E -> E
activeIr E
instrId = String -> Spec1 -> [E] -> E
opcs String
"active" [(Rate
Ir, [Rate
Ir])] [E
instrId]

activeKr :: E -> E
activeKr :: E -> E
activeKr E
instrId = String -> Spec1 -> [E] -> E
opcs String
"active" [(Rate
Kr, [Rate
Ir])] [E
instrId]

port :: E -> E -> E
port :: E -> E -> E
port E
a E
b = String -> Spec1 -> [E] -> E
opcs String
"portk" [(Rate
Kr, [Rate
Kr, Rate
Ir])] [E
a, E
b]

downsamp :: E -> E
downsamp :: E -> E
downsamp E
a = String -> Spec1 -> [E] -> E
opcs String
"downsamp" [(Rate
Kr, [Rate
Ar])] [E
a]

-----------------------------------------------------------

getPair :: (Int -> [a]) -> (a, a)
getPair :: (Int -> [a]) -> (a, a)
getPair Int -> [a]
mout = (a
a, a
b)
    where [a
a, a
b] = Int -> [a]
mout Int
2

hrtfmove :: E -> E -> E -> E -> E -> E -> E -> E -> (E, E)
hrtfmove :: E -> E -> E -> E -> E -> E -> E -> E -> (E, E)
hrtfmove E
a1 E
a2 E
a3 E
a4 E
a5 E
a6 E
a7 E
a8 = (Int -> [E]) -> (E, E)
forall a. (Int -> [a]) -> (a, a)
getPair ((Int -> [E]) -> (E, E)) -> (Int -> [E]) -> (E, E)
forall a b. (a -> b) -> a -> b
$ String -> Specs -> [E] -> Int -> [E]
mopcs String
"hrtfmove2" ([Rate
Ar, Rate
Ar], [Rate
Ar, Rate
Kr, Rate
Kr, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir]) [E
a1, E
a2, E
a3, E
a4, E
a5, E
a6, E
a7, E
a8]

hrtfstat :: E -> E -> E -> E -> E -> E -> E -> (E, E)
hrtfstat :: E -> E -> E -> E -> E -> E -> E -> (E, E)
hrtfstat E
a1 E
a2 E
a3 E
a4 E
a5 E
a6 E
a7 = (Int -> [E]) -> (E, E)
forall a. (Int -> [a]) -> (a, a)
getPair ((Int -> [E]) -> (E, E)) -> (Int -> [E]) -> (E, E)
forall a b. (a -> b) -> a -> b
$ String -> Specs -> [E] -> Int -> [E]
mopcs String
"hrtfstat" ([Rate
Ar, Rate
Ar], [Rate
Ar, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir, Rate
Ir]) [E
a1, E
a2, E
a3, E
a4, E
a5, E
a6, E
a7]


-----------------------------------------------------------
-- read tables

tableK :: E -> E -> E
tableK :: E -> E -> E
tableK E
a1 E
a2 = String -> Spec1 -> [E] -> E
opcs String
"table" [(Rate
Kr, [Rate
Kr, Rate
Ir])] [E
a1, E
a2]

tableI :: E -> E -> E
tableI :: E -> E -> E
tableI E
a1 E
a2 = String -> Spec1 -> [E] -> E
opcs String
"table" [(Rate
Ir, [Rate
Ir, Rate
Ir])] [E
a1, E
a2]