Skip to content
Browse files

foo

  • Loading branch information...
1 parent 265e8fd commit 5b52bcc2a1b45b29558c61c6615c3b0eb491a0aa @yaxu committed Mar 16, 2012
Showing with 17 additions and 14 deletions.
  1. +15 −13 Pattern.hs
  2. +2 −1 Stream.hs
View
28 Pattern.hs
@@ -164,7 +164,7 @@ cat ps = Cycle $ map a [0 .. (length ps) - 1]
a n = Arc {pattern = ps !! n,
onset = s * (fromIntegral n),
scale = s,
- reps = 1
+ reps = s
}
every :: Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a
@@ -253,18 +253,20 @@ flat (o, s) (Cycle ps) = concatMap (flat (o, s)) ps
flat (a, s) Arc {pattern = p, onset = a', scale = s', reps = r}
| isIn = squash a' s' $ flat (max a'' 0, min s'' 1) p
| otherwise = []
- where b = a+s
- b' = a'+s'
- ia = max a a'
- ib = min b b'
- is = 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]
-
+ where
+ cycles = floor o
+ offset = ((fromIntegral cycles) * reps) mod' 1
+ b = a+s
+ b' = a'+s'
+ ia = max a a'
+ b = 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]
isWithin :: Rational -> Rational -> Rational -> Rational -> Bool
isWithin a b a' b' = or [a' >= a && a' < b,
View
3 Stream.hs
@@ -107,7 +107,8 @@ onTick s shape patternM change ticks
= do p <- readMVar patternM
let tpb' = 4 :: Integer
ticks' = (fromIntegral ticks) :: Integer
- a = (ticks' `mod` tpb') % tpb'
+ a = ticks' % tpb'
+ --a = (ticks' `mod` tpb') % tpb'
b = 1 % tpb'
messages = mapMaybe
(toMessage shape change ticks)

0 comments on commit 5b52bcc

Please sign in to comment.
Something went wrong with that request. Please try again.