packages feed

dobutokO2 0.33.0.0 → 0.34.0.0

raw patch · 4 files changed

+78/−19 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ DobutokO.Sound.Keyboard: input2BLMN :: Int64 -> Int64 -> IO ByteString
+ DobutokO.Sound.Keyboard: input2BLN :: Int64 -> IO ByteString
+ DobutokO.Sound.Keyboard: readFile2BLGenMN :: Int64 -> Int64 -> String -> FilePath -> IO ByteString
+ DobutokO.Sound.Keyboard: readFile2BLGenN :: Int64 -> String -> FilePath -> IO ByteString
+ DobutokO.Sound.Keyboard: readFile2BLMN :: Int64 -> Int64 -> FilePath -> IO ByteString
+ DobutokO.Sound.Keyboard: readFile2BLN :: Int64 -> FilePath -> IO ByteString
+ DobutokO.Sound.Keyboard: readFileDoublesGenMN :: Int64 -> Int64 -> String -> FilePath -> IO (Vector Int)
+ DobutokO.Sound.Keyboard: readFileDoublesGenN :: Int64 -> String -> FilePath -> IO (Vector Int)
+ DobutokO.Sound.Keyboard: readFileDoublesMN :: Int64 -> Int64 -> FilePath -> IO (Vector Int)
+ DobutokO.Sound.Keyboard: readFileDoublesN :: Int64 -> FilePath -> IO (Vector Int)

Files

CHANGELOG.md view
@@ -296,3 +296,8 @@  * Thirty-third version. Changed some functions to reduce unneeded parameter functions and arguments in the DobutokO.Sound.Functional and DobutokO.Sound.Executable  modules. Added new functions to change elements of the OvertonesO 'fChangeFElem' and 'fChangeFElems'. Some documentation improvements.++## 0.34.0.0 -- 2020-04-21++* Thirty-fourth version. Fixed issues with deprecated documentation for 0.33.0.0 version. Added new functions to the DobutokO.Sound.Keyboard +module to provide more control over reading from the files and stdin. Some documentation improvements.
DobutokO/Sound/Functional.hs view
@@ -1066,7 +1066,7 @@ sameFreqFI freq (noteN0,amplN0) f g = g (noteN0,amplN0) . V.filter (\(x,y) -> x == noteN0) $ f freq  -- | @gAdd :: (Double,Double) -> Double -> (Double -> OvertonesO) -> OvertonesO@ is a function that defines how the element is added--- to the 'OvertonesO'. Unlike for 'sameFreqF', it depends also on the 'Double' argument for @f :: Double -> OvertonesO@. 'fAddFElem' is+-- to the 'OvertonesO'. 'fAddFElem' is  -- actually a higher-order function, it changes the function @f@ and returns a new one. It can be an interesting task  -- (in general) to look at such a function through a prism of notion of operator (mathematical, for example similar to that ones that  -- are used for quantum mechanics and quantum field theory). @@ -1077,7 +1077,7 @@ fAddFElem (noteN, amplN) f gAdd t = gAdd (noteN, amplN) t f  -- | @gRem:: (Double,Double) -> Double -> (Double -> OvertonesO) -> OvertonesO@ is a function that defines how the element is removed--- from the 'OvertonesO'. Unlike for 'sameFreqF', it depends also on the 'Double' argument for @f :: Double -> OvertonesO@. 'fRemoveFElem' is+-- from the 'OvertonesO'. 'fRemoveFElem' is -- actually a higher-order function, it changes the function @f@ and returns a new one. It can be an interesting task  -- (in general) to look at such a function through a prism of notion of operator (mathematical, for example that ones that are used  -- for quantum mechanics and quantum field theory). @@ -1268,14 +1268,14 @@ 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+    let c1s = 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) +          case c1s of+            "ab" -> 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) +            "ac" -> let (k1,k2,k3,k4) = (1,n - 1,n - 1,V.length v0 - n) in splitHelp1 k1 k2 k3 k4 v1 (x0,y0) +            "ad" -> 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'.@@ -1302,15 +1302,15 @@ 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+    let c1s = 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    +          case c1s of+            "ab" -> 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) +            "ac" -> let (k1,k2,k3,k4) = (1,n - 1,n - 1,V.length v0 - n) in splitHelp2 h k1 k2 k3 k4 v1 (x0,y0) +            "ad" -> 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
DobutokO/Sound/Keyboard.hs view
@@ -16,11 +16,21 @@   qwerty2dvorak   , dvorak2qwerty   , input2BL+  , input2BLN+  , input2BLMN   , readFile2BL-  , readFile2BLGen+  , readFile2BLN+  , readFile2BLMN+  , readFile2BLGen  +  , readFile2BLGenN+  , readFile2BLGenMN   -- * Conversions   , readFileDoubles+  , readFileDoublesN+  , readFileDoublesMN   , readFileDoublesGen+  , readFileDoublesGenN+  , readFileDoublesGenMN   , takeDoubles   , hashStr2   , convH@@ -29,7 +39,8 @@ import CaseBi (getBFst') import Data.Char (isAsciiLower) import qualified Data.Vector as V-import qualified Data.ByteString.Lazy.Char8 as BL (ByteString,map,zipWith,tail,filter,getContents,readFile)+import GHC.Int (Int64)+import qualified Data.ByteString.Lazy.Char8 as BL (ByteString,map,zipWith,tail,filter,getContents,readFile,take,drop)  -- | Converts a lazy 'BL.ByteString' into a 'V.Vector' of 'Int' using 'hashStr2'.  takeDoubles :: BL.ByteString -> V.Vector Int@@ -52,12 +63,30 @@ input2BL :: IO (BL.ByteString) input2BL = fmap (convH [] (BL.filter isAsciiLower)) BL.getContents +-- | Like 'input2BL', but takes only first @n@ symbols specified with the first 'Int64' argument.+input2BLN :: Int64 -> IO (BL.ByteString)+input2BLN n = fmap (convH [] (BL.take n . BL.filter isAsciiLower)) BL.getContents++-- | Like 'input2BL', but takes only first @n@ symbols specified with the second 'Int64' argument dropping before this the first @m@ symbols specified +-- with the first 'Int64' argument.+input2BLMN :: Int64 -> Int64 -> IO (BL.ByteString)+input2BLMN m n = fmap (convH [] (BL.take n . BL.drop m . BL.filter isAsciiLower)) BL.getContents+ -- | Reads a given file into a lazy 'BL.ByteString' with filtering of all characters that are not a lower case ascii letters. It has additional  -- first command line argument to control the way of treating letters: as being typed (entered) properly (null 'String'), or needed to be converted  -- from qwerty to dvorak layout (\"q\" 'String'), or vice versa (otherwise). readFile2BLGen :: String -> FilePath -> IO (BL.ByteString) readFile2BLGen ys = fmap (convH ys (BL.filter isAsciiLower)) . BL.readFile +-- | Like 'readFile2BLGen', but reads only first @n@ symbols specified with the first 'Int64' argument.+readFile2BLGenN :: Int64 -> String -> FilePath -> IO (BL.ByteString)+readFile2BLGenN n ys = fmap (convH ys (BL.take n . BL.filter isAsciiLower)) . BL.readFile++-- | Like 'readFile2BLGen', but reads only first @n@ symbols specified with the second 'Int64' argument dropping before this the first @m@ symbols specified +-- with the first 'Int64' argument.+readFile2BLGenMN :: Int64 -> Int64 -> String -> FilePath -> IO (BL.ByteString)+readFile2BLGenMN m n ys = fmap (convH ys (BL.take n . BL.drop m . BL.filter isAsciiLower)) . BL.readFile+ -- | Auxiliary function to define how is a 'BL.ByteString' treated, see 'readFile2BLGen'. convH :: String -> (BL.ByteString -> BL.ByteString) -> (BL.ByteString -> BL.ByteString) convH ys f @@ -70,14 +99,39 @@ readFile2BL :: FilePath -> IO (BL.ByteString) readFile2BL = readFile2BLGen [] +-- | Like 'readFile2BL', but reads only first @n@ symbols specified with the first 'Int64' argument.+readFile2BLN :: Int64 -> FilePath -> IO (BL.ByteString)+readFile2BLN n = readFile2BLGenN n []++-- | Like 'readFile2BL', but reads only first @n@ symbols specified with the second 'Int64' argument dropping before this the first @m@ symbols specified +-- with the first 'Int64' argument.+readFile2BLMN :: Int64 -> Int64 -> FilePath -> IO (BL.ByteString)+readFile2BLMN m n = readFile2BLGenMN m n []+ -- | After reading a file into a filtered lazy 'BL.ByteString' (see, 'readFile2BLGen') converts the resulting 'BL.ByteString' into a 'V.Vector'  -- of 'Int'. The arguments have the same meaning as for 'readFile2BLGen'. readFileDoublesGen :: String -> FilePath -> IO (V.Vector Int) readFileDoublesGen ys = fmap (takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile +-- | Like 'readFileDoublesGen', but returns only first @n@ elements of the 'V.Vector' specified with the first 'Int64' argument.+readFileDoublesGenN :: Int64 -> String -> FilePath -> IO (V.Vector Int)+readFileDoublesGenN n ys = fmap (V.unsafeSlice 0 (fromIntegral n - 1) . takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile++-- | Like 'readFileDoublesGen', but returns only first @n@ symbols specified with the second 'Int64' argument dropping before this the first @m@ symbols specified +-- with the first 'Int64' argument.+readFileDoublesGenMN :: Int64 -> Int64 -> String -> FilePath -> IO (V.Vector Int)+readFileDoublesGenMN m n ys = fmap (V.unsafeSlice (fromIntegral m - 1) (fromIntegral n - 1) . takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile+ -- | Usual way the function 'readFileDoublesGen' is used. The text in a file being read is treated as a properly typed (entered) one. So there is no  -- keyboard layout conversion at all. readFileDoubles :: FilePath -> IO (V.Vector Int) readFileDoubles = readFileDoublesGen [] +-- | Like 'readFileDoubles', but returns only first @n@ elements of the 'V.Vector' specified with the first 'Int64' argument.+readFileDoublesN :: Int64 -> FilePath -> IO (V.Vector Int)+readFileDoublesN n = readFileDoublesGenN n [] +-- | Like 'readFileDoubles', but returns only first @n@ elements of the 'V.Vector' specified with the second 'Int64' argument +-- dropping before this the first @m@ elements specified with the first 'Int64' argument.+readFileDoublesMN :: Int64 -> Int64 -> FilePath -> IO (V.Vector Int)+readFileDoublesMN m n = readFileDoublesGenMN m n []
dobutokO2.cabal view
@@ -2,8 +2,8 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO2-version:             0.33.0.0-synopsis:            A program and a library to create experimental music from a mono audio and a Ukrainian text+version:             0.34.0.0+synopsis:            A program and a library to create experimental music from a file and a Ukrainian text description:         It can also create a timbre for the notes. Uses SoX inside. homepage:            https://hackage.haskell.org/package/dobutokO2 license:             MIT