Permalink
Browse files

broken in order to fix

  • Loading branch information...
yaxu committed Mar 16, 2012
1 parent 5b52bcc commit 5a508a3a7cec810e768ab93248a4462720a2e435
Showing with 7 additions and 4 deletions.
  1. +7 −4 Pattern.hs
View
@@ -250,23 +250,26 @@ flat (o, s) (Silence) = []
flat (o, s) (Atom e) | o <= 0 && (o+s) > 0 = [(0, e)]
| otherwise = []
flat (o, s) (Cycle ps) = concatMap (flat (o, s)) ps
-flat (a, s) Arc {pattern = p, onset = a', scale = s', reps = r}
+flat (o, s) Arc {pattern = p, onset = a', scale = s', reps = 1}
| isIn = squash a' s' $ flat (max a'' 0, min s'' 1) p
| otherwise = []
where
- cycles = floor o
- offset = ((fromIntegral cycles) * reps) mod' 1
+ a = mod' o 1
b = a+s
b' = a'+s'
ia = max a a'
- b = min b b'
+ ib = min b b'
s = ib - ia
a'' = (ia - a') / s'
b'' = (ib - a') / s'
s'' = b'' - a''
isIn = a'' < 1 && b'' > 0 && a'' < b''
isIn' = tr $ isIn
tr = trace $ intercalate ", " [show a,show b,show a',show b',show isIn]
+flat (o, s) arc@(Arc {pattern = p, onset = o', scale = s', reps = r})
+ = flat (o, s) (arc {reps = 1, scale = s' / r, onset = o' + (mod' o r)})
+ where
+
isWithin :: Rational -> Rational -> Rational -> Rational -> Bool
isWithin a b a' b' = or [a' >= a && a' < b,

0 comments on commit 5a508a3

Please sign in to comment.