csound-expression-dynamic 0.1.4.1 → 0.1.4.2
raw patch · 7 files changed
+36/−76 lines, 7 files
Files
- csound-expression-dynamic.cabal +2/−3
- src/Csound/Dynamic/Build.hs +2/−1
- src/Csound/Dynamic/Build/Logic.hs +9/−0
- src/Csound/Dynamic/Build/Numeric.hs +1/−1
- src/Csound/Dynamic/Render/Pretty.hs +2/−3
- src/Csound/Dynamic/Types/CsdFile.hs +20/−2
- src/Csound/Dynamic/Types/EventList.hs +0/−66
csound-expression-dynamic.cabal view
@@ -1,5 +1,5 @@ Name: csound-expression-dynamic-Version: 0.1.4.1+Version: 0.1.4.2 Cabal-Version: >= 1.6 License: BSD3 License-file: LICENSE@@ -34,8 +34,7 @@ Csound.Dynamic.Types.Exp Csound.Dynamic.Types.Dep Csound.Dynamic.Types.CsdFile- Csound.Dynamic.Types.Flags- Csound.Dynamic.Types.EventList+ Csound.Dynamic.Types.Flags Csound.Dynamic.Build Csound.Dynamic.Build.Numeric
src/Csound/Dynamic/Build.hs view
@@ -28,7 +28,8 @@ import Data.List(transpose) import Data.Fix(Fix(..)) -import Csound.Dynamic.Types+import Csound.Dynamic.Types.Exp+import Csound.Dynamic.Types.Dep ------------------------------------------------ -- basic constructors
src/Csound/Dynamic/Build/Logic.hs view
@@ -126,7 +126,16 @@ boolOp2 :: CondOp -> E -> E -> E boolOp0 op = boolOps op []+ boolOp2 op a b = boolOps op [a, b]++fromBoolOpt :: Either Bool E -> E+fromBoolOpt = either (\x -> if x then true else false) id ++toNumOpt :: E -> Either Double E+toNumOpt x = case toExp x of+ ExpPrim (PrimDouble d) -> Left d+ _ -> Right x ----------------------------------------------------------------------------- -- no support for not in csound so we perform not-elimination
src/Csound/Dynamic/Build/Numeric.hs view
@@ -7,7 +7,7 @@ import Data.Monoid -import Csound.Dynamic.Types+import Csound.Dynamic.Types.Exp import Csound.Dynamic.Build(toExp, prim, opr1, numExp1) ---------------------------------------------
src/Csound/Dynamic/Render/Pretty.hs view
@@ -8,7 +8,6 @@ import qualified Data.IntMap as IM import Text.PrettyPrint.Leijen- import Csound.Dynamic.Types vcatSep :: [Doc] -> Doc@@ -41,10 +40,10 @@ content, text "</" <> text name <> char '>'] -ppNotes :: InstrId -> [CsdEvent Note] -> Doc+ppNotes :: InstrId -> [CsdEvent] -> Doc ppNotes instrId = vcat . fmap (ppNote instrId) -ppNote :: InstrId -> CsdEvent Note -> Doc+ppNote :: InstrId -> CsdEvent -> Doc ppNote instrId evt = char 'i' <+> ppInstrId instrId <+> double (csdEventStart evt) <+> double (csdEventDur evt)
src/Csound/Dynamic/Types/CsdFile.hs view
@@ -1,9 +1,11 @@ -- | The Csound file module Csound.Dynamic.Types.CsdFile( Csd(..), Flags, Orc(..), Sco(..), Instr(..), InstrBody,+ CsdEvent, csdEventStart, csdEventDur, csdEventContent, csdEventTotalDur, intInstr, alwaysOn ) where +import Csound.Dynamic.Build.Numeric import Csound.Dynamic.Types.Exp import Csound.Dynamic.Types.Flags import Csound.Dynamic.Types.EventList@@ -29,7 +31,7 @@ data Sco = Sco { scoTotalDur :: Maybe Double , scoGens :: [(Int, Gen)]- , scoNotes :: [(InstrId, [CsdEvent Note])] }+ , scoNotes :: [(InstrId, [CsdEvent])] } ---------------------------------------------------------------- -- instruments@@ -40,6 +42,22 @@ ---------------------------------------------------------------- -- score -alwaysOn :: InstrId -> (InstrId, [CsdEvent Note])+alwaysOn :: InstrId -> (InstrId, [CsdEvent]) alwaysOn instrId = (instrId, [(0, -1, [])]) ++-- | The Csound note. It's a triple of+--+-- > (startTime, duration, parameters)+type CsdEvent = (Double, Double, Note)++csdEventStart :: CsdEvent -> Double+csdEventDur :: CsdEvent -> Double+csdEventContent :: CsdEvent -> Note++csdEventStart (a, _, _) = a+csdEventDur (_, a, _) = a+csdEventContent (_, _, a) = a++csdEventTotalDur :: CsdEvent -> Double+csdEventTotalDur (start, dur, _) = start + dur
− src/Csound/Dynamic/Types/EventList.hs
@@ -1,66 +0,0 @@-{-# Language DeriveFunctor, DeriveFoldable, DeriveTraversable #-}-module Csound.Dynamic.Types.EventList(- CsdSco(..), - CsdEvent, csdEventStart, csdEventDur, csdEventContent,- CsdEventList(..), delayCsdEventList, rescaleCsdEventList-) where--import Data.Traversable-import Data.Foldable---- | The Csound note. It's a triple of------ > (startTime, duration, parameters)-type CsdEvent a = (Double, Double, a)--csdEventStart :: CsdEvent a -> Double-csdEventDur :: CsdEvent a -> Double-csdEventContent :: CsdEvent a -> a--csdEventStart (a, _, _) = a-csdEventDur (_, a, _) = a-csdEventContent (_, _, a) = a--csdEventTotalDur :: CsdEvent a -> Double-csdEventTotalDur (start, dur, _) = start + dur---- | A class that represents Csound scores. All functions that use score are defined--- in terms of this class. If you want to use your own score representation, just define--- two methods of the class.------ The properties:------ > forall a . toCsdEventList (singleCsdEvent a) === CsdEventList 1 [(0, 1, a)]-class Functor f => CsdSco f where - -- | Converts a given score representation to the canonical one.- toCsdEventList :: f a -> CsdEventList a- -- | Constructs a scores that contains only one event. The event happens immediately and lasts for 1 second.- singleCsdEvent :: CsdEvent a -> f a---- | 'Csound.Base.CsdEventList' is a canonical representation of the Csound scores.--- A scores is a list of events and we should know the total duration of the scores.--- It's not meant to be used directly. We can use a better alternative. More convenient--- type that belongs to 'Csound.Base.CsdSco' type class (see temporal-csound package).-data CsdEventList a = CsdEventList- { csdEventListDur :: Double- , csdEventListNotes :: [CsdEvent a] - } deriving (Eq, Show, Functor, Foldable, Traversable)--instance CsdSco CsdEventList where- toCsdEventList = id- singleCsdEvent evt = CsdEventList (csdEventTotalDur evt) [evt]--delayCsdEventList :: Double -> CsdEventList a -> CsdEventList a-delayCsdEventList k (CsdEventList totalDur events) = - CsdEventList (k + totalDur) (fmap (delayCsdEvent k) events)--delayCsdEvent :: Double -> CsdEvent a -> CsdEvent a -delayCsdEvent k (start, dur, a) = (k + start, dur, a)--rescaleCsdEventList :: Double -> CsdEventList a -> CsdEventList a-rescaleCsdEventList k (CsdEventList totalDur events) = - CsdEventList (k * totalDur) (fmap (rescaleCsdEvent k) events)--rescaleCsdEvent :: Double -> CsdEvent a -> CsdEvent a-rescaleCsdEvent k (start, dur, a) = (k * start, k * dur, a)-