module Csound.Types(
Sig, D, Tab, Str, Spec, Wspec,
BoolSig, BoolD, Val(..), SigOrD,
Sig2, Sig3, Sig4, Sig5, Sig6, Sig8,
Sig2_2, Sig2_3, Sig2_4, Sig2_5, Sig2_6, Sig2_7, Sig2_8,
double, int, text,
idur, getSampleRate, getControlRate, getBlockSize,
getBpm, setBpm, syn, takt,
ar, kr, ir, sig,
withInits, withDs, withSigs, withTabs,
withD, withSig, withTab, withSeed,
quot', rem', div', mod', ceil', floor', round', int', frac',
boolSig, when1, whens, whenElse, whenD1, whenDs, whileDo, untilDo, whileDoD, untilDoD, whenElseD, compareWhenD,
equalsTo, notEqualsTo, lessThan, greaterThan, lessThanEquals, greaterThanEquals,
ar1, ar2, ar4, ar6, ar8,
Tuple(..), makeTupleMethods, Unit, unit, atTuple,
ifTuple, guardedTuple, caseTuple,
Arg, atArg,
ifArg, guardedArg, caseArg,
MonoArg(..), MonoAdsr, adsrMonoSynt, monoAdsr,
Sigs,
Arr, newLocalArr, newGlobalArr, newLocalCtrlArr, newGlobalCtrlArr,
writeArr, readArr, modifyArr, mixArr,
Arr1, DArr1, Arr2, DArr2, Arr3, DArr3,
arr1, darr1, arr2, darr2, arr3, darr3,
foreachArr, foreachArrD, forRowArr, forColumnArr, forRowArrD, forColumnArrD,
foldArr, foldRowArr, foldColumnArr, foldRowsArrD, foldColumnsArrD,
fillLocalArr, fillGlobalArr, fillLocalCtrlArr, fillGlobalCtrlArr,
maparrayNew, lenarray, copyf2array, copya2ftab, minarray, maxarray, sumarray,
scalearray, slicearrayNew,
maparrayCopy, slicearrayCopy,
SpecArr,
fftNew, fftinvNew, rfftNew, rifftNew, pvs2tab, tab2pvs, cmplxprodNew,
rect2polNew, pol2rectNew, pol2rect2New, windowArrayNew,
r2cNew, c2rNew, magsArrayNew, phsArrayNew,
fftCopy, fftinvCopy, rfftCopy, rifftCopy, cmplxprodCopy,
rect2polCopy, pol2rectCopy, pol2rect2Copy, windowArrayCopy,
r2cCopy, c2rCopy, magsArrayCopy, phsArrayCopy
) where
import Data.Boolean
import Csound.Typed.Types
import Csound.Typed.Control
atArg :: (Tuple a, Arg a) => [a] -> D -> a
atArg :: [a] -> D -> a
atArg [a]
as D
ind = [(BoolD, a)] -> a -> a
forall b. (Tuple b, Arg b) => [(BoolD, b)] -> b -> b
guardedArg ([BoolD] -> [a] -> [(BoolD, a)]
forall a b. [a] -> [b] -> [(a, b)]
zip ((Int -> BoolD) -> [Int] -> [BoolD]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Int
x -> Int -> D
int Int
x D -> D -> BoolD
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* D
ind) [Int
0 .. ]) [a]
as) ([a] -> a
forall a. [a] -> a
head [a]
as)
atTuple :: (Tuple a) => [a] -> Sig -> a
atTuple :: [a] -> Sig -> a
atTuple [a]
as Sig
ind = [(BoolSig, a)] -> a -> a
forall b. Tuple b => [(BoolSig, b)] -> b -> b
guardedTuple ([BoolSig] -> [a] -> [(BoolSig, a)]
forall a b. [a] -> [b] -> [(a, b)]
zip ((Int -> BoolSig) -> [Int] -> [BoolSig]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Int
x -> D -> Sig
sig (Int -> D
int Int
x) Sig -> Sig -> BoolSig
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
ind) [Int
0 .. ]) [a]
as) ([a] -> a
forall a. [a] -> a
head [a]
as)
whenElseD :: BoolD -> SE () -> SE () -> SE ()
whenElseD :: BoolD -> SE () -> SE () -> SE ()
whenElseD BoolD
condition SE ()
ifDo SE ()
elseDo = [(BoolD, SE ())] -> SE () -> SE ()
whenDs [(BoolD
condition, SE ()
ifDo)] SE ()
elseDo
whenElse :: BoolSig -> SE () -> SE () -> SE ()
whenElse :: BoolSig -> SE () -> SE () -> SE ()
whenElse BoolSig
condition SE ()
ifDo SE ()
elseDo = [(BoolSig, SE ())] -> SE () -> SE ()
whens [(BoolSig
condition, SE ()
ifDo)] SE ()
elseDo
compareWhenD :: D -> [(D, SE ())] -> SE ()
compareWhenD :: D -> [(D, SE ())] -> SE ()
compareWhenD D
val [(D, SE ())]
conditions = case [(D, SE ())]
conditions of
[] -> () -> SE ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
[(D
_condition, SE ()
ifDo)] -> SE ()
ifDo
(D
condition1, SE ()
do1):(D
_condition2, SE ()
do2): [] -> BoolD -> SE () -> SE () -> SE ()
whenElseD (D
val D -> D -> BooleanOf D
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` D
condition1) SE ()
do1 SE ()
do2
[(D, SE ())]
_ -> BoolD -> SE () -> SE () -> SE ()
whenElseD (D
val D -> D -> BooleanOf D
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` D
rootcondition) (D -> [(D, SE ())] -> SE ()
compareWhenD D
val [(D, SE ())]
less) (D -> [(D, SE ())] -> SE ()
compareWhenD D
val [(D, SE ())]
more)
where
([(D, SE ())]
less, [(D, SE ())]
more) = Int -> [(D, SE ())] -> ([(D, SE ())], [(D, SE ())])
forall a. Int -> [a] -> ([a], [a])
splitAt ([(D, SE ())] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(D, SE ())]
conditions Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
2) [(D, SE ())]
conditions
rootcondition :: D
rootcondition = (D, SE ()) -> D
forall a b. (a, b) -> a
fst ((D, SE ()) -> D) -> (D, SE ()) -> D
forall a b. (a -> b) -> a -> b
$ [(D, SE ())] -> (D, SE ())
forall a. [a] -> a
last [(D, SE ())]
less
syn :: Sig -> Sig
syn :: Sig -> Sig
syn Sig
x = (Sig
bpm Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig
60) Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* Sig
x
where bpm :: Sig
bpm = Sig
getBpm
takt :: Sig -> Sig
takt :: Sig -> Sig
takt = Sig -> Sig
forall a. Fractional a => a -> a
recip (Sig -> Sig) -> (Sig -> Sig) -> Sig -> Sig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig -> Sig
syn