packages feed

dobutokO2 0.31.0.0 → 0.32.0.0

raw patch · 4 files changed

+69/−7 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ DobutokO.Sound.Functional: splitHelp1 :: Int -> Int -> Int -> Int -> OvertonesO -> (Double, Double) -> Vector OvertonesO
+ DobutokO.Sound.Functional: splitHelp2 :: (OvertonesO -> OvertonesO) -> Int -> Int -> Int -> Int -> OvertonesO -> (Double, Double) -> Vector OvertonesO
+ DobutokO.Sound.Functional: splitOG1 :: String -> Int -> OvertonesO -> Vector OvertonesO
+ DobutokO.Sound.Functional: splitOG2 :: (OvertonesO -> OvertonesO) -> String -> Int -> OvertonesO -> Vector OvertonesO

Files

CHANGELOG.md view
@@ -286,3 +286,8 @@ ## 0.31.0.0 -- 2020-04-16  * Thirty-first version. Added a new functionality with splitting the 'OvertonesO' to the DobutokO.Sound.Functional module. ++## 0.32.0.0 -- 2020-04-17++* Thirty-second version. Made a way the greatest amplitudes are treated in the splitting functions for OvertonesO better defined. Added a new generalization for the +splitting functionality to the DobutokO.Sound.Functional module. Some documentation improvements.
DobutokO/Sound/Functional.hs view
@@ -127,11 +127,16 @@   , splitO   , splitO2   , overConcat+  -- ** Generalization of the previous ones splitting functions+  , splitHelp1+  , splitHelp2+  , splitOG1+  , splitOG2 ) where  import Text.Read (readMaybe) import CaseBi (getBFst')-import Data.Char (isDigit)+import Data.Char (isDigit,isAsciiLower) import System.Exit (ExitCode( ExitSuccess )) import Numeric import Data.List (isPrefixOf,sort,sortBy,nubBy)@@ -1206,16 +1211,16 @@    else v1       -- | Splits (with addition of the new overtones) a given 'OvertonesO' into a number @n@ (specified by the first 'Int' argument) of 'OvertonesO' --- (represented finally as a 'V.Vector' of them repsectively) so that all except the first @n@ greatest by the amplitude tuples of Doubles are --- considered overtones for the greatest one in the given 'OvertonesO' and all the next @n - 1@ are treated as the greatest and each of them --- produces the similar by the @f :: Double -> OvertonesO@ function overtones.+-- (represented finally as a 'V.Vector' of them repsectively) so that all except the first @n@ greatest by the absolute value of the amplitude tuples of Doubles are +-- considered overtones for the greatest by the absolute value one in the given 'OvertonesO' and all the next @n - 1@ are treated as the greatest by +-- the absolute value and each of them produces the similar by the @f :: Double -> OvertonesO@ function overtones. --  -- It is expected to obtain by such a conversion a splitted one sound into several simultaneous similar ones with different heights.  -- To provide a rich result, the given first argument must be strictly less than the length of the given 'OvertonesO' minus one. splitO :: Int -> OvertonesO -> V.Vector OvertonesO splitO n v0   | compare (V.length v0) (n + 1) == GT = -    let v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare x2 x1) . V.toList $ v0+    let v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare (abs x2) (abs x1)) . V.toList $ v0         (x0, y0) = V.unsafeIndex v1 0         v2 = V.unsafeSlice 1 (n - 1) v1         v31 = V.map (\t -> (fst t) / x0) v2@@ -1234,7 +1239,7 @@ splitO2 :: (OvertonesO -> OvertonesO) -> Int -> OvertonesO -> V.Vector OvertonesO splitO2 h n v0  | compare (V.length v0) (n + 1) == GT = -    let v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare x2 x1) . V.toList $ v0+    let v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare (abs x2) (abs x1)) . V.toList $ v0         (x0, y0) = V.unsafeIndex v1 0         v2 = V.unsafeSlice 1 (n - 1) v1         v31 = V.map (\t -> (fst t) / x0) v2@@ -1243,6 +1248,54 @@         f1Tup = (\(t1,w2) -> V.imap (\i (u1,u2) -> (fst (V.unsafeIndex v3 i) * t1, snd (V.unsafeIndex v3 i) * w2 )) v3)           in V.map f1Tup (h . V.unsafeSlice 0 n $ v1)   | otherwise = V.singleton v0++-- | -- | Generalized variant of the 'splitO' with the different splitting variants depending on the first two ASCII lower case letters in the 'String' argument.+splitOG1 :: String -> Int -> OvertonesO -> V.Vector OvertonesO+splitOG1 xs n v0 + | compare (V.length v0) (n + 1) == GT = +    let (c1s,c2s) = splitAt 1 . take 2 . filter isAsciiLower $ xs+        v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare (abs x2) (abs x1)) . V.toList $ v0+        (x0, y0) = V.unsafeIndex v1 0 in+          case (c1s,c2s) of+            ("a","b") -> let (k1,k2,k3,k4) = (n - 1,V.length v0 - n,n - 1,V.length v0 - n) in splitHelp1 k1 k2 k3 k4 v1 (x0,y0) +            ("a","c") -> let (k1,k2,k3,k4) = (1,n - 1,n - 1,V.length v0 - n) in splitHelp1 k1 k2 k3 k4 v1 (x0,y0) +            ("a","d") -> let (k1,k2,k3,k4) = (n - 1,V.length v0 - n,0,n) in splitHelp1 k1 k2 k3 k4 v1 (x0,y0) +            (_,_)         -> let (k1,k2,k3,k4) = (1,n - 1,0,n) in splitHelp1 k1 k2 k3 k4 v1 (x0,y0) +  | otherwise = V.singleton v0++-- | Auxiliary function that is used inside 'innerSplit1' and also in 'splitOG1'.+splitHelp1 :: Int -> Int -> Int -> Int -> OvertonesO -> (Double,Double) -> V.Vector OvertonesO+splitHelp1 x1 x2 x3 x4 v00 (y5,y6) = +  let v2 = V.unsafeSlice x1 x2 v00+      v31 = V.map (\t -> (fst t) / y5) v2+      v32 = V.map (\t -> (snd t) / y6) v2+      v3 = V.zip v31 v32+      f1Tup = (\(t1,w2) -> V.imap (\i (u1,u2) -> (fst (V.unsafeIndex v3 i) * t1, snd (V.unsafeIndex v3 i) * w2 )) v3)+        in V.map f1Tup (V.unsafeSlice x3 x4 v00)++-- | Auxiliary function that is used inside 'innerSplit2' and also in 'splitOG2'.+splitHelp2 :: (OvertonesO -> OvertonesO) -> Int -> Int -> Int -> Int -> OvertonesO -> (Double,Double) -> V.Vector OvertonesO+splitHelp2 h1 x1 x2 x3 x4 v00 (y5,y6) = +  let v2 = V.unsafeSlice x1 x2 v00+      v31 = V.map (\t -> (fst t) / y5) v2+      v32 = V.map (\t -> (snd t) / y6) v2+      v3 = V.zip v31 v32+      f1Tup = (\(t1,w2) -> V.imap (\i (u1,u2) -> (fst (V.unsafeIndex v3 i) * t1, snd (V.unsafeIndex v3 i) * w2 )) v3)+        in V.map f1Tup (h1 . V.unsafeSlice x3 x4 $ v00)        ++-- | Generalized variant of the 'splitO2' with the different splitting variants depending on the first two ASCII lower case letters in the 'String' argument.+splitOG2 :: (OvertonesO -> OvertonesO) -> String -> Int -> OvertonesO -> V.Vector OvertonesO+splitOG2 h xs n v0+ | compare (V.length v0) (n + 1) == GT = +    let (c1s,c2s) = splitAt 1 . take 2 . filter isAsciiLower $ xs+        v1 = V.fromList . sortBy (\(x1,y1) (x2,y2) -> compare (abs x2) (abs x1)) . V.toList $ v0+        (x0, y0) = V.unsafeIndex v1 0 in+          case (c1s,c2s) of+            ("a","b") -> let (k1,k2,k3,k4) = (n - 1,V.length v0 - n,n - 1,V.length v0 - n) in splitHelp2 h k1 k2 k3 k4 v1 (x0,y0) +            ("a","c") -> let (k1,k2,k3,k4) = (1,n - 1,n - 1,V.length v0 - n) in splitHelp2 h k1 k2 k3 k4 v1 (x0,y0) +            ("a","d") -> let (k1,k2,k3,k4) = (n - 1,V.length v0 - n,0,n) in splitHelp2 h k1 k2 k3 k4 v1 (x0,y0) +            (_,_)         -> let (k1,k2,k3,k4) = (1,n - 1,0,n) in splitHelp2 h k1 k2 k3 k4 v1 (x0,y0) +  | otherwise = V.singleton v0      -- | Concatenates a 'V.Vector' of 'OvertonesO' into a single 'OvertonesO'. Can be easily used with 'splitO'. overConcat :: V.Vector OvertonesO -> OvertonesO
README.markdown view
@@ -232,6 +232,10 @@ with f function in the DobutokO.Sound.Functional module. They are based on the simplest (but still meaningful) multiplicative data fitting. +Since the 0.31.0.0 version the library includes functions to split the sound +into several simultanously sounding similar ones. For more information, please, +refer to the DobutokO.Sound.Functional module.+ ** Note:  * Better to execute in the RAM. Need rather a lot of space on the disk for
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO2-version:             0.31.0.0+version:             0.32.0.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