mmsyn7l 0.3.2.0 → 0.4.0.0
raw patch · 5 files changed
+103/−53 lines, 5 filesdep +directorydep ~mmsyn7ukrPVP ok
version bump matches the API change (PVP)
Dependencies added: directory
Dependency ranges changed: mmsyn7ukr
API changes (from Hackage documentation)
+ MMSyn7l: adjustVolRes :: [String] -> IO ()
- MMSyn7l: changeVolume :: FilePath -> IO ()
+ MMSyn7l: changeVolume :: Int -> FilePath -> IO ()
Files
- CHANGELOG.md +6/−0
- MMSyn7l.hs +76/−44
- Main.hs +12/−5
- README.markdown +6/−1
- mmsyn7l.cabal +3/−3
CHANGELOG.md view
@@ -47,3 +47,9 @@ ## 0.3.2.0 -- 2020-01-30 * Third version revised B. Changed README file to README.markdown.++## 0.4.0.0 -- 2020-03-25++* Fourth version. Added new command line option variant "-r" and changed MMSyn7l.changeVolume function. Added for this purpose a new function 'adjustVolRes'.+Added directory as an explicit dependency (earlier it has been implicit as a dependency for mmsyn7ukr package). Changed information in the README.markdown+file appropriately.
MMSyn7l.hs view
@@ -6,11 +6,14 @@ -- Maintainer : olexandr543@yahoo.com -- -- A program and a library to modify the amplitude of the sound representations for --- the Ukrainian language created by mmsyn7ukr package or somehow otherwise.+-- the Ukrainian language created by mmsyn7ukr package or somehow otherwise. Besides+-- it can be used to adjust volume for the sequential \"result*.wav\" files. -- module MMSyn7l where +import qualified Data.List as L (sort,isPrefixOf)+import System.Directory (listDirectory) import Data.Char (toUpper, isDigit) import qualified SoXBasics as SB import qualified SoXBasics1 as SB1@@ -49,53 +52,60 @@ -- the @String@ has as a first element the \'-\' @Char@ (the sound decreases), -- then everything is analogously the same, but an interval between the -- maximum by modulus amplitude value and 0.0 is divided into 10 equal parts --- and so on.-changeVolume :: FilePath -> IO ()-changeVolume file = do+-- and so on. 'Int' parameter is used to control the informational output+-- (to get it, specify 1). +changeVolume :: Int -> FilePath -> IO ()+changeVolume n file = do SB.playA file- let sound = getBFst' ("е", V.fromList . zip ["A.wav", "B.wav", "C.wav", "D.wav", "E.wav", "F.wav", "G.wav", "H.wav", - "I.wav", "J.wav", "K.wav", "L.wav", "M.wav", "N.wav", "O.wav", "P.wav", "Q.wav", "R.wav", + case n of+ 1 -> do + let sound = getBFst' ("е", V.fromList . zip ["A.wav", "B.wav", "C.wav", "D.wav", "E.wav", "F.wav", "G.wav", "H.wav", + "I.wav", "J.wav", "K.wav", "L.wav", "M.wav", "N.wav", "O.wav", "P.wav", "Q.wav", "R.wav", "S.wav", "T.wav", "U.wav", "V.wav", "W.wav", "X.wav", "Y.wav", "Z.wav", "a.wav", "b.wav", "c.wav", "d.wav", "e.wav", "f.wav"] $ ["а","б","в","г","д","дж","дз", "е","ж","з","и","й","к","л","м","н","о","п","р", "с","сь","т","у","ф","х","ц","ць","ч","ш","ь","і","ґ"]) file- putStrLn $ "You can now change the volume for the played sound representation for the Ukrainian sound " ++ show (map toUpper sound)- putStrLn ""- putStr "Please, specify the change by passing a String of digits (with may be a preceding symbol \'-\'). "- putStr ""- putStr "For the proper proceeding you specify a String, which consists of 4 "- putStr "digits (and it may be preceded by a symbol \"-\"). If the String "- putStr "begins with the \"-\", then a sound amplitude decreases, otherwise "- putStr "the amplitude increases. The level of increase / decrease is "- putStr "determined by the magnitude of the absolute value of integer numbers. "- putStr "The greater is the number -- the greater is the amplitude change. "- putStr "The count begins with \"0000\" and ends with \"9999\" (the sign is not "- putStr "taken into consideration). If there is less than 4 digits in a String, "- putStr "then the String is equivalent to that one with the appropriate number "- putStr "of zeroes preceding to fulfill to the 4 needed digits (for example, "- putStr "\"657\" is equivalent to \"0657\", \"-2\" is equivalent to \"-0002\" etc.). "- putStr "In such a case, for the Strings without the "- putStr "initial sign \"-\" (the sound increases) an interval between the "- putStr "maximum by modulus value of the amlitude (which is represented by the "- putStr "parts of 1) and 1.0 is divided into 10 equal parts (starting a count "- putStr "from 0) and then that one of them is selected, which has a number "- putStr "determined by the first digit in the String writing. Then (if specified "- putStr "further) the interval between this amplitude value and a value, "- putStr "which corresponds to the selection on the previous step the next "- putStr "first digit in the writing (for example, after \"4\" -- \"5\", "- putStr "after \"7\" -- \"8\" etc.), greater by 1 than the actually selected one, "- putStr "is also divided again into 10 equal parts and that one is selected, "- putStr "which corresponds to the number determined by the second digit in the "- putStr "String writing (again beginning with \"0\" and ending with \"9\") and so on "- putStr "until the 4th level. The greater exactness is not needed because our "- putStr "hearing ability hardly distinguish such a subtle sound changes. If "- putStr "the String has as a first element the \'-\' Char (the sound decreases), "- putStr "then everything is analogously the same, but an interval between the "- putStr "maximum by modulus amplitude value and 0.0 is divided into 10 equal parts "- putStrLn "and so on. "- onException (specifyVol file) (do+ putStrLn $ "You can now change the volume for the played sound representation for the Ukrainian sound " ++ show (map toUpper sound) putStrLn ""- putStrLn "Something went wrong for the sound representation, please, check the input value and repeat once more! "- specifyVol file)+ putStr "Please, specify the change by passing a String of digits (with may be a preceding symbol \'-\'). "+ putStr ""+ putStr "For the proper proceeding you specify a String, which consists of 4 "+ putStr "digits (and it may be preceded by a symbol \"-\"). If the String "+ putStr "begins with the \"-\", then a sound amplitude decreases, otherwise "+ putStr "the amplitude increases. The level of increase / decrease is "+ putStr "determined by the magnitude of the absolute value of integer numbers. "+ putStr "The greater is the number -- the greater is the amplitude change. "+ putStr "The count begins with \"0000\" and ends with \"9999\" (the sign is not "+ putStr "taken into consideration). If there is less than 4 digits in a String, "+ putStr "then the String is equivalent to that one with the appropriate number "+ putStr "of zeroes preceding to fulfill to the 4 needed digits (for example, "+ putStr "\"657\" is equivalent to \"0657\", \"-2\" is equivalent to \"-0002\" etc.). "+ putStr "In such a case, for the Strings without the "+ putStr "initial sign \"-\" (the sound increases) an interval between the "+ putStr "maximum by modulus value of the amlitude (which is represented by the "+ putStr "parts of 1) and 1.0 is divided into 10 equal parts (starting a count "+ putStr "from 0) and then that one of them is selected, which has a number "+ putStr "determined by the first digit in the String writing. Then (if specified "+ putStr "further) the interval between this amplitude value and a value, "+ putStr "which corresponds to the selection on the previous step the next "+ putStr "first digit in the writing (for example, after \"4\" -- \"5\", "+ putStr "after \"7\" -- \"8\" etc.), greater by 1 than the actually selected one, "+ putStr "is also divided again into 10 equal parts and that one is selected, "+ putStr "which corresponds to the number determined by the second digit in the "+ putStr "String writing (again beginning with \"0\" and ending with \"9\") and so on "+ putStr "until the 4th level. The greater exactness is not needed because our "+ putStr "hearing ability hardly distinguish such a subtle sound changes. If "+ putStr "the String has as a first element the \'-\' Char (the sound decreases), "+ putStr "then everything is analogously the same, but an interval between the "+ putStr "maximum by modulus amplitude value and 0.0 is divided into 10 equal parts "+ putStrLn "and so on. "+ onException (specifyVol file) (do+ putStrLn ""+ putStrLn "Something went wrong for the sound representation, please, check the input value and repeat once more! "+ specifyVol file)+ _ -> onException (specifyVol file) (do+ putStrLn ""+ putStrLn "Something went wrong for the sound representation, please, check the input value and repeat once more! "+ specifyVol file) -- | Function 'specifyVol' is used internally in the 'changeVolume' to get the @String@ and to apply the needed change. specifyVol :: FilePath -> IO ()@@ -148,4 +158,26 @@ ratio = 1.0 + (delta / ampl) * coefA SB1.volS file (ratio * ampl) else catchEnd (StrangeAnswer "SoXBasics1" "volS")- ++-- | Works with the \"result*.wav\" files in the current directory: it adjusts volume levels for the sequence of them starting from the +-- first argument in a list and ending with the second one (if specified). If there is no first -- all such files are adjusted; if there is no second one -- +-- the files are adjusted to the last one. Count starts at 0. +adjustVolRes :: [String] -> IO ()+adjustVolRes args = do+ dir <- listDirectory "."+ let dirV0 = L.sort . filter (L.isPrefixOf "result") $ dir+ dirV = V.fromList dirV0+ first0 = concat . take 1 . drop 1 $ args+ last0 = concat . take 1 . drop 2 $ args+ idxAllN = V.length dirV - 1+ onException (do { + let first1 = read first0::Int+ last1 = read last0::Int+ first2 = min (abs first1) (abs last1)+ last2 = max (abs first1) (abs last1)+ first = if compare first2 idxAllN == GT then 0 else first2+ last = if compare last2 idxAllN == GT then idxAllN else last2+ ; mapM_ (changeVolume 1) (V.unsafeSlice first last dirV)+ ; putStrLn ""+ ; putStrLn "Now you have changed (or left unchanged) the amplitudes for the needed \"result*.wav\" sound files." }) (do+ error "Please, specify a right numbers for the first and last files to be adjusted starting count from 0.")
Main.hs view
@@ -6,12 +6,14 @@ -- Maintainer : olexandr543@yahoo.com -- -- A program and a library to modify the amplitudes of the sound representations for --- the Ukrainian language created by mmsyn7ukr package or somehow otherwise.+-- the Ukrainian language created by mmsyn7ukr package or somehow otherwise. Besides+-- it can be used to adjust volume for the sequential \"result*.wav\" files. -- module Main where -import MMSyn7l (changeVolume)+import Control.Exception (onException)+import MMSyn7l (changeVolume,adjustVolRes) import qualified Data.Vector as V import CaseBi (getBFst') import System.Environment (getArgs)@@ -26,7 +28,7 @@ [] -> do putStrLn "Now you can change the amplitude of the sound representations of the Ukrainian sounds (or something similar). " putStrLn ""- mapM_ changeVolume ["A.wav", "B.wav", "C.wav", "D.wav", "E.wav", "F.wav", "G.wav", "H.wav", + mapM_ (changeVolume 1) ["A.wav", "B.wav", "C.wav", "D.wav", "E.wav", "F.wav", "G.wav", "H.wav", "I.wav", "J.wav", "K.wav", "L.wav", "M.wav", "N.wav", "O.wav", "P.wav", "Q.wav", "R.wav", "S.wav", "T.wav", "U.wav", "V.wav", "W.wav", "X.wav", "Y.wav", "Z.wav", "a.wav", "b.wav", "c.wav", "d.wav", "e.wav", "f.wav"]@@ -37,15 +39,20 @@ putStrLn "SYNOPSYS: " putStrLn "mmsyn7l -h OR" putStrLn "mmsyn7l -v OR"+ putStrLn "mmsyn7l -r [number-of-the-first-file-to-be-volume-adjusted [number-of-the-last-file-to-be-volume-adjusted]] OR" putStrLn "mmsyn7l [list-of-needed-sounds-to-be-amplitude-modified]" putStrLn "\"-h\" prints this message." putStrLn "\"-v\" prints version number of the program."+ putStr "\"-r\" works with the \"result*.wav\" files in the current directory: it adjusts a volume for the sequence of them starting from the "+ putStr "first argument and ending with the second (if specified). If there is no first -- all such files are adjusted; if there is no second one -- "+ putStrLn "the files are adjusted to the last one. Count starts at 0. " putStr "[list-of-needed-sounds-to-be-amplitude-modified (if given) -- the program modifies the amplitudes in the interactive mode only for the " putStrLn "given sound representations. If not specified, the program modifies the amplitudes for all non-pause Ukrainian sounds representations." putStrLn "" ("-v":_) -> do- putStrLn "mmsyn7l version: 0.3.2.0"+ putStrLn "mmsyn7l version: 0.4.0.0" putStrLn ""+ ("-r":_) -> adjustVolRes . drop 1 $ args _ -> do putStrLn "Now you can change the amplitude of the needed sound representations of the Ukrainian sounds (or something similar). " putStrLn ""@@ -58,7 +65,7 @@ "I.wav", "J.wav", "K.wav", "L.wav", "M.wav", "N.wav", "O.wav", "P.wav", "Q.wav", "R.wav", "S.wav", "T.wav", "U.wav", "V.wav", "W.wav", "X.wav", "Y.wav", "Z.wav", "a.wav", "b.wav", "c.wav", "d.wav", "e.wav", "f.wav"])) zss- mapM_ changeVolume wws+ mapM_ (changeVolume 1) wws putStrLn "" putStrLn "Now you have changed (or left unchanged) the amplitudes for the needed sound representations for the Ukrainian language. " putStrLn "Please, remember about responsible usage especially in case of processing the real voice sound samples! "
README.markdown view
@@ -35,7 +35,7 @@ ***** Command Line Arguments ***** ---------------------------------- -If you specify a command line argument (other than "-h" or "-v"),+If you specify a command line argument (other than "-h", "-r", or "-v"), it must be a sorted list of the Ukrainian sounds representations, which can be obtained by using the mmsyn7s package. For more information, please, refer to:@@ -47,5 +47,10 @@ sounds representations in the current directory. The "-h" command line argument is used for the help informational message.+ The "-v" command line argument is used for the version number.++The "-r" command line argument is used to work with "result*.wav" files to adjust+their volume. You can additionally specify the numbers for the first and for+the last files to be adjusted.
mmsyn7l.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn7l-version: 0.3.2.0+version: 0.4.0.0 synopsis: Modifies the amplitudes of the Ukrainian sounds representations created by mmsyn7ukr package. description: A program and a library to modify the amplitudes of the Ukrainian sounds representations created by mmsyn7ukr package or somehow otherwise. homepage: https://hackage.haskell.org/package/mmsyn7l@@ -20,7 +20,7 @@ exposed-modules: Main, MMSyn7l -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.14, mmsyn7ukr >=0.11 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1+ build-depends: base >=4.7 && <4.14, mmsyn7ukr >=0.15.3 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1, directory >=1.2.7 && <2 -- hs-source-dirs: default-language: Haskell2010 @@ -28,6 +28,6 @@ main-is: Main.hs -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.14, mmsyn7ukr >=0.11 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1+ build-depends: base >=4.7 && <4.14, mmsyn7ukr >=0.15.3 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1, directory >=1.2.7 && <2 -- hs-source-dirs: default-language: Haskell2010