{-# Language DeriveFunctor, DeriveFoldable, DeriveTraversable #-}moduleCsound.Exp(E,RatedExp(..),RatedVar(..),onExp,Exp,toPrimOr,PrimOr(..),MainExp(..),Name,VarType(..),Var(..),Info(..),OpcType(..),Rate(..),Signature(..),isProcedure,isInfix,isPrefix,Prim(..),LowTab(..),Tab(..),TabSize(..),TabArgs(..),TabMap,Inline(..),InlineExp(..),PreInline(..),BoolExp,CondInfo,CondOp(..),isTrue,isFalse,NumExp,NumOp(..),Msg(..),Note,Event(..),eventEnd,)whereimportControl.ApplicativeimportData.MonoidimportData.TraversableimportData.Foldablehiding(concat)importData.DefaultimportData.Map(Map)importqualifiedData.IntMapasIMimportqualifiedData.MapasMimportData.Fix-- | The inner representation of csound expressions.typeE=FixRatedExptypeName=StringdataRatedExpa=RatedExp{ratedExpRate::MaybeRate,ratedExpDepends::Maybea,ratedExpExp::Expa}deriving(Show,Eq,Ord,Functor,Foldable,Traversable)dataRatedVar=RatedVar{ratedVarRate::Rate,ratedVarId::Int}deriving(Show)onExp::(Expa->Expa)->RatedExpa->RatedExpaonExpfa=a{ratedExpExp=f(ratedExpExpa)}dataVarType=LocalVar|GlobalVarderiving(Show,Eq,Ord)typeExpa=MainExp(PrimOra)toPrimOr::E->PrimOrEtoPrimOra=PrimOr$caseratedExpExp$unFixaofExpPrim(PString_)->RightaExpPrimp->Leftp_->RightanewtypePrimOra=PrimOr{unPrimOr::EitherPrima}deriving(Show,Eq,Ord,Functor)dataMainExpa=ExpPrimPrim|TfmInfo[a]|ConvertRateRateRatea|SelectRateInta|If(CondInfoa)aa|ExpBool(BoolExpa)|ExpNum(NumExpa)|ReadVarVar|WriteVarVaraderiving(Show,Eq,Ord,Functor,Foldable,Traversable)dataVar=Var{varType::VarType,varRate::Rate,varName::Name}|VarVerbatim{varRate::Rate,varName::Name}deriving(Show,Eq,Ord)dataInfo=Info{infoName::Name,infoSignature::Signature,infoOpcType::OpcType,infoNextSE::MaybeInt}deriving(Show,Eq,Ord)isPrefix,isInfix,isProcedure::Info->BoolisPrefix=(Prefix==).infoOpcTypeisInfix=(Infix==).infoOpcTypeisProcedure=(Procedure==).infoOpcTypedataOpcType=Prefix|Infix|Procedurederiving(Show,Eq,Ord)-- | The Csound rates.dataRate=Xr|Ar|Kr|Ir|Sr|Frderiving(Show,Eq,Ord,Enum,Bounded)dataSignature=SingleRate(MapRate[Rate])|MultiRate{outMultiRate::[Rate],inMultiRate::[Rate]}deriving(Show,Eq,Ord)dataPrim=PInt|PStringInt-- >> p-string: |PrimIntInt|PrimDoubleDouble|PrimTab(EitherTabLowTab)|PrimStringStringderiving(Show,Eq,Ord)typeTabMap=M.MapLowTabIntdataLowTab=LowTab{lowTabSize::Int,lowTabGen::Int,lowTabArgs::[Double]}deriving(Show,Eq,Ord)-- | Csound f-tables. You can make a value of 'Tab' with the function 'Csound.Tab.gen' or-- use more higher level functions.dataTab=TabExpE|Tab{tabSize::TabSize,tabGen::Int,tabArgs::TabArgs}deriving(Show,Eq,Ord)instanceDefaultTabSizewheredef=SizeDegree{hasGuardPoint=False,sizeDegree=0}dataTabSize=SizePlainInt|SizeDegree{hasGuardPoint::Bool,sizeDegree::Int}deriving(Show,Eq,Ord)dataTabArgs=ArgsPlain[Double]|ArgsRelative[Double]deriving(Show,Eq,Ord)-- | Midi messages.dataMsg=MsgtypeNote=[Prim]dataEventa=Event{eventStart::Double,eventDur::Double,eventContent::a}eventEnde=eventStarte+eventDureinstanceFunctorEventwherefmapfa=a{eventContent=f$eventContenta}-------------------------------------------------------------- types for arithmetic and boolean expressionsdataInlineab=Inline{inlineExp::InlineExpa,inlineEnv::IM.IntMapb}deriving(Show,Eq,Ord,Functor,Foldable,Traversable)dataInlineExpa=InlinePrimInt|InlineExpa[InlineExpa]deriving(Show,Eq,Ord)dataPreInlineab=PreInlinea[b]deriving(Show,Eq,Ord,Functor,Foldable,Traversable)-- booleanstypeBoolExpa=PreInlineCondOpatypeCondInfoa=InlineCondOpadataCondOp=TrueOp|FalseOp|Not|And|Or|Equals|NotEquals|Less|Greater|LessEquals|GreaterEqualsderiving(Show,Eq,Ord)isTrue,isFalse::CondInfoa->BoolisTrue=isCondOpTrueOpisFalse=isCondOpFalseOpisCondOpop=maybeFalse(op==).getCondInfoOpgetCondInfoOp::CondInfoa->MaybeCondOpgetCondInfoOpx=caseinlineExpxofInlineExpop_->Justop_->Nothing-- numberstypeNumExpa=PreInlineNumOpadataNumOp=Add|Sub|Neg|Mul|Div|Pow|Mod|Sin|Cos|Sinh|Cosh|Tan|Tanh|Sininv|Cosinv|Taninv|Ceil|Floor|Frac|Round|IntOp|Abs|ExpOp|Log|Log10|Logbtwo|Sqrt|Ampdb|Ampdbfs|Dbamp|Dbfsamp|Cent|Cpsmidinn|Cpsoct|Cpspch|Octave|Octcps|Octmidinn|Octpch|Pchmidinn|Pchoct|Semitonederiving(Show,Eq,Ord)--------------------------------------------------------- instances for cse that ghc was not able to derive for meinstanceFoldablePrimOrwherefoldMap=foldMapDefaultinstanceTraversablePrimOrwheretraversefx=caseunPrimOrxofLeftp->pure$PrimOr$LeftpRighta->PrimOr.Right<$>fa-- comments-- -- p-string ---- separate p-param for strings (we need it to read strings from global table) -- Csound doesn't permits us to use more than four string params so we need to-- keep strings in the global table and use `strget` to read them