mmsyn7ukr 0.9.3.0 → 0.9.4.0
raw patch · 4 files changed
+469/−114 lines, 4 files
Files
- ChangeLog.md +4/−0
- SoXBasics.hs +270/−30
- SoXBasics1.hs +194/−83
- mmsyn7ukr.cabal +1/−1
ChangeLog.md view
@@ -148,3 +148,7 @@ ## 0.9.3.0 -- 2020-01-24 * Ninth version revised D. Further needed work to fix an issue with Typeable in the Processing_mmsyn7ukr module. Now it should compile also for GHC 7.8.4.++## 0.9.4.0 -- 2020-01-25++* Ninth version revised E. Fixed issues with being not properly created or modified the files in the SoXBasics and SoXBasics1 modules.
SoXBasics.hs view
@@ -144,9 +144,18 @@ (_, _, herr) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "0", showFFloat Nothing (lim1 / 2.0) $ show 0, "stat"] "" let zs = lines herr in let z = concatMap (dropWhile (not . isDigit)) . take 1 . drop 3 $ zs in if z < noiseM then do - _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim1 / 2.0) $ show 0, "-0.000000"] ""- threadDelay 100000- opFile file exit noiseMax+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim1 / 2.0) $ show 0, "-0.000000"] ""+ if code == ExitSuccess+ then do+ threadDelay 100000+ opFile file exit noiseMax+ else do+ e0 <- doesFileExist $ "7" ++ file+ if e0+ then do+ removeFile $ "7" ++ file+ error "The function did not create the needed file, but may be it trimmed the initial one (not enough)!"+ else error "The function did not create the needed file, but may be it trimmed the initial one (not enough)!" else alterVadB file (lim1 / 4.0) noiseMax exit | otherwise = let noiseM = (case noiseMax of @@ -158,9 +167,18 @@ (_, _, herr) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "0", showFFloat Nothing (lim / 2.0) $ show 0, "stat"] "" let zs = lines herr in let z = concatMap (dropWhile (not . isDigit)) . take 1 . drop 3 $ zs in if z < noiseM then do - _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim / 2.0) $ show 0, "-0.000000"] ""- threadDelay 100000- opFile file exit noiseMax+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim / 2.0) $ show 0, "-0.000000"] ""+ if code == ExitSuccess+ then do+ threadDelay 100000+ opFile file exit noiseMax+ else do+ e0 <- doesFileExist $ "7" ++ file+ if e0+ then do+ removeFile $ "7" ++ file+ error "The function did not create the needed file, but may be it trimmed the initial one (not enough)!"+ else error "The function did not create the needed file, but may be it trimmed the initial one (not enough)!" else alterVadB file (lim / 4.0) noiseMax exit -- | Function 'opFile' is used internally in 'alterVadB' to check whether @FilePath@ exist and if so to do some processing to allow the 'alterVadB' function iterate further.@@ -180,7 +198,21 @@ -- in the same directory where the function is called from). norm :: FilePath -> IO () norm file = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "8" ++ file, "norm"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "8" ++ file, "norm"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "8" ++ file+ if e1+ then do+ removeFile $ "8" ++ file+ error "File was not created with \"norm\" effect!"+ else error "File was not created with \"norm\" effect!"+ else do + e2 <- doesFileExist $ "8" ++ file+ if e2 + then return ()+ 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. @@ -188,7 +220,21 @@ -- in the same directory where the function is called from). normL :: FilePath -> Int -> IO () normL file level = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-n", show level] "" >> return ()+ then do+ (code, _, _) <- (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-n", show level] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "9" ++ file+ if e1+ then do+ removeFile $ "9" ++ file+ error "File was not created with \"gain -n\" effect!"+ else error "File was not created with \"gain -n\" effect!"+ else do + e2 <- doesFileExist $ "9" ++ file+ if e2 + then return ()+ 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. @@ -196,7 +242,21 @@ -- in the same directory where the function is called from). gainL :: FilePath -> Double -> IO () gainL file level = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-b", showFFloat (Just 6) level $ show 0] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-b", showFFloat (Just 6) level $ show 0] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "9" ++ file+ if e1+ then do+ removeFile $ "9" ++ file+ error "File was not created with \"gain -b\" effect!"+ else error "File was not created with \"gain -b\" effect!"+ else do + e2 <- doesFileExist $ "9" ++ file+ if e2 + then return ()+ 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 'soxStat' prints a SoX statistics for the audio file.@@ -216,11 +276,40 @@ | otherwise = if isJust (showE "sox") then do- _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "6" ++ file, "reverse"] ""- alterVadB ("6" ++ file) lim noiseMax exit- _ <- readProcessWithExitCode (fromJust (showE "sox")) ["6" ++ file, "76" ++ file, "reverse"] ""- removeFile $ "6" ++ file- renameFile ("76" ++ file) file+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "6" ++ file, "reverse"] ""+ if code /= ExitSuccess+ then do+ e0 <- doesFileExist $ "6" ++ file+ if e0+ then do+ removeFile $ "6" ++ file+ error "The function did not create the needed file!"+ else do+ error "The function did not create the needed file!"+ else do+ alterVadB ("6" ++ file) lim noiseMax exit+ (code1, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) ["6" ++ file, "76" ++ file, "reverse"] ""+ if code1 /= ExitSuccess+ then do+ e1 <- doesFileExist $ "76" ++ file+ if e1+ then do+ removeFile $ "76" ++ file+ removeFile $ "6" ++ file+ error "The function did not create the needed file!"+ else do+ removeFile $ "6" ++ file+ error "The function did not create the needed file!"+ else do+ e2 <- doesFileExist $ "76" ++ file+ if e2+ then do+ removeFile $ "6" ++ file+ removeFile file+ renameFile ("76" ++ file) file+ else do+ removeFile $ "6" ++ file+ error "The function did not create the needed file!" else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." -- | Function 'upperBnd' returns a maximum number of samples for use in other functions.@@ -246,8 +335,20 @@ then do pos <- extremeS1 file upp <- upperBnd file- _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4" ++ file, "fade", "q", show pos ++ "s", "=" ++ show upp ++ "s", show (upp - pos) ++ "s"] ""- return ()+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4" ++ file, "fade", "q", show pos ++ "s", "=" ++ show upp ++ "s", show (upp - pos) ++ "s"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "4" ++ file+ if e1+ then do+ removeFile $ "4" ++ file+ error "File was not created with \"fade\" effect!"+ else error "File was not created with \"fade\" effect!"+ else do + e2 <- doesFileExist $ "4" ++ file+ if e2 + then return ()+ 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. @@ -265,10 +366,40 @@ recA :: FilePath -> Double -> IO () recA file x | take 5 os == "mingw" = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) ["-t","waveaudio","-d","-b16", "-c1", "-esigned-integer", "-L", file, "trim", "0.5", showFFloat Nothing x $ show 0] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) ["-t","waveaudio","-d","-b16", "-c1", "-esigned-integer", "-L", file, "trim", "0.5", showFFloat Nothing x $ show 0] ""+ if code /= ExitSuccess+ then do+ e0 <- doesFileExist file+ if e0+ then do+ removeFile file+ error $ "The file " ++ file ++ " was not recorded!"+ else do+ error $ "The file " ++ file ++ " was not recorded!"+ else do+ e1 <- doesFileExist file+ if e1+ then return ()+ else error $ "The file " ++ file ++ " was not recorded!" else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." | otherwise = if isJust (showE "rec") - then readProcessWithExitCode (fromJust (showE "rec")) ["-b16", "-c1", "-esigned-integer", "-L", file, "trim", "0.5", showFFloat Nothing x $ show 0] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "rec")) ["-b16", "-c1", "-esigned-integer", "-L", file, "trim", "0.5", showFFloat Nothing x $ show 0] ""+ if code /= ExitSuccess+ then do+ e0 <- doesFileExist file+ if e0+ then do+ removeFile file+ error $ "The file " ++ file ++ " was not recorded!"+ else do+ error $ "The file " ++ file ++ " was not recorded!"+ else do+ e1 <- doesFileExist file+ if e1+ then return ()+ else error $ "The file " ++ file ++ " was not recorded!" 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. @@ -276,7 +407,21 @@ -- in the same directory where the function is called from). resampleA :: FilePath -> Int -> IO () resampleA file frequency = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "3" ++ file, "rate", "-s", "-I", show frequency] "" >> return ()+ then do+ (code, _, _) <- (fromJust (showE "sox")) [file, "3" ++ file, "rate", "-s", "-I", show frequency] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "3" ++ file+ if e1+ then do+ removeFile $ "3" ++ file+ error "File was not created with \"rate\" effect!"+ else error "File was not created with \"rate\" effect!"+ else do + e2 <- doesFileExist $ "3" ++ file+ if e2 + then return ()+ 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 'durationA' returns a duration of the audio file in seconds.@@ -301,13 +446,41 @@ -- | Function 'noiseProfB' creates with SoX a file containing a noise profile for the first 0.05 s of the audio file given. noiseProfB :: FilePath -> IO () noiseProfB file = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "0", "0.05", "noiseprof",file ++ ".b.prof"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "0", "0.05", "noiseprof",file ++ ".b.prof"] ""+ if code /= ExitSuccess+ then do+ e0 <- doesFileExist $ file ++ ".b.prof"+ if e0+ then do+ removeFile $ file ++ ".b.prof"+ error $ "The noise profile " ++ file ++ ".b.prof was not created!"+ else error $ "The noise profile " ++ file ++ ".b.prof was not created!"+ else do + e1 <- doesFileExist $ file ++ ".b.prof"+ if e1+ then return ()+ else error $ "The noise profile " ++ file ++ ".b.prof was not created!" else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." -- | Function 'noiseProfE' creates with SoX a file containing a noise profile for the last 0.05 s of the audio file given. noiseProfE :: FilePath -> IO () noiseProfE file = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "-0.05", "0.05", "noiseprof",file ++ ".e.prof"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "-0.05", "0.05", "noiseprof",file ++ ".e.prof"] ""+ if code /= ExitSuccess+ then do+ e0 <- doesFileExist $ file ++ ".e.prof"+ if e0+ then do+ removeFile $ file ++ ".e.prof"+ error $ "The noise profile " ++ file ++ ".e.prof was not created!"+ else error $ "The noise profile " ++ file ++ ".e.prof was not created!"+ else do + e1 <- doesFileExist $ file ++ ".e.prof"+ if e1+ then return ()+ else error $ "The noise profile " ++ file ++ ".e.prof was not created!" 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. @@ -315,7 +488,21 @@ -- in the same directory where the function is called from). noiseReduceB :: FilePath -> IO () noiseReduceB file = if isJust (showE "sox")- then readProcessWithExitCode (fromJust (showE "sox")) [file, "_" ++ file, "noisered", file ++ ".b.prof"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_" ++ file, "noisered", file ++ ".b.prof"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "_" ++ file+ if e1+ then do+ removeFile $ "_" ++ file+ error "File was not created with \"noisered\" effect!"+ else error "File was not created with \"noisered\" effect!"+ else do + e2 <- doesFileExist $ "_" ++ file+ if e2 + then return ()+ 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. @@ -323,7 +510,21 @@ -- in the same directory where the function is called from). noiseReduceE :: FilePath -> IO () noiseReduceE file = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "_." ++ file, "noisered", file ++ ".e.prof"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_." ++ file, "noisered", file ++ ".e.prof"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "_." ++ file+ if e1+ then do+ removeFile $ "_." ++ file+ error "File was not created with \"noisered\" effect!"+ else error "File was not created with \"noisered\" effect!"+ else do + e2 <- doesFileExist $ "_." ++ file+ if e2 + then return ()+ 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.@@ -333,8 +534,28 @@ volS file amplitude = if isJust (showE "sox") then do norm file- _ <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ file, "8." ++ file, "vol", showFFloat Nothing amplitude $ show 0, "amplitude"] ""- removeFile $ "8" ++ file+ e0 <- doesFileExist $ "8" ++ file+ if e0+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ file, "8." ++ file, "vol", showFFloat Nothing amplitude $ show 0, "amplitude"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "8." ++ file+ if e1+ then do+ removeFile $ "8." ++ file+ removeFile $ "8" ++ file+ error "File was not created with \"vol\" effect!"+ else do+ removeFile $ "8" ++ file+ error "File was not created with \"vol\" effect!"+ else do + e2 <- doesFileExist $ "8." ++ file+ if e2 + then return ()+ else do + removeFile $ "8" ++ file+ 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 'volS2' changes the given audio (the first @FilePath@ parameter, which must be normalized e. g. by the 'norm' function before) with @@ -350,19 +571,38 @@ let ampl = read (fst . 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!"+ then do+ e1 <- doesFileExist $ "8." ++ tail fileA+ if e1+ then do+ removeFile $ "8." ++ tail fileA+ error "File was not created with \"vol\" effect!"+ else error "File was not created with \"vol\" effect!" else do file8e <- doesFileExist $ "8." ++ tail fileA if file8e - then removeFile fileA- else error "Second error!"+ then return ()+ 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. sincA :: FilePath -> IO () sincA file = if isJust (showE "sox") - then readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.07k-11k"] "" >> return ()+ then do+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.07k-11k"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "4." ++ file+ if e1+ then do+ removeFile $ "4." ++ file+ error "File was not created with \"sinc\" effect!"+ else error "File was not created with \"sinc\" effect!"+ else do + e0 <- doesFileExist $ "4." ++ file+ if e0 + then return ()+ 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 '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
@@ -42,7 +42,7 @@ import System.Process import EndOfExe import System.Exit-import qualified SoXBasics as SX (extremeS1,upperBnd,selMA,maxAbs,norm) +import qualified SoXBasics as SB (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 @@ -52,13 +52,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "8" ++ file, "norm"] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("8" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "8" ++ file+ if e1+ then do+ removeFile $ "8" ++ file+ error "File was not created with \"norm\" effect!"+ else error "File was not created with \"norm\" effect!"+ else do + e2 <- doesFileExist $ "8" ++ file+ if e2 + 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. @@ -69,13 +78,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-n", show level] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("9" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "9" ++ file+ if e1+ then do+ removeFile $ "9" ++ file+ error "File was not created with \"gain -n\" effect!"+ else error "File was not created with \"gain -n\" effect!"+ else do + e2 <- doesFileExist $ "9" ++ file+ if e2 + 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. @@ -86,13 +104,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "9" ++ file, "gain", "-b", showFFloat (Just 6) level $ show 0] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("9" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "9" ++ file+ if e1+ then do+ removeFile $ "9" ++ file+ error "File was not created with \"gain\" effect!"+ else error "File was not created with \"gain\" effect!"+ else do + e2 <- doesFileExist $ "9" ++ file+ if e2 + 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. @@ -103,15 +130,24 @@ 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+ pos <- SB.extremeS1 file+ upp <- SB.upperBnd file+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4" ++ file, "fade", "q", show pos ++ "s", "=" ++ show upp ++ "s", show (upp - pos) ++ "s"] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("4" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "4" ++ file+ if e1+ then do+ removeFile $ "4" ++ file+ error "File was not created with \"fade\" effect!"+ else error "File was not created with \"fade\" effect!"+ else do + e2 <- doesFileExist $ "4" ++ file+ if e2 + 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. @@ -122,20 +158,42 @@ 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!" + (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "3" ++ file, "delay", show beginning ++ "s", "reverse"] ""+ if code /= ExitSuccess + then do+ e1 <- doesFileExist $ "3" ++ file+ if e1+ then do+ removeFile $ "3" ++ file+ error "File was not created with \"delay\" and \"reverse\" effects!"+ else error "File was not created with \"delay\" and \"reverse\" effects!"+ else do + e2 <- doesFileExist $ "3" ++ file+ if e2 + then do+ (code1, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) ["3" ++ file, "2" ++ file, "delay", show end ++ "s", "reverse"] ""+ if code1 /= ExitSuccess+ then do+ e2 <- doesFileExist $ "2" ++ file+ if e2+ then do+ removeFile $ "3" ++ file+ removeFile $ "2" ++ file+ error "The resulting file was not created!"+ else do+ removeFile $ "3" ++ file+ error "The resulting file was not created!"+ else do+ e3 <- doesFileExist $ "2" ++ file+ if e3+ 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. @@ -146,13 +204,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "3" ++ file, "rate", "-s", "-I", show frequency] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("3" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "3" ++ file+ if e1+ then do+ removeFile $ "3" ++ file+ error "File was not created with \"rate\" effect!"+ else error "File was not created with \"rate\" effect!"+ else do + e2 <- doesFileExist $ "3" ++ file+ if e2 + 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. @@ -163,13 +230,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_" ++ file, "noisered", file ++ ".b.prof"] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("_" ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "_" ++ file+ if e1+ then do+ removeFile $ "_" ++ file+ error "File was not created with \"noisered\" effect!"+ else error "File was not created with \"noisered\" effect!"+ else do + e2 <- doesFileExist $ "_" ++ file+ if e2 + 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. @@ -180,13 +256,22 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "_." ++ file, "noisered", file ++ ".e.prof"] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("_." ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "_." ++ file+ if e1+ then do+ removeFile $ "_." ++ file+ error "File was not created with \"noisered\" effect!"+ else error "File was not created with \"noisered\" effect!"+ else do + e2 <- doesFileExist $ "_." ++ file+ if e2 + 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.@@ -197,21 +282,32 @@ volS :: FilePath -> Double -> IO () volS file amplitude = if isJust (showE "sox") then do- SX.norm file- exist0 <- doesFileExist $ "8" ++ file- if exist0+ SB.norm file+ e0 <- doesFileExist $ "8" ++ file+ if e0 then do- _ <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ file, "8." ++ file, "vol", showFFloat Nothing amplitude $ show 0, "amplitude"] ""- exist1 <- doesFileExist $ "8." ++ file- if exist1+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) ["8" ++ file, "8." ++ file, "vol", showFFloat Nothing amplitude $ show 0, "amplitude"] ""+ if code /= ExitSuccess 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!"+ e1 <- doesFileExist $ "8." ++ file+ if e1+ then do+ removeFile $ "8." ++ file+ removeFile $ "8" ++ file+ error "File was not created with \"vol\" effect!"+ else do+ removeFile $ "8" ++ file+ error "File was not created with \"vol\" effect!"+ else do + e2 <- doesFileExist $ "8." ++ file+ if e2 + 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 "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 @@ -223,13 +319,19 @@ 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+ upp <- SB.upperBnd fileB+ amplMax <- SB.selMA fileB (0, upp) True+ amplMin <- SB.selMA fileB (0, upp) False+ let ampl = read (fst . SB.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!"+ then do+ e1 <- doesFileExist $ "8." ++ tail fileA+ if e1+ then do+ removeFile $ "8." ++ tail fileA+ error "File was not created with \"vol\" effect!"+ else error "File was not created with \"vol\" effect!" else do file8e <- doesFileExist $ "8." ++ tail fileA if file8e @@ -246,11 +348,20 @@ 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+ (code, _, _) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "4." ++ file, "sinc", "-a", "50", "-I", "0.07k-11k"] ""+ if code /= ExitSuccess then do- removeFile file- renameFile ("4." ++ file) file- else error "The initial file was not changed!" + e1 <- doesFileExist $ "4." ++ file+ if e1+ then do+ removeFile $ "4." ++ file+ error "File was not created with \"sinc\" effect!"+ else error "File was not created with \"sinc\" effect!"+ else do + e0 <- doesFileExist $ "4." ++ file+ if e0 + 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.9.3.0+version: 0.9.4.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