mmsyn7l (empty) → 0.1.0.0
raw patch · 7 files changed
+263/−0 lines, 7 filesdep +basedep +directorydep +mmsyn2setup-changed
Dependencies added: base, directory, mmsyn2, mmsyn7ukr, vector
Files
- CHANGELOG.md +5/−0
- LICENSE +20/−0
- MMSyn7l.hs +148/−0
- Main.hs +29/−0
- README +26/−0
- Setup.hs +2/−0
- mmsyn7l.cabal +33/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for mmsyn7l++## 0.1.0.0 -- 2020-01-07++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2020 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ MMSyn7l.hs view
@@ -0,0 +1,148 @@+-- |+-- Module : MMSyn7l+-- Copyright : (c) OleksandrZhabenko 2020+-- License : MIT+--+-- 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.+--++module MMSyn7l where++import Data.Char (toUpper, isDigit)+import System.Directory+import SoXBasics+import qualified Data.Vector as V+import Control.Exception (onException)+import CaseBi (getBFst')++-- | Function 'changeVolume' is used to change the amplitude of the sound. +-- For the proper proceeding you specify a @String@, which consists of 4 +-- digits (and it may be preceeded by a symbol \"-\"). If the @String@ +-- begins with the \"-\", then a sound amplitude decreases, otherwise +-- the amplitude increases. The level of increase / decrease is +-- determined by the magnitude of the absolute value of integer numbers. +-- The greater is the number -- the greater is the amplitude change. +-- The count begins with \"0000\" and ends with \"9999\" (the sign is not +-- taken into consideration). In such a case, for the @String@s without the +-- initial sign \"-\" (the sound increases) an interval between the +-- maximum by modulus value of the amlitude (which is represented by the +-- parts of 1) and 1.0 is divided into 10 equal parts (starting a count +-- from 0) and then that one of them is selected, which has a number +-- determined by the first digit in the @String@ writing. Then (if specified +-- further) the interval between this amplitude value and a value, +-- which corresponds to the selection on the previous step the next +-- first digit in the writing (for example, after \"4\" -- \"5\", +-- after \"7\" -- \"8\" etc.), greater by 1 than the actually selected one, +-- is also divided again into 10 equal parts and that one is selected, +-- which corresponds to the number determined by the second digit in the +-- String writing (again beginning with \"0\" and ending with \"9\") and so on +-- until the 4th level. The greater exactness is not needed because our +-- hearing ability hardly distinguish such a subtle sound changes. If +-- 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+ 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", + "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 preceeding symbol \'-\'). "+ putStr ""+ putStr "For the proper proceeding you specify a String, which consists of 4 "+ putStr "digits (and it may be preceeded 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). 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)++-- | Function 'specifyVol' is used internally in the 'changeVolume' to get the @String@ and to apply the needed change. +specifyVol :: FilePath -> IO ()+specifyVol file = do + change0 <- getLine+ upperbound <- upperBnd file+ (originalStr, bool) <- selMaxAbs file (0::Int, upperbound)+ if bool + then changeVol3 file (change0, originalStr)+ else changeVol4 file (change0, originalStr)++-- | Function 'changeVol2' is used internally in the 'specifyVol' in case of decreasing of the sound.+changeVol2 :: FilePath -> String -> IO ()+changeVol2 file xs = do + let ys = take 4 . filter isDigit $ xs+ coefA = 0.0001 * fromIntegral (read ys::Int)+ ratio = 1.0 - coefA+ volS file ratio+ removeFile file+ renameFile ("8." ++ file) file++-- | Function 'changeVol3' is used internally in the 'specifyVol' in case of working with the maximum amplitude.+changeVol3 :: FilePath -> (String, String) -> IO ()+changeVol3 file (change0, originalStr) = do+ let ampl = read originalStr::Double+ if ampl > 0.0 + then do + let delta = 1.0 - ampl+ xs = filter (\x -> isDigit x || x == '-') change0+ if take 1 xs == "-" + then changeVol2 file xs+ else do + let ys = take 4 . takeWhile (isDigit) $ xs+ coefA = 0.0001 * fromIntegral (read ys::Int)+ ratio = 1.0 + (delta / ampl) * coefA+ volS file ratio+ removeFile file+ renameFile ("8." ++ file) file+ else error "SoXBasics: the volS function gave a strange result!"++-- | Function 'changeVol4' is used internally in the 'specifyVol' in case of working with the minimum amplitude.+changeVol4 :: FilePath -> (String, String) -> IO ()+changeVol4 file (change0, originalStr) = do+ let ampl = read originalStr::Double+ if ampl < 0.0+ then do + let delta = (-1.0) - ampl+ xs = filter (\x -> isDigit x || x == '-') change0+ if take 1 xs == "-" + then changeVol2 file xs+ else do + let ys = take 4 . filter isDigit $ xs+ coefA = 0.0001 * fromIntegral (read ys::Int)+ ratio = 1.0 + (delta / ampl) * coefA+ volS file ratio+ removeFile file+ renameFile ("8." ++ file) file+ else error "SoXBasic: the volS function gave a strange result!"+
+ Main.hs view
@@ -0,0 +1,29 @@+-- |+-- Module : Main+-- Copyright : (c) OleksandrZhabenko 2020+-- License : MIT+--+-- 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.+--++module Main where++import MMSyn7l (changeVolume)++-- | The main and the only one function in the module.+main :: IO ()+main = 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", + "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"]+ putStrLn ""+ putStrLn "Now you have changed (or left unchanged) the amplitudes for the sound representations for Ukrainian language. "+ putStrLn "Please, remember about responsible usage especially in case of processing the real voice sound samples! "++
+ README view
@@ -0,0 +1,26 @@+For the proper proceeding you specify a String, which consists of 4 +digits (and it may be preceeded by a symbol "-"). If the String +begins with the "-", then a sound amplitude decreases, otherwise +the amplitude increases. The level of increase / decrease is +determined by the magnitude of the absolute value of integer numbers. +The greater is the number -- the greater is the amplitude change. +The count begins with "0000" and ends with "9999" (the sign is not +taken into consideration). In such a case, for the Strings without the +initial sign "-" (the sound increases) an interval between the +maximum by modulus value of the amlitude (which is represented by the +parts of 1) and 1.0 is divided into 10 equal parts (starting a count +from 0) and then that one of them is selected, which has a number +determined by the first digit in the String writing. Then (if specified +further) the interval between this amplitude value and a value, +which corresponds to the selection on the previous step the next +first digit in the writing (for example, after "4" -- "5", +after "7" --"8" etc.), greater by 1 than the actually selected one, +is also divided again into 10 equal parts and that one is selected, +which corresponds to the number determined by the second digit in the +String writing (again beginning with "0" and ending with "9") and so on +until the 4th level. The greater exactness is not needed because our +hearing ability hardly distinguish such a subtle sound changes. If +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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ mmsyn7l.cabal view
@@ -0,0 +1,33 @@+-- Initial mmsyn7l.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: mmsyn7l+version: 0.1.0.0+synopsis: A program and a library to modify the amplitude of the sound representations for the Ukrainian language created by mmsyn7ukr package.+description: A program and a library to modify the amplitude of the sound representations for the Ukrainian language created by mmsyn7ukr package or somehow otherwise.+homepage: https://hackage.haskell.org/package/mmsyn7l+license: MIT+license-file: LICENSE+author: (c) OleksandrZhabenko 2020+maintainer: olexandr543@yahoo.com+-- copyright:+category: Sound+build-type: Simple+extra-source-files: CHANGELOG.md, README+cabal-version: >=1.10++library+ exposed-modules: Main, MMSyn7l+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.7 && <4.14, directory >=1 && <1.5, mmsyn7ukr >=0.5.0.1 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1+ -- hs-source-dirs:+ default-language: Haskell2010++executable mmsyn7l+ main-is: Main.hs+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.7 && <4.14, directory >=1 && <1.5, mmsyn7ukr >=0.5.0.1 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.7 && <1+ -- hs-source-dirs:+ default-language: Haskell2010