csound-expression 0.0.2 → 0.0.3
raw patch · 2 files changed
+25/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
csound-expression.cabal view
@@ -1,5 +1,5 @@ Name: csound-expression-Version: 0.0.2+Version: 0.0.3 Cabal-Version: >= 1.2 License: BSD3 License-File: LICENSE
src/CsoundExpr/Translator/Score.hs view
@@ -19,12 +19,20 @@ import CsoundExpr.Translator.Types ++-- import Debug.Trace+-- debug msg x = trace (msg ++ " : " ++ show x) x++ type NodeId = (Int, [Int]) type PfieldId = (Int, IsStringPfield) type IsStringPfield = Bool +-- | all values in given instrument node+type NodeSlice = (NodeId, [ValueId])+ foldScores :: EventList Dur Instr -> [(Instr, [Note])] foldScores x = zip instrs vals where instrs = zipWith substPfields ids rawInstrs@@ -50,15 +58,24 @@ foldVals :: [(Time, Time, [(NodeId, ValueId)])] -> ([(NodeId, PfieldId)], [Note]) foldVals xs = (i, subst3 (valList v) xs)- where (i, v) = assignPfieldIds $ [(fst $ head v, (map snd v)) | v <- f xs]- f = filter isPfield . transpose . map thd+ where (i, v) = assignPfieldIds $ filter (isPfield . snd) $ alignValuesByNodes xs subst3 ys xs = [(a, b, y) | (y, (a, b, _)) <- zip ys xs] valList [] = repeat [] valList xs = transpose xs- isPfield = ( > 1) . length . nub +isPfield :: [ValueId] -> Bool+isPfield = p . nub+ where p x = case x of+ (x0 : x1 : _) -> True+ _ -> False ++alignValuesByNodes :: [(Time, Time, [(NodeId, ValueId)])] -> [NodeSlice]+alignValuesByNodes = map select . transpose . map thd+ where select x = (fst $ head x, map snd x)++ substPfields :: [(NodeId, PfieldId)] -> Instr -> Instr substPfields ids instr = foldl f instr ids -- zip ids [4..] where f xs ((id0, id), n) =@@ -73,7 +90,7 @@ substListElem id x xs = take id xs ++ [x] ++ drop (id+1) xs - + formValues :: [(Time, Time, Instr)] -> [(Time, Time, [(NodeId, ValueId)])] formValues = map f . sortBy p where f (t, d, expr) = (t, d, toVals expr)@@ -84,6 +101,7 @@ | otherwise = GT + toVals :: Instr -> [(NodeId, ValueId)] toVals = (addId0 =<< ) . zip [0..] . map getVals where getVals = map (mapSnd value') . filter (isVal . exprOp . exprTag . snd) . toIdList@@ -91,13 +109,11 @@ addId0 (id0, xs) = [((id0, ids), vs) | (ids, vs) <- xs] -assignPfieldIds :: [(NodeId, [ValueId])] -> ([(NodeId, PfieldId)], [[ValueId]])+assignPfieldIds :: [NodeSlice] -> ([(NodeId, PfieldId)], [[ValueId]]) assignPfieldIds xs = (zip (map fst xs) (zip ids isStr), orderValsWithIds ids vals) where ids = map (+4) $ numerate $ map snd xs isStr = map (isStringValueId . head . snd) xs- vals = map (snd . head) $- groupBy ((==) `on` fst) $- zip ids (map snd xs)+ vals = map snd xs