dobutokO2 0.19.0.0 → 0.19.1.0
raw patch · 4 files changed
+30/−20 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- DobutokO.Sound.ParseList: parseStoLInts :: String -> [Int]
+ DobutokO.Sound.ParseList: parseStoLInts :: Int -> String -> [Int]
- DobutokO.Sound.ParseList: parseV :: Vector String -> Maybe [Int]
+ DobutokO.Sound.ParseList: parseV :: Int -> Vector String -> Maybe [Int]
Files
- CHANGELOG.md +5/−0
- DobutokO/Sound/Executable.hs +5/−5
- DobutokO/Sound/ParseList.hs +19/−14
- dobutokO2.cabal +1/−1
CHANGELOG.md view
@@ -178,3 +178,8 @@ * Nineteenth version. Added a new module DobutokO.Sound.ParseList to parse entered list of Int. Added the possibility to use "99" and "999" first command line options that allows to play and edit with SoX effects applied respectively the sequence of the "result\*wav" files in the current directory. Added functions to realize the functionality to different modules. Some documentation improvements.++## 0.19.1.0 -- 2020-03-28++* Nineteenth version revised A. Fixed issue with the infinite lists and thus the divergent functions. Changed some functions and fulfilled them with a limitation+parameter. Some minor documentation improvements.
DobutokO/Sound/Executable.hs view
@@ -233,7 +233,7 @@ let l0 = V.length dir0V putStrLn $ "You have available " ++ show l0 ++ " files that can be played. The minimum index further is 0, the maximum is " ++ show (l0 - 1) list1 <- recAndProcess file (99::Int)- let yss = divideToStr list1+ let yss = divideToStr l0 list1 v01 = V.fromList yss mxE = if isNothing (maxLinV v01) then (l0 - 1) else fromJust (maxLinV v01) mnE = if isNothing (minLinV v01) then 0 else fromJust (minLinV v01)@@ -248,17 +248,17 @@ let l0 = V.length dir0V putStrLn $ "You have available " ++ show l0 ++ " files that can be processed. The minimum index further is 0, the maximum is " ++ show (l0 - 1) list1 <- recAndProcess file (999::Int)- let yss = divideToStr list1+ let yss = divideToStr l0 list1 v01 = V.fromList yss- mxE = if isNothing (maxLinV v01) then 0 else fromJust (maxLinV v01)+ mxE = if isNothing (maxLinV v01) then (l0 - 1) else fromJust (maxLinV v01) mnE = if isNothing (minLinV v01) then 0 else fromJust (minLinV v01) zss = map (filterToBnds mnE mxE) yss v1 = doubleLtoV zss V.mapM_ (\idx -> soxE1 (V.unsafeIndex dir0V idx) argss) v1 {-# INLINE dobutokO2H999 #-} -divideToStr :: String -> [[Int]]-divideToStr = map parseStoLInts . lines+divideToStr :: Int -> String -> [[Int]]+divideToStr n = map (parseStoLInts n). lines isDataStr :: String -> Bool isDataStr = null . filter (== '@')
DobutokO/Sound/ParseList.hs view
@@ -32,16 +32,17 @@ canBePreParseV :: V.Vector String -> Bool canBePreParseV v = not (V.elem "(" v || V.elem "-" v || V.elem ")" v) -parseV :: V.Vector String -> Maybe [Int]-parseV v- | V.findIndices (== "..") v == V.singleton 2 && V.length v == 4 = +-- | Notification. Uses an 'Int' limitation to avoid infinite lists. All arguments must be not negative.+parseV :: Int -> V.Vector String -> Maybe [Int]+parseV n v+ | compare n 0 /= LT && V.findIndices (== "..") v == V.singleton 2 && V.length v == 4 = if V.unsafeIndex v 0 == "[" && V.unsafeIndex v 3 == "]" then let ins1 = readMaybe (V.unsafeIndex v 1)::Maybe Int in case ins1 of- Just ins -> Just [ins..]+ Just ins -> if compare n ins /= GT then Just [ins] else Just [ins..n] Nothing -> Nothing else Nothing- | V.findIndices (== "..") v == V.singleton 2 && V.length v == 5 =+ | compare n 0 /= LT && V.findIndices (== "..") v == V.singleton 2 && V.length v == 5 = if V.unsafeIndex v 0 == "[" && V.unsafeIndex v 4 == "]" then let ins1 = readMaybe (V.unsafeIndex v 1)::Maybe Int ins2 = readMaybe (V.unsafeIndex v 3)::Maybe Int in@@ -49,15 +50,19 @@ (Just ins01,Just ins02) -> if ins02 >= ins01 then Just [ins01..ins02] else Nothing _ -> Nothing else Nothing- | V.findIndices (== "..") v == V.singleton 4 && V.length v == 6 =+ | compare n 0 /= LT && V.findIndices (== "..") v == V.singleton 4 && V.length v == 6 = if V.unsafeIndex v 0 == "[" && V.unsafeIndex v 2 == "," && V.unsafeIndex v 5 == "]" then let ins1 = readMaybe (V.unsafeIndex v 1)::Maybe Int ins2 = readMaybe (V.unsafeIndex v 3)::Maybe Int in case (ins1,ins2) of- (Just ins01,Just ins02) -> Just [ins01,ins02..]+ (Just ins01,Just ins02) ->+ case compare ins02 ins01 of+ GT -> if compare n ins02 /= LT then Just [ins01,ins02..n] else Just [ins01,ins02]+ EQ -> Just [ins01]+ _ -> Just [ins01,ins02..0] _ -> Nothing else Nothing- | V.findIndices (== "..") v == V.singleton 4 && V.length v == 7 =+ | compare n 0 /= LT && V.findIndices (== "..") v == V.singleton 4 && V.length v == 7 = if V.unsafeIndex v 0 == "[" && V.unsafeIndex v 2 == "," && V.unsafeIndex v 6 == "]" then let ins1 = readMaybe (V.unsafeIndex v 1)::Maybe Int ins2 = readMaybe (V.unsafeIndex v 3)::Maybe Int@@ -66,7 +71,7 @@ (Just ins01,Just ins02,Just ins03) -> if null [ins01,ins02..ins03] then Nothing else Just [ins01,ins02..ins03] _ -> Nothing else Nothing- | V.unsafeIndex v 0 == "[" && V.unsafeIndex v (V.length v - 1) == "]" && V.length v `rem` 2 == 1 &&+ | compare n 0 /= LT && V.unsafeIndex v 0 == "[" && V.unsafeIndex v (V.length v - 1) == "]" && V.length v `rem` 2 == 1 && (V.toList . V.findIndices (== ",") $ v) == [2,4..(V.length v - 2)] = let insV1 = V.imap (\i _ -> readMaybe (V.unsafeIndex v (2 * i + 1))::Maybe Int) (V.unsafeSlice 0 (V.length v `quot` 2) v) in if V.any isNothing insV1@@ -74,10 +79,10 @@ else Just (V.toList . V.mapMaybe id $ insV1) | otherwise = Nothing --- | Parses a 'Strting' being a list of Ints written with Haskell rules, e. g. \"[1..]\", \"[2,4..45]\", \"[3,5,6,7,8,3]\" etc. into a list of 'Int'.--- If it is not possible or list is empty, returns []. Preceding whitespaces are ignored.-parseStoLInts :: String -> [Int]-parseStoLInts xs+-- | Parses a 'String' being a list of Ints written with Haskell rules, e. g. \"[1..]\", \"[2,4..45]\", \"[3,5,6,7,8,3]\" etc. into a list of 'Int'.+-- If it is not possible or list is empty, returns []. Preceding whitespaces are ignored. An 'Int' argument is used as a delimiter to avoid infinite lists.+parseStoLInts :: Int -> String -> [Int]+parseStoLInts n xs | canBePreParseV . parseTupV . dropWhile isSpace $ xs =- if isNothing . parseV $ (parseTupV . dropWhile isSpace $ xs) then [] else fromJust . parseV $ (parseTupV . dropWhile isSpace $ xs)+ if isNothing . parseV n $ (parseTupV . dropWhile isSpace $ xs) then [] else fromJust . parseV n $ (parseTupV . dropWhile isSpace $ xs) | otherwise = []
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dobutokO2-version: 0.19.0.0+version: 0.19.1.0 synopsis: A program and a library to create experimental music from a mono audio and a Ukrainian text description: It can also create a timbre for the notes. Uses SoX inside. homepage: https://hackage.haskell.org/package/dobutokO2