packages feed

mmsyn7ukr 0.7.6.0 → 0.8.0.0

raw patch · 7 files changed

+457/−166 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Processing_mmsyn7ukr: main7ukr :: [String] -> IO ()
+ SoXBasics1: gainL :: FilePath -> Double -> IO ()
+ SoXBasics1: noiseReduceB :: FilePath -> IO ()
+ SoXBasics1: noiseReduceE :: FilePath -> IO ()
+ SoXBasics1: norm :: FilePath -> IO ()
+ SoXBasics1: normL :: FilePath -> Int -> IO ()
+ SoXBasics1: quarterSinFade :: FilePath -> IO ()
+ SoXBasics1: resampleA :: FilePath -> Int -> IO ()
+ SoXBasics1: silenceBoth :: FilePath -> Int -> Int -> IO ()
+ SoXBasics1: sincA :: FilePath -> IO ()
+ SoXBasics1: volS :: FilePath -> Double -> IO ()
+ SoXBasics1: volS2 :: FilePath -> FilePath -> IO ()

Files

ChangeLog.md view
@@ -121,3 +121,9 @@  * Seventh version revised G. Added a possibility not to reduce a noise. It is controlled by the first command line argument. Some minor documentation improvements.++## 0.8.0.0 -- 2020-01-24++* Eigth version. Added a new module SoXBasics1 where all the functions (contrary to the SoXBasics module) try to replace+the initial file with the resulting one. Changed the lower bound for SoX "sinc" effect. Added help messages and version information+being obtained in the command line.
Main.hs view
@@ -14,170 +14,30 @@  module Main where -import System.Directory-import Control.Exception (onException)-import EndOfExe (showE)-import Data.Maybe (fromJust)-import Paths_mmsyn6ukr+import Control.Concurrent (myThreadId,killThread) import Processing_mmsyn7ukr import System.Environment (getArgs)-import System.Info (os)-import CaseBi (getBFst')-import qualified Data.Vector as V-import ReplaceP (replaceP, replaceP4) --- | Function responds for general program execution. It starts with CAUTION to be responsible for usage and to --- use it personally in some important cases (see README) and with some additional information. Then the program--- guides you through the creating your Ukrainian \"voice\". --- Please, use it carefully. The function uses command line arguments. --- For their meaning, please, refer to README file.--- +-- | Function responds for general @mmsyn7ukr@ program execution.  main :: IO () main = do   args <- getArgs-  putStrLn "     ***** CAUTION! *****"-  putStrLn ""-  putStrLn "\"The possession of great power necessarily implies great responsibility.\""-  putStrLn ""-  putStrLn "                                            (William Lamb)"-  putStrLn ""-  putStr "The program mmsyn7ukr produces the \"voice\" represented as an ordered "-  putStr "set of sounds each of which corresponds (represents) one of the "-  putStr "Ukrainian sounds so that using them together by mmsyn7h program "-  putStr "(https://hackage.haskell.org/package/mmsyn7h) can be a background "-  putStr "for sound synthesis. If you pronounce sounds as the appropriate "-  putStr "Ukrainian ones, close to proper Ukrainian speech with your own "-  putStr "voice. This program approximates your voice with a sequence "-  putStr "of recorded separate sounds with your control over the "-  putStr "duration of the sounds. They are then precessed by the SoX "-  putStr "binaries already installed in the system to produce the "-  putStr "needed sounds and then you can pronounce some Ukrainian text "-  putStr "with your recorded \"voice\" using mmsyn7h program. In-between "-  putStr "you can do some additional processing as you need. Moreover, "-  putStr "you can substitute whatever sounds you like (consider being "-  putStrLn "sensible) instead of your own voice."-  putStrLn ""-  putStr "Be aware that if somebody can get access to the sounds of "-  putStr "your voice or to the recorded speech (except you) then this "-  putStr "possibility itself creates security issues and concerns. So, "-  putStr "please, do NOT give access to such records to anybody else "-  putStrLn "except you."-  putStrLn ""-  putStr "In such a case, the program is for personal usage of every "-  putStrLn "user ONLY!"-  putStrLn ""-  putStr "Being given as an advice in such a case, run the program "-  putStr "in the empty directory with the current user permissions to write, "-  putStr "read and search and provide some proofs and evidence that nobody else "-  putStr "can even read the files in the directory. May be, it is better "-  putStr "to execute the program being in the directory located in the RAM, "-  putStr "then consequently wait until the program ends and then reboot "-  putStrLn "the computer. "-  putStrLn ""-  putStr "If the program ends earlier, you must then remove "-  putStr "(better wipe) the directory contents. No other users should "-  putStr "have access to the computer after you have begun to run the "-  putStr "program and have not deleted (or better wiped) the contents "-  putStr "of the directory. Please, be aware, that there are possibilities "-  putStr "to read sensitive information from the drives after you have "-  putStr "deleted the files in a usual way. You can use wiping for better "-  putStr "security. Besides, if somebody can get access to the memory of "-  putStr "the computer or to the directory contents where you run the "-  putStr "program or (may be) to the temporary files created by SoX or "-  putStr "to the drive where you run the program (not in the RAM, or may "-  putStr "be in it) then your voice can be stolen and / or used "-  putStr "inappropriately. Use all possible precautions and measures to "-  putStrLn "avoid the situation. "-  putStrLn ""-  putStr "Be aware also that the given by the program technology (or "-  putStr "documentation for it in any form) of the voice processing can "-  putStr "be improved so there is NO guarantees that the given technology "-  putStr "or its successors cannot be used in violating your voice identity "-  putStr "to produce from some available voice records the voice for the "-  putStr "inappropriate usage. Therefore, better is to proove your identity not "-  putStr "only with the solely voice itself but with some additional "-  putStrLn "independent sources and measures. "-  putStrLn ""-  putStr "The author of the program accordingly to the LICENSE (MIT) does not "-  putStr "response for any possible issues, but by this notification tries to "-  putStrLn "intent you to be aware of some possible issues."-  putStrLn ""-  putStrLn "           ***** More Information *****"-  putStrLn ""-  putStr "You can create a sound in either a \'sharp\' mode or in a usual mode."-  putStr "The first one means that the program does not check whether the"-  putStr "specified duration for recording the initial sound data"-  putStr "is greater than 3 seconds. In such a case the duration can be"-  putStr "much smaller. This mode needs more mastership in interacting with a"-  putStr "program. For speech synthesis (as an advice) use this mode for"-  putStr "the very short sounds (like the sound representation for \"ь\")"-  putStr "or for the sounds, you can articulate for a long time continually"-  putStr "(for example, vowels and some consonants). The \'sharp\' mode delegates"-  putStr "the responsibility for the sound to much broader extent to the user,"-  putStrLn "so for a beginning it is not recommended (though you can give it a try)."-  putStrLn ""-  putStr "At the beginning the program also creates a noise profile (once per execution)."-  putStr "It is now used to reduce the noise level for the recorded sound representations."-  putStr "It uses the default SoX noise reducing settings with a hope that for you they can"-  putStrLn "be sufficient."-  putStrLn ""-  putStrLn "           ***** Ukrainian Localization *****"-  putStrLn ""-  putStr "Please, before using the program check that uk_UA.UTF8 localization is"-  putStr "present in your system as one of the system locales. Otherwise,"-  putStr "the program will possibly (in some cases surely) cycle. In such a case,"-  putStrLn "you can terminate it in a usual way by sending interruption signals."-  putStrLn ""-  putStrLn ""-  onException (if take 5 os == "mingw" -      then do -        let eS = fromJust (showE "sox")-            eSi = fromJust (showE "soxi")-        return ()-      else do -        let eS = fromJust (showE "sox")-            eSi = fromJust (showE "soxi")-            eSp = fromJust (showE "play")-            eSr = fromJust (showE "rec")-        return ()) (error "SoX is not properly installed in your system. Please, install it properly and then run the program again! ")-  tempeRa-  let a0 = if null . take 1 $ args -             then []-             else concat . take 1 $ args-      a1 = if null . drop 1 . take 2 $ args -             then []-             else concat . drop 1 . take 1 $ args-      a2 = if null . drop 2 . take 3 $ args -             then []-             else drop 2 . take 3 $ args-  if null a2-    then do-      paths <- mapM getDataFileName ["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"]-      copiedFs <- mapM getDataFileName ["-.wav", "0.wav", "1.wav"]-      mapM_ (produceSound (a0, a1)) paths-      silenceFs <- mapM makeAbsolute ["-.wav", "0.wav", "1.wav"]-      let pairs = zip copiedFs silenceFs-      mapM_ (\(x, y) -> copyFile x y) pairs-    else do-      putStrLn ""-      let rrs = show a2-          list0 = read (replaceP rrs)::[String]-          zss = read (replaceP4 . show $ list0)::[String]-          wws = map (getBFst' ("0.wav", 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"])) zss-      paths <- mapM getDataFileName wws-      copiedFs <- mapM getDataFileName ["-.wav", "0.wav", "1.wav"]-      mapM_ (produceSound (a0, a1)) paths-      silenceFs <- mapM makeAbsolute ["-.wav", "0.wav", "1.wav"]-      let pairs = zip copiedFs silenceFs-      mapM_ (\(x, y) -> copyFile x y) pairs-  putStrLn ""-  putStrLn "Your voice sound files are now created in the current directory! Use in a secure way! Remember the initial CAUTION! "-  putStrLn ""-  cleanTempN+  let c0 = concat . take 1 $ args+  case c0 of+    "-h" -> do+       putStrLn "mmsyn7ukr SYNOPSIS:"+       putStrLn "mmsyn7ukr [control-parameter-for-levels-of-processment] [control-parameter-for-truncating-sounds] [list-of-produced-sound-representations]"+       putStrLn ""+       putStr "control-parameter-for-levels-of-processment (if any) -- an integer number in range [-1..3] that defines in ascending order the portion of processment "+       putStrLn "of the resulting sound representations. "+       putStr "control-parameter-for-truncating-sounds (if any) -- an integer number in range [0..3] that defines in ascending order the level for maximum " +       putStrLn "amplitude that are trimmed for the sound file. "+       putStr "list-of-produced-sound-representations (if any) -- a list of sound representations, which the program will try to produce while being executed. "+       putStrLn "The default one (if not specified) is a full range of needed sound representations. "+       myThread <- myThreadId+       killThread myThread+    "-v" -> do+       putStrLn "mmsyn7ukr version: 0.8.0.0"+       myThread <- myThreadId+       killThread myThread+    _    -> main7ukr args
Processing_mmsyn7ukr.hs view
@@ -12,8 +12,10 @@ --  module Processing_mmsyn7ukr (+  -- * Main7ukr function+  main7ukr   -- * Producing sound-  produceSound+  , produceSound   , produceSound2   , produceSound3   , produceSound4@@ -37,9 +39,13 @@ import qualified Data.Vector as V import System.Process import System.IO+import System.Info (os) import SoXBasics import CaseBi (getBFst')+import ReplaceP (replaceP, replaceP4)+import Paths_mmsyn6ukr + -- | Function that being given a tuple of @String@ and a path to the installed by the @mmsyn6ukr@ package file produces the corresponding analogous sound with your created  -- voicing. The tuple controls the function behaviour. The first @String@ in it specifies the actions that will be performed to produce a sound file and the second one  -- specifies a maximum absolute amplitude starting from which the sound will not be truncated if the 'alterVadB' and 'alterVadE' functions must be applied (that is specified @@ -326,3 +332,159 @@     ; putStrLn ""     ; threadDelay 400000     ; putStrLn "The noise sound profile is now created. The program can proceed further." }++-- | Function 'main7ukr' is used internally in the 'main' function of the Main module. It responds for mainstream @mmsyn7ukr@ program execution.+-- It starts with CAUTION to be responsible for usage and to +-- use it personally in some important cases (see README) and with some additional information. Then the program+-- guides you through the creating your Ukrainian \"voice\". +-- Please, use it carefully. The function uses command line arguments. +-- For their meaning, please, refer to README file.+-- +main7ukr :: [String] -> IO ()+main7ukr args = do+  putStrLn "     ***** CAUTION! *****"+  putStrLn ""+  putStrLn "\"The possession of great power necessarily implies great responsibility.\""+  putStrLn ""+  putStrLn "                                            (William Lamb)"+  putStrLn ""+  putStr "The program mmsyn7ukr produces the \"voice\" represented as an ordered "+  putStr "set of sounds each of which corresponds (represents) one of the "+  putStr "Ukrainian sounds so that using them together by mmsyn7h program "+  putStr "(https://hackage.haskell.org/package/mmsyn7h) can be a background "+  putStr "for sound synthesis. If you pronounce sounds as the appropriate "+  putStr "Ukrainian ones, close to proper Ukrainian speech with your own "+  putStr "voice. This program approximates your voice with a sequence "+  putStr "of recorded separate sounds with your control over the "+  putStr "duration of the sounds. They are then precessed by the SoX "+  putStr "binaries already installed in the system to produce the "+  putStr "needed sounds and then you can pronounce some Ukrainian text "+  putStr "with your recorded \"voice\" using mmsyn7h program. In-between "+  putStr "you can do some additional processing as you need. Moreover, "+  putStr "you can substitute whatever sounds you like (consider being "+  putStrLn "sensible) instead of your own voice."+  putStrLn ""+  putStr "Be aware that if somebody can get access to the sounds of "+  putStr "your voice or to the recorded speech (except you) then this "+  putStr "possibility itself creates security issues and concerns. So, "+  putStr "please, do NOT give access to such records to anybody else "+  putStrLn "except you."+  putStrLn ""+  putStr "In such a case, the program is for personal usage of every "+  putStrLn "user ONLY!"+  putStrLn ""+  putStr "Being given as an advice in such a case, run the program "+  putStr "in the empty directory with the current user permissions to write, "+  putStr "read and search and provide some proofs and evidence that nobody else "+  putStr "can even read the files in the directory. May be, it is better "+  putStr "to execute the program being in the directory located in the RAM, "+  putStr "then consequently wait until the program ends and then reboot "+  putStrLn "the computer. "+  putStrLn ""+  putStr "If the program ends earlier, you must then remove "+  putStr "(better wipe) the directory contents. No other users should "+  putStr "have access to the computer after you have begun to run the "+  putStr "program and have not deleted (or better wiped) the contents "+  putStr "of the directory. Please, be aware, that there are possibilities "+  putStr "to read sensitive information from the drives after you have "+  putStr "deleted the files in a usual way. You can use wiping for better "+  putStr "security. Besides, if somebody can get access to the memory of "+  putStr "the computer or to the directory contents where you run the "+  putStr "program or (may be) to the temporary files created by SoX or "+  putStr "to the drive where you run the program (not in the RAM, or may "+  putStr "be in it) then your voice can be stolen and / or used "+  putStr "inappropriately. Use all possible precautions and measures to "+  putStrLn "avoid the situation. "+  putStrLn ""+  putStr "Be aware also that the given by the program technology (or "+  putStr "documentation for it in any form) of the voice processing can "+  putStr "be improved so there is NO guarantees that the given technology "+  putStr "or its successors cannot be used in violating your voice identity "+  putStr "to produce from some available voice records the voice for the "+  putStr "inappropriate usage. Therefore, better is to proove your identity not "+  putStr "only with the solely voice itself but with some additional "+  putStrLn "independent sources and measures. "+  putStrLn ""+  putStr "The author of the program accordingly to the LICENSE (MIT) does not "+  putStr "response for any possible issues, but by this notification tries to "+  putStrLn "intent you to be aware of some possible issues."+  putStrLn ""+  putStrLn "           ***** More Information *****"+  putStrLn ""+  putStr "You can create a sound in either a \'sharp\' mode or in a usual mode."+  putStr "The first one means that the program does not check whether the"+  putStr "specified duration for recording the initial sound data"+  putStr "is greater than 3 seconds. In such a case the duration can be"+  putStr "much smaller. This mode needs more mastership in interacting with a"+  putStr "program. For speech synthesis (as an advice) use this mode for"+  putStr "the very short sounds (like the sound representation for \"ь\")"+  putStr "or for the sounds, you can articulate for a long time continually"+  putStr "(for example, vowels and some consonants). The \'sharp\' mode delegates"+  putStr "the responsibility for the sound to much broader extent to the user,"+  putStrLn "so for a beginning it is not recommended (though you can give it a try)."+  putStrLn ""+  putStr "At the beginning the program also creates a noise profile (once per execution)."+  putStr "It is now used to reduce the noise level for the recorded sound representations."+  putStr "It uses the default SoX noise reducing settings with a hope that for you they can"+  putStrLn "be sufficient."+  putStrLn ""+  putStrLn "           ***** Ukrainian Localization *****"+  putStrLn ""+  putStr "Please, before using the program check that uk_UA.UTF8 localization is"+  putStr "present in your system as one of the system locales. Otherwise,"+  putStr "the program will possibly (in some cases surely) cycle. In such a case,"+  putStrLn "you can terminate it in a usual way by sending interruption signals."+  putStrLn ""+  putStrLn ""+  onException (if take 5 os == "mingw" +      then do +        let eS = fromJust (showE "sox")+            eSi = fromJust (showE "soxi")+        return ()+      else do +        let eS = fromJust (showE "sox")+            eSi = fromJust (showE "soxi")+            eSp = fromJust (showE "play")+            eSr = fromJust (showE "rec")+        return ()) (error "SoX is not properly installed in your system. Please, install it properly and then run the program again! ")+  tempeRa+  let a0 = if null . take 1 $ args +             then []+             else concat . take 1 $ args+      a1 = if null . drop 1 . take 2 $ args +             then []+             else concat . drop 1 . take 1 $ args+      a2 = if null . drop 2 . take 3 $ args +             then []+             else drop 2 . take 3 $ args+  if null a2+    then do+      paths <- mapM getDataFileName ["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"]+      copiedFs <- mapM getDataFileName ["-.wav", "0.wav", "1.wav"]+      mapM_ (produceSound (a0, a1)) paths+      silenceFs <- mapM makeAbsolute ["-.wav", "0.wav", "1.wav"]+      let pairs = zip copiedFs silenceFs+      mapM_ (\(x, y) -> copyFile x y) pairs+    else do+      putStrLn ""+      let rrs = show a2+          list0 = read (replaceP rrs)::[String]+          zss = read (replaceP4 . show $ list0)::[String]+          wws = map (getBFst' ("0.wav", 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"])) zss+      paths <- mapM getDataFileName wws+      copiedFs <- mapM getDataFileName ["-.wav", "0.wav", "1.wav"]+      mapM_ (produceSound (a0, a1)) paths+      silenceFs <- mapM makeAbsolute ["-.wav", "0.wav", "1.wav"]+      let pairs = zip copiedFs silenceFs+      mapM_ (\(x, y) -> copyFile x y) pairs+  putStrLn ""+  putStrLn "Your voice sound files are now created in the current directory! Use in a secure way! Remember the initial CAUTION! "+  putStrLn ""+  cleanTempN
README view
@@ -157,3 +157,10 @@ the program will possibly (in some cases surely) cycle. In such a case, you can terminate it in a usual way by sending interruption signals. +           ***** SoXBasics and SoXBasics1 *****++The library have two similar modules with partially overlapping function names+(so it is recommended to import them qualified). SoXBasics1 functions after+creation of the resulting file try to replace by it the initial one and to clean+the space from the temporary files. This can be helpful in writing sequentially+applied functions but needs somewhat more resources.
SoXBasics.hs view
@@ -359,10 +359,10 @@   else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."          --- | Function 'sincA' uses a \"sinc\" effect with @-a 50 -I 0.1k-11k@ band-pass filter for the audio file given.+-- | Function 'sincA' uses a \"sinc\" effect with @-a 50 -I 0.07k-11k@ band-pass filter for the audio file given. sincA :: FilePath -> IO () sincA file = if isJust (showE "sox") -  then readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.1k-11k"] "" >> return ()+  then readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.07k-11k"] "" >> return ()   else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."  -- | Function 'sampleAn' analyzes the one samle of the 1-channel sound file (or k samples for the k-channel file) and returns a tuple pair of 
+ SoXBasics1.hs view
@@ -0,0 +1,256 @@+-- |+-- Module      :  SoXBasics1+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+--+-- Maintainer  :  olexandr543@yahoo.com+--+-- A program and a library that can be used as a simple +-- basic interface to some SoX functionality or for producing +-- the approximately Ukrainian speech with your own recorded +-- voice (actually it produces the needed sound representations). +-- This module differs from a SoXBasics that the resulting files+-- in it have possibly just the same name as the input ones. The functions+-- try to replace the initial file with the processed one.+-- +++module SoXBasics1 (+  -- * Produce sound+  -- ** Amplitude modification+  norm+  , normL+  , gainL+  , quarterSinFade+  -- ** Adding silence+  , silenceBoth+  -- ** Changing sample rate+  , resampleA+  -- ** Working with noise+  , noiseReduceB+  , noiseReduceE+  -- ** Filtering+  , sincA+  -- ** Volume amplification+  , volS+  , volS2+) where++import System.Directory+import Data.Maybe (isJust, fromJust)+import Numeric+import System.Process+import EndOfExe+import System.Exit+import qualified SoXBasics as SX (extremeS1,upperBnd,selMA,maxAbs,norm) ++-- | Function 'norm' applies a SoX normalization effect on the audio file. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+norm :: FilePath -> IO ()+norm file = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "8" ++ file, "norm"] ""+    exist0 <- doesFileExist $ "8" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("8" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'normL' applies a SoX gain effect on the audio file with the maximum absolute dB value given by the @Int@ argument. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+normL :: FilePath -> Int -> IO ()+normL file level = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-n", show level] ""+    exist0 <- doesFileExist $ "9" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("9" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'normL' applies a SoX \"gain -b [db-Value]\" effect on the audio file with dB value given by the @Double@ argument. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+gainL :: FilePath -> Double -> IO ()+gainL file level = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-b", showFFloat (Just 6) level $ show 0] ""+    exist0 <- doesFileExist $ "9" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("9" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'quarterSinFade' applies a fade effect by SoX to the audio file with \"q\" type. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+quarterSinFade :: FilePath -> IO ()+quarterSinFade file = if isJust (showE "sox") +  then do+    pos <- SX.extremeS1 file+    upp <- SX.upperBnd file+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4" ++ file, "fade", "q", show pos ++ "s", "=" ++ show upp ++ "s", show (upp - pos) ++ "s"] ""+    exist0 <- doesFileExist $ "4" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("4" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'silenceBoth' adds some silence to both ends of the audio. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+silenceBoth :: FilePath -> Int -> Int -> IO ()+silenceBoth file beginning end = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "3" ++ file, "delay", show beginning ++ "s", "reverse"] ""+    _ <- readProcessWithExitCode (fromJust (showE "sox")) ["3" ++ file, "2" ++ file, "delay", show end ++ "s", "reverse"] ""+    exist0 <- doesFileExist $ "3" ++ file+    exist1 <- doesFileExist $ "2" ++ file+    if exist0+      then if exist1+             then do +               removeFile $ "3" ++ file+               removeFile file+               renameFile ("2" ++ file) file+             else do+               removeFile $ "3" ++ file+               error "The resulting file was not created!"+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'resampleA' changes the sample rate for the recorded audio for further processing. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+resampleA :: FilePath -> Int -> IO ()+resampleA file frequency = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "3" ++ file, "rate", "-s", "-I", show frequency] ""+    exist0 <- doesFileExist $ "3" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("3" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'noiseReduceB' reduces with SoX a noise in the file given with the corresponding noise profile created with 'noiseProfB' function. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+noiseReduceB :: FilePath -> IO ()+noiseReduceB file = if isJust (showE "sox")+  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_" ++ file, "noisered", file ++ ".b.prof"] ""+    exist0 <- doesFileExist $ "_" ++ file+    if exist0+      then do+        removeFile file+        renameFile ("_" ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'noiseReduceE' reduces with SoX a noise in the file given with the corresponding noise profile created with 'noiseProfE' function. +-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+noiseReduceE :: FilePath -> IO ()+noiseReduceE file = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_." ++ file, "noisered", file ++ ".e.prof"] ""+    exist0 <- doesFileExist $ "_." ++ file+    if exist0+      then do+        removeFile file+        renameFile ("_." ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'volS' changes the given audio with the linear ratio for the amplitude so that the resulting amlitude is equal to the given @Double@ parameter.+-- The function must be used with the @FilePath@ parameter containing no directories in its name (that means the file of the @FilePath@ parameter must be +-- in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+volS :: FilePath -> Double -> IO ()+volS file amplitude = if isJust (showE "sox") +  then do+    SX.norm file+    exist0 <- doesFileExist $ "8" ++ file+    if exist0+      then do+        _ <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ file, "8." ++ file, "vol", showFFloat Nothing amplitude $ show 0, "amplitude"] ""+        exist1 <- doesFileExist $ "8." ++ file+        if exist1+          then do+            removeFile file+            removeFile $ "8" ++ file+            renameFile ("8." ++ file) file+          else do+            removeFile $ "8" ++ file+            error "The initial file was not changed!"+      else error "The initial file was not changed at all!"+  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."++-- | Function 'volS2' changes the given audio (the first @FilePath@ parameter, which must be normalized e. g. by the 'norm' function before) with +-- the linear ratio for the amplitude so that the resulting amlitude is equal to the maximum by absolute value amplitude for the file given +-- by the second @FilePath@ parameter. The function must be used with the first @FilePath@ parameter containing no directories in its name +-- (that means the file of the first @FilePath@ parameter must be in the same directory where the function is called from). While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+volS2 :: FilePath -> FilePath -> IO ()+volS2 fileA fileB = if isJust (showE "sox") +  then do+    upp <- SX.upperBnd fileB+    amplMax <- SX.selMA fileB (0, upp) True+    amplMin <- SX.selMA fileB (0, upp) False+    let ampl = read (fst . SX.maxAbs $ (amplMax, amplMin))::Double+    (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [fileA, "8." ++ tail fileA, "vol", showFFloat Nothing ampl $ show 0, "amplitude"] ""+    if code /= ExitSuccess +      then error "File was not created with \"vol\" effect!"+      else do +        file8e <- doesFileExist $ "8." ++ tail fileA+        if file8e +          then do+            removeFile fileA+            renameFile ("8." ++ tail fileA) fileA+          else error "The initial file was not changed!"+  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."+        ++-- | Function 'sincA' uses a \"sinc\" effect with @-a 50 -I 0.07k-11k@ band-pass filter for the audio file given. While being+-- executed the function tries to replace the initial file with the resulting processed one and to clean the temporary files. If it is not+-- successful the function exits with error and leaves the initial file without modification.+sincA :: FilePath -> IO ()+sincA file = if isJust (showE "sox") +  then do+    _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.07k-11k"] ""+    exist0 <- doesFileExist $ "4." ++ file+    if exist0+      then do+        removeFile file+        renameFile ("4." ++ file) file+      else error "The initial file was not changed!" +  else error "SoX is not properly installed in your system. Please, install it properly and then call the function again."
mmsyn7ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn7ukr-version:             0.7.6.0+version:             0.8.0.0 synopsis:            A simple basic interface to some SoX functionality or to produce a voice that can be used by mmsyn7h description:         A program and a library that can be used as a simple basic interface to some SoX functionality or to produce your voice in Ukrainian (if you pronounce the sounds properly) represented by the separate sounds or something special like soft sign. homepage:            https://hackage.haskell.org/package/mmsyn7ukr@@ -17,7 +17,7 @@ cabal-version:       >=1.10  library-  exposed-modules:     SoXBasics, Processing_mmsyn7ukr, Main, ReplaceP+  exposed-modules:     SoXBasics, SoXBasics1, Processing_mmsyn7ukr, Main, ReplaceP   -- other-modules:   -- other-extensions:   build-depends:       base >=4.7 && <4.14, process >=1.4 && <1.8, vector >=0.11 && <0.14, bytestring >=0.10 && < 0.12, mmsyn2 >=0.1.7 && <1, directory >=1.2.5 && <1.4, mmsyn6ukr >=0.6.2 && <1, mmsyn3 >=0.1.4 && <1