This repository was archived by the owner on Jun 13, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 275
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Simplify rev #1139
Copy link
Copy link
Open
Description
I think @polymorphicengine pointed out that rev could just negate time, rather than the complex mirroring it's doing now.
Here's an implementation of that:
negateArc (Arc b e) = Arc (negate e) (negate b)
rev' = withQueryArc negateArc . withResultArc negateArcCan we drop this in or does it have different behaviour? I think it's similar but the cycles are also in reverse order?
for comparison:
Tidal/src/Sound/Tidal/Pattern.hs
Lines 813 to 845 in 493b2c0
| rev :: Pattern a -> Pattern a | |
| rev p = | |
| keepMeta p $ | |
| splitQueries $ | |
| p | |
| { query = \st -> | |
| map makeWholeAbsolute $ | |
| mapParts (mirrorArc (midCycle $ arc st)) $ | |
| map | |
| makeWholeRelative | |
| ( query | |
| p | |
| st | |
| { arc = mirrorArc (midCycle $ arc st) (arc st) | |
| } | |
| ) | |
| } | |
| where | |
| makeWholeRelative :: Event a -> Event a | |
| makeWholeRelative e@Event {whole = Nothing} = e | |
| makeWholeRelative (Event c (Just (Arc s e)) p'@(Arc s' e') v) = | |
| Event c (Just $ Arc (s' - s) (e - e')) p' v | |
| makeWholeAbsolute :: Event a -> Event a | |
| makeWholeAbsolute e@Event {whole = Nothing} = e | |
| makeWholeAbsolute (Event c (Just (Arc s e)) p'@(Arc s' e') v) = | |
| Event c (Just $ Arc (s' - e) (e' + s)) p' v | |
| midCycle :: Arc -> Time | |
| midCycle (Arc s _) = sam s + 0.5 | |
| mapParts :: (Arc -> Arc) -> [Event a] -> [Event a] | |
| mapParts f es = (\(Event c w p' v) -> Event c w (f p') v) <$> es | |
| -- Returns the `mirror image' of a 'Arc' around the given point in time | |
| mirrorArc :: Time -> Arc -> Arc | |
| mirrorArc mid' (Arc s e) = Arc (mid' - (e - mid')) (mid' + (mid' - s)) |
Metadata
Metadata
Assignees
Labels
No labels