packages feed

algorithmic-composition-basic 0.5.0.0 → 0.6.0.0

raw patch · 5 files changed

+71/−70 lines, 5 filesdep +ukrainian-phonetics-basic-arraydep −bytestringdep −ukrainian-phonetics-basic-array-bytestringdep ~directorydep ~foldable-ixdep ~mmsyn2-arrayPVP ok

version bump matches the API change (PVP)

Dependencies added: ukrainian-phonetics-basic-array

Dependencies removed: bytestring, ukrainian-phonetics-basic-array-bytestring

Dependency ranges changed: directory, foldable-ix, mmsyn2-array, mmsyn3, mmsyn7l, mmsyn7ukr-common, process, process-sequential

API changes (from Hackage documentation)

- Composition.Sound.Functional.Params: strToIntG :: Intervals -> Char -> Int
+ Composition.Sound.Functional.Params: strToIntG :: Intervals -> Sound8 -> Int
- Composition.Sound.Functional.Params: vStrToVIntG :: Intervals -> String -> Intervals
+ Composition.Sound.Functional.Params: vStrToVIntG :: Intervals -> FlowSound -> Intervals
- Composition.Sound.Keyboard: convH :: String -> (ByteString -> ByteString) -> ByteString -> ByteString
+ Composition.Sound.Keyboard: convH :: String -> (String -> String) -> String -> String
- Composition.Sound.Keyboard: dvorak2qwerty :: ByteString -> ByteString
+ Composition.Sound.Keyboard: dvorak2qwerty :: String -> String
- Composition.Sound.Keyboard: input2BL :: IO ByteString
+ Composition.Sound.Keyboard: input2BL :: IO String
- Composition.Sound.Keyboard: input2BLMN :: Int64 -> Int64 -> IO ByteString
+ Composition.Sound.Keyboard: input2BLMN :: Int -> Int -> IO String
- Composition.Sound.Keyboard: input2BLN :: Int64 -> IO ByteString
+ Composition.Sound.Keyboard: input2BLN :: Int -> IO String
- Composition.Sound.Keyboard: qwerty2dvorak :: ByteString -> ByteString
+ Composition.Sound.Keyboard: qwerty2dvorak :: String -> String
- Composition.Sound.Keyboard: readFile2BL :: FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BL :: FilePath -> IO String
- Composition.Sound.Keyboard: readFile2BLGen :: String -> FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BLGen :: String -> FilePath -> IO String
- Composition.Sound.Keyboard: readFile2BLGenMN :: Int64 -> Int64 -> String -> FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BLGenMN :: Int -> Int -> String -> FilePath -> IO String
- Composition.Sound.Keyboard: readFile2BLGenN :: Int64 -> String -> FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BLGenN :: Int -> String -> FilePath -> IO String
- Composition.Sound.Keyboard: readFile2BLMN :: Int64 -> Int64 -> FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BLMN :: Int -> Int -> FilePath -> IO String
- Composition.Sound.Keyboard: readFile2BLN :: Int64 -> FilePath -> IO ByteString
+ Composition.Sound.Keyboard: readFile2BLN :: Int -> FilePath -> IO String
- Composition.Sound.Keyboard: readFileDoublesGenMN :: Int64 -> Int64 -> String -> FilePath -> IO [Int]
+ Composition.Sound.Keyboard: readFileDoublesGenMN :: Int -> Int -> String -> FilePath -> IO [Int]
- Composition.Sound.Keyboard: readFileDoublesGenN :: Int64 -> String -> FilePath -> IO [Int]
+ Composition.Sound.Keyboard: readFileDoublesGenN :: Int -> String -> FilePath -> IO [Int]
- Composition.Sound.Keyboard: readFileDoublesMN :: Int64 -> Int64 -> FilePath -> IO [Int]
+ Composition.Sound.Keyboard: readFileDoublesMN :: Int -> Int -> FilePath -> IO [Int]
- Composition.Sound.Keyboard: readFileDoublesN :: Int64 -> FilePath -> IO [Int]
+ Composition.Sound.Keyboard: readFileDoublesN :: Int -> FilePath -> IO [Int]
- Composition.Sound.Keyboard: takeDoubles :: ByteString -> [Int]
+ Composition.Sound.Keyboard: takeDoubles :: String -> [Int]

Files

CHANGELOG.md view
@@ -49,3 +49,8 @@  * Fifth version. Switched to the ukrainian-phonetics-basic-array-bytestring package as its dependency. No code revision done. +## 0.6.0.0 -- 2022-08-17++* Sixth version. Changed the dependencies so not to use bytestring functionality. Updated the+dependencies boundaries to support the latest GHC-9.* series. Some code changes.+
Composition/Sound/Functional/Params.hs view
@@ -65,8 +65,8 @@ import System.Exit import EndOfExe import System.Directory-import Languages.Phonetic.Ukrainian.Syllable.Arr-import Melodics.ByteString.Ukrainian.Arr+import Languages.Phonetic.Ukrainian.Syllable.ArrInt8+import Melodics.Ukrainian.ArrInt8 import Sound.SoXBasics (upperBnd,selMaxAbs) import MMSyn7l import qualified Data.Foldable as F@@ -96,15 +96,12 @@ -- and sonorous consonants gives \"-\" sign (-1). \"сь\" and \"ць\" gives "0". Other symbols are not taken into account. signsFromString :: Int -> String -> Array Int Int signsFromString n1 =-  (\rs -> listArray (0,length rs - 1) rs) . take n1 . concatMap (fmap (\case-      UZ _ W -> 1-      UZ _ D -> 1-      UZ _ K -> 1-      UZ _ L -> (-1)-      UZ _ M -> (-1)-      UZ _ S -> (-1)-      UZ _ O -> (-1)-      _ -> 0) . concat) . createSyllablesUkrS . take (3 * n1) . cycle+  (\rs -> listArray (0,length rs - 1) rs) . take n1 . concatMap (fmap g) . concat . createSyllablesUkrS . take (3 * n1) . cycle+     where g t +            | t > 0 && t < 27 = 1+            | isSonorous1 t = -1+            | isVoicelessC1 t = -1+            | otherwise = 0  -- | Generalized version of the 'overSoXSynthGen2FDN_SG4G' where instead of lifting with 'liftInEnkuV' 'liftInParamsV' is used. It allows e. g. to -- use some tonality. For more information, please, refer to 'filterInParams'.@@ -499,7 +496,7 @@ -- For more information, please, refer to 'soxBasicParams'. overSoXSynth2FDN_Sf32G :: (Float -> OvertonesO) -> (Float, Float, Float) -> Int -> String -> Array Int Float -> String -> IO () overSoXSynth2FDN_Sf32G f (x, y, t0) j zs vdB ys- | null . convertToProperUkrainianS $ zs = overSoXSynthG f x+ | null . convertToProperUkrainianI8 $ zs = overSoXSynthG f x  | otherwise = do     let l0    = length zs     soundGenF32G [\x2 -> closestNote (if x2 /= 0.0 then abs x2 else unsafeAt notes 0),\x2 -> fromMaybe (unsafeAt notes 0)@@ -509,22 +506,22 @@  -- | Function is used to get numbers of intervals from a Ukrainian 'String'. It is used internally in the 'uniqOverSoXSynthN4' function. intervalsFromString :: String -> Intervals-intervalsFromString = vStrToVIntG defInt . convertToProperUkrainianS+intervalsFromString = vStrToVIntG defInt . convertToProperUkrainianI8  -- | Generatlized version of the 'vStrToVInt' with a possibility to specify your own 'Intervals'.-vStrToVIntG :: Intervals -> String -> Intervals+vStrToVIntG :: Intervals -> FlowSound -> Intervals vStrToVIntG v xs = listArray (0,l) . map (strToIntG v) $ xs  where l = length xs - 1  -- | Default values for 'strToInt'. All the intervals are not greater than one full octave. defInt :: Intervals-defInt = listArray (0,28) [5,3,7,11,1,12,4,11,4,12,2,9,3,12,5,10,7,7,7,12,10,7,10,2,12,7,2,12,8]+defInt = listArray (0,49) [5,3,7,11,1,12,4,11,4,12,2,9,3,12,5,10,7,7,7,12,10,7,10,2,12,7,2,12,8,3,7,12,5,4,10,4,7,7,5,2,9,8,3,5,7,11,12,4,9,12] {-# INLINE defInt #-}  -- | Generatlized version of the 'strToInt' with a possibility to specify your own 'Intervals'.-strToIntG :: Intervals -> Char -> Int+strToIntG :: Intervals  ->Sound8 -> Int strToIntG v =-  getBFstLSorted' 0 (zip "ABCEFabcdefghijklmnoprstuvxyz" . elems $ v)+  getBFstLSorted' 0 (zip [1,2,3,4,5,6,8,9,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54] . elems $ v) {-# INLINE strToIntG #-}  -- | Generates a melodic line (a somewhat complex changing sound) with a possibility to specify sound quality using the 'String' argument. For more information,
Composition/Sound/Keyboard.hs view
@@ -40,55 +40,54 @@ import GHC.Arr import Data.Foldable.Ix 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 list of 'Int' using 'hashStr2'. -takeDoubles :: BL.ByteString -> [Int]-takeDoubles xs = BL.zipWith hashStr2 xs $ BL.tail xs+-- | Converts a lazy 'String' into a list of 'Int' using 'hashStr2'. +takeDoubles :: String -> [Int]+takeDoubles xs = zipWith hashStr2 xs $ tail xs  -- | Converts a string of lowercase ASCII letters being typed on the QWERTY keyboard layout into corresponding Dvorak keyboard layout.-qwerty2dvorak :: BL.ByteString -> BL.ByteString-qwerty2dvorak = BL.map (getBFstL' ' ' (zip ("/;<>" ++ ['a'..'z']) "wvszaxje.uidchtnmbrl'poygk,qf;"))+qwerty2dvorak :: String -> String+qwerty2dvorak = map (getBFstL' ' ' (zip ("/;<>" ++ ['a'..'z']) "wvszaxje.uidchtnmbrl'poygk,qf;"))  -- | Vice versa to 'qwerty2dvorak'.-dvorak2qwerty :: BL.ByteString -> BL.ByteString-dvorak2qwerty = BL.map (getBFstL' ' ' (zip ("',.;" ++ ['a'..'z']) "qwezanihdyujgcvpmlsrxo;kf.,bt/"))+dvorak2qwerty :: String -> String+dvorak2qwerty = map (getBFstL' ' ' (zip ("',.;" ++ ['a'..'z']) "qwezanihdyujgcvpmlsrxo;kf.,bt/"))  -- | Hashes two lower case ascii characters. Is used for controlling frequencies and operators. hashStr2 :: Char -> Char -> Int hashStr2 x y = getBFstLSorted' 57 (zip ['a'..'z'] . map (\t -> getBFstLSorted' (26 * t + 18) (zip ['a'..'z'] [(26 * t + 4)..]) y) .    concat $ [[0],[6..8],[1],[9..11],[4],[12..16],[2],[17..21],[3],[22..24],[5,25]]) x -- 679 is the greatest value ~ \"zz\"; there are 572 effectful val. --- | Get contents into lazy 'BL.ByteString' with filtering of all characters that are not a lower case ascii letters.-input2BL :: IO (BL.ByteString)-input2BL = fmap (convH [] (BL.filter isAsciiLower)) BL.getContents+-- | Get contents into lazy 'String' with filtering of all characters that are not a lower case ascii letters.+input2BL :: IO (String)+input2BL = fmap (convH [] (filter isAsciiLower)) 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 first 'Int' argument.+input2BLN :: Int -> IO (String)+input2BLN n = fmap (convH [] (take n . filter isAsciiLower)) 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+-- | Like 'input2BL', but takes only first @n@ symbols specified with the second 'Int' argument dropping before this the first @m@ symbols specified +-- with the first 'Int' argument.+input2BLMN :: Int -> Int -> IO (String)+input2BLMN m n = fmap (convH [] (take n . drop m . filter isAsciiLower)) 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 +-- | Reads a given file into a lazy 'String' 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+readFile2BLGen :: String -> FilePath -> IO (String)+readFile2BLGen ys = fmap (convH ys (filter isAsciiLower)) . 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 first 'Int' argument.+readFile2BLGenN :: Int -> String -> FilePath -> IO (String)+readFile2BLGenN n ys = fmap (convH ys (take n . filter isAsciiLower)) . 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+-- | Like 'readFile2BLGen', but reads only first @n@ symbols specified with the second 'Int' argument dropping before this the first @m@ symbols specified +-- with the first 'Int' argument.+readFile2BLGenMN :: Int -> Int -> String -> FilePath -> IO (String)+readFile2BLGenMN m n ys = fmap (convH ys (take n . drop m . filter isAsciiLower)) . readFile --- | Auxiliary function to define how is a 'BL.ByteString' treated, see 'readFile2BLGen'.-convH :: String -> (BL.ByteString -> BL.ByteString) -> (BL.ByteString -> BL.ByteString)+-- | Auxiliary function to define how is a 'String' treated, see 'readFile2BLGen'.+convH :: String -> (String -> String) -> (String -> String) convH ys f   | null ys = f  | ys == "q" = qwerty2dvorak . f@@ -96,34 +95,34 @@    -- | Usual way the function 'readFile2BLGen' 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.-readFile2BL :: FilePath -> IO (BL.ByteString)+readFile2BL :: FilePath -> IO (String) readFile2BL = readFile2BLGen [] {-# INLINE readFile2BL #-} --- | Like 'readFile2BL', but reads only first @n@ symbols specified with the first 'Int64' argument.-readFile2BLN :: Int64 -> FilePath -> IO (BL.ByteString)+-- | Like 'readFile2BL', but reads only first @n@ symbols specified with the first 'Int' argument.+readFile2BLN :: Int -> FilePath -> IO (String) readFile2BLN n = readFile2BLGenN n [] {-# INLINE readFile2BLN #-} --- | 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)+-- | Like 'readFile2BL', but reads only first @n@ symbols specified with the second 'Int' argument dropping before this the first @m@ symbols specified +-- with the first 'Int' argument.+readFile2BLMN :: Int -> Int -> FilePath -> IO (String) readFile2BLMN m n = readFile2BLGenMN m n [] {-# INLINE readFile2BLMN #-} --- | After reading a file into a filtered lazy 'BL.ByteString' (see, 'readFile2BLGen') converts the resulting 'BL.ByteString' into a list+-- | After reading a file into a filtered lazy 'String' (see, 'readFile2BLGen') converts the resulting 'String' into a list -- of 'Int'. The arguments have the same meaning as for 'readFile2BLGen'. readFileDoublesGen :: String -> FilePath -> IO [Int]-readFileDoublesGen ys = fmap (takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile+readFileDoublesGen ys = fmap (takeDoubles . convH ys (filter isAsciiLower)) . readFile --- | Like 'readFileDoublesGen', but returns only first @n@ elements of the list specified with the first 'Int64' argument.-readFileDoublesGenN :: Int64 -> String -> FilePath -> IO [Int]-readFileDoublesGenN n ys = fmap (take (fromIntegral n) . takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile+-- | Like 'readFileDoublesGen', but returns only first @n@ elements of the list specified with the first 'Int' argument.+readFileDoublesGenN :: Int -> String -> FilePath -> IO [Int]+readFileDoublesGenN n ys = fmap (take (fromIntegral n) . takeDoubles . convH ys (filter isAsciiLower)) . 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 [Int]-readFileDoublesGenMN m n ys = fmap (s2L (fromIntegral m) (fromIntegral n) . takeDoubles . convH ys (BL.filter isAsciiLower)) . BL.readFile+-- | Like 'readFileDoublesGen', but returns only first @n@ symbols specified with the second 'Int' argument dropping before this the first @m@ symbols specified +-- with the first 'Int' argument.+readFileDoublesGenMN :: Int -> Int -> String -> FilePath -> IO [Int]+readFileDoublesGenMN m n ys = fmap (s2L (fromIntegral m) (fromIntegral n) . takeDoubles . convH ys (filter isAsciiLower)) . 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.@@ -131,13 +130,13 @@ readFileDoubles = readFileDoublesGen [] {-# INLINE readFileDoubles #-} --- | Like 'readFileDoubles', but returns only first @n@ elements of the list specified with the first 'Int64' argument.-readFileDoublesN :: Int64 -> FilePath -> IO [Int]+-- | Like 'readFileDoubles', but returns only first @n@ elements of the list specified with the first 'Int' argument.+readFileDoublesN :: Int -> FilePath -> IO [Int] readFileDoublesN n = readFileDoublesGenN n [] {-# INLINE readFileDoublesN #-} --- | Like 'readFileDoubles', but returns only first @n@ elements of the list specified with the second 'Int64' argument --- dropping before this the first @m@ elements specified with the first 'Int64' argument.-readFileDoublesMN :: Int64 -> Int64 -> FilePath -> IO [Int]+-- | Like 'readFileDoubles', but returns only first @n@ elements of the list specified with the second 'Int' argument +-- dropping before this the first @m@ elements specified with the first 'Int' argument.+readFileDoublesMN :: Int -> Int -> FilePath -> IO [Int] readFileDoublesMN m n = readFileDoublesGenMN m n [] {-# INLINE readFileDoublesMN #-}
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020-2021 OleksandrZhabenko+Copyright (c) 2020-2022 Oleksandr Zhabenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
algorithmic-composition-basic.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                algorithmic-composition-basic-version:             0.5.0.0+version:             0.6.0.0 synopsis:            Helps to create experimental music from a file (or its part) and a Ukrainian text. description:         It can also generate a timbre for the notes. Uses SoX inside. homepage:            https://hackage.haskell.org/package/algorithmic-composition-basic@@ -20,6 +20,6 @@   exposed-modules:     Composition.Sound.IntermediateF, Composition.Sound.Keyboard, Composition.Sound.Functional.Basics, Composition.Sound.Functional.Params, Composition.Sound.Functional.Elements   -- other-modules:   other-extensions:    BangPatterns-  build-depends:       base >=4.8 && <5, bytestring >= 0.10.6 && <1, process >=1.4 && <1.9, mmsyn3 >=0.1.5 && <1,  directory >=1.2.7 && <1.7, mmsyn7ukr-common >=0.1.1 && <1, mmsyn2-array >=0.3 && <1, ukrainian-phonetics-basic-array-bytestring >=0.1 && <1, mmsyn7l >=0.9 && <1, foldable-ix >=0.2 && <1, process-sequential >=0.1.1 && <1+  build-depends:       base >=4.8 && <5, process >=1.4 && <2, mmsyn3 ==0.1.6.0,  directory >=1.2.7 && <2, mmsyn7ukr-common ==0.2.0.0, mmsyn2-array ==0.3.0.0, ukrainian-phonetics-basic-array ==0.6.0.0, mmsyn7l ==0.9.1.0, foldable-ix ==0.2.1.0, process-sequential ==0.1.2.0   -- hs-source-dirs:   default-language:    Haskell2010