dobutokO2 0.30.0.0 → 0.31.0.0
raw patch · 3 files changed
+51/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ DobutokO.Sound.Functional: overConcat :: Vector OvertonesO -> OvertonesO
+ DobutokO.Sound.Functional: splitO :: Int -> OvertonesO -> Vector OvertonesO
+ DobutokO.Sound.Functional: splitO2 :: (OvertonesO -> OvertonesO) -> Int -> OvertonesO -> Vector OvertonesO
Files
- CHANGELOG.md +4/−0
- DobutokO/Sound/Functional.hs +46/−0
- dobutokO2.cabal +1/−1
CHANGELOG.md view
@@ -282,3 +282,7 @@ * Thirtieth version. Recent code in the DobutokO.Sound.Executable generalization. Added a new function 'soundGen3G_O2G' for this. It allows very general approach to generation of the changing timbre for a solo sounds and their sequences. Some documentation improvements.++## 0.31.0.0 -- 2020-04-16++* Thirty-first version. Added a new functionality with splitting the 'OvertonesO' to the DobutokO.Sound.Functional module.
DobutokO/Sound/Functional.hs view
@@ -123,6 +123,10 @@ , elemsOverlapOvers , gAdds01 , gAdds02+ -- * Splitting and concatenating OvertonesO+ , splitO+ , splitO2+ , overConcat ) where import Text.Read (readMaybe)@@ -1201,3 +1205,45 @@ if compare (V.length v1) 5 /= GT then renormF . V.generate 5 $ (\i -> (fromIntegral (i + 1) * note, halfwidth / fromIntegral (i + 3))) 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.+-- +-- 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+ (x0, y0) = V.unsafeIndex v1 0+ v2 = V.unsafeSlice 1 (n - 1) v1+ v31 = V.map (\t -> (fst t) / x0) v2+ v32 = V.map (\t -> (snd t) / y0) 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 0 n v1)+ | otherwise = V.singleton v0++-- | Splits (with addition of the new overtones) a given 'OvertonesO' into a number of 'OvertonesO' (represented finally as a 'V.Vector' of them repsectively) +-- so that it intermediately uses a special function before applying the \"similarization\" splitting function. Is a generalization of the 'splitO', +-- which can be considered a 'splitO2' with a first command line argument equals to 'id'.+-- +-- It is expected to obtain by such a conversion a splitted one sound into several simultaneous similar (less or more, depending on @h :: OvertonesO -> OvertonesO@) +-- 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.+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+ (x0, y0) = V.unsafeIndex v1 0+ v2 = V.unsafeSlice 1 (n - 1) v1+ v31 = V.map (\t -> (fst t) / x0) v2+ v32 = V.map (\t -> (snd t) / y0) 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 (h . V.unsafeSlice 0 n $ v1)+ | 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+overConcat v = V.concat . V.toList $ v
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dobutokO2-version: 0.30.0.0+version: 0.31.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