Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ejconlon committed Jan 22, 2024
1 parent 08cb3ee commit 114335f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions minipat/src/Minipat/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,9 @@ patCont f = Pat (tapeSingleton . evCont f)
--
-- patSine :: Rational -> Pat Double
-- patSine = patCont . fnSine

-- patDeriv :: Num n => Pat n -> Pat n
-- patDeriv = undefined
--
-- patInteg :: Num n => Pat n -> Pat n
-- patInteg = undefined
11 changes: 8 additions & 3 deletions minipat/src/Minipat/Time.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ timeFloor = floor
timeCeil :: Time -> Integer
timeCeil = (+ 1) . timeFloor

timeLerp :: Time -> Time -> Time
timeLerp s e = s + (e - s) / 2
timeMidpoint :: Time -> Time -> Time
timeMidpoint s e = s + (e - s) / 2

data Arc = Arc {arcStart :: !Time, arcEnd :: !Time}
deriving stock (Eq, Ord, Show)
Expand All @@ -27,7 +27,7 @@ arcWiden :: Arc -> Arc
arcWiden (Arc s e) = Arc (fromInteger (timeFloor s)) (fromInteger (timeCeil e))

arcMidpoint :: Arc -> Time
arcMidpoint (Arc s e) = timeLerp s e
arcMidpoint (Arc s e) = timeMidpoint s e

arcTimeMapMono :: (Time -> Time) -> Arc -> Arc
arcTimeMapMono f (Arc s e) = Arc (f s) (f e)
Expand All @@ -54,6 +54,11 @@ spanTimeMapMono f (Span ac wh) = Span (arcTimeMapMono f ac) (fmap (arcTimeMapMon
spanWholeMapMono :: (Maybe Arc -> Maybe Arc) -> Span -> Span
spanWholeMapMono f (Span ac wh) = Span ac (f wh)

-- | Expands the active arc to cover the whole event
spanExtent :: Span -> Span
spanExtent sp@(Span _ wh) = maybe sp (`Span` wh) wh

-- | Splits an Arc into single-cycle spans
spanSplit :: Arc -> [(Integer, Span)]
spanSplit (Arc s0 e) =
let ef = fromInteger (timeFloor e)
Expand Down

0 comments on commit 114335f

Please sign in to comment.