packages feed

mmsyn7ukr 0.3.0.1 → 0.3.1.0

raw patch · 4 files changed

+72/−34 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ SoXBasics: opFile :: FilePath -> Double -> IO ()
- SoXBasics: alterVadB :: FilePath -> Double -> IO ()
+ SoXBasics: alterVadB :: FilePath -> Double -> Double -> IO ()
- SoXBasics: alterVadE :: FilePath -> Double -> IO ()
+ SoXBasics: alterVadE :: FilePath -> Double -> Double -> IO ()

Files

ChangeLog.md view
@@ -33,3 +33,8 @@ ## 0.3.0.1 -- 2019-12-25  * Third version revised A. Changed some documentation and text messages to more consistent ones.++## 0.3.1.0 -- 2019-12-27++* Third version revised B. Changed the behaviour for 'alterVadB' and 'alterVadE' functions so that are now fully iterative with thread delay.+
Processing_mmsyn7ukr.hs view
@@ -66,18 +66,18 @@   noiseProfB "8x.wav"   noiseReduceB "8x.wav"   lim0 <- durationA "_8x.wav"-  alterVadB "_8x.wav" lim0-  lim1 <- durationA "7_8x.wav"+  alterVadB "_8x.wav" lim0 (duration0*0.1)+  lim1 <- durationA "_8x.wav"   if lim1 <= 0.0     then beginProcessing file file1 soundUkr     else do -      alterVadE "7_8x.wav" lim1-      sincA "67_8x.wav"-      resampleA "4.67_8x.wav" (22050::Int)-      quarterSinFade "34.67_8x.wav"-      norm "434.67_8x.wav"-      volS2 "8434.67_8x.wav" file-      renameFile "8.434.67_8x.wav" file1+      alterVadE "_8x.wav" lim1 (duration0*0.1)+      sincA "_8x.wav"+      resampleA "4._8x.wav" (22050::Int)+      quarterSinFade "34._8x.wav"+      norm "434._8x.wav"+      volS2 "8434._8x.wav" file+      renameFile "8.434._8x.wav" file1       cleanTemp        -- | Function 'beginProcessing' is used to catch the variant where the sound is fully cut by the SoX because the sound was created in inappropriate time.@@ -115,18 +115,18 @@   noiseProfB "8x.wav"   noiseReduceB "8x.wav"   lim0 <- durationA "_8x.wav"-  alterVadB "_8x.wav" lim0-  lim1 <- durationA "7_8x.wav"+  alterVadB "_8x.wav" lim0 (duration0 * 0.1)+  lim1 <- durationA "_8x.wav"   if lim1 <= 0.0     then beginProcessing file file1 soundUkr     else do -      alterVadE "7_8x.wav" lim1-      sincA "67_8x.wav"-      resampleA "4.67_8x.wav" (22050::Int)-      quarterSinFade "34.67_8x.wav"-      norm "434.67_8x.wav"-      volS2 "8434.67_8x.wav" file-      renameFile "8.434.67_8x.wav" file1+      alterVadE "_8x.wav" lim1 (duration0 * 0.1)+      sincA "_8x.wav"+      resampleA "4._8x.wav" (22050::Int)+      quarterSinFade "34._8x.wav"+      norm "434._8x.wav"+      volS2 "8434._8x.wav" file+      renameFile "8.434._8x.wav" file1       cleanTemp  -- | Function to get the @Double@ value, which shows in how many times you expect that your sound representation will be longer than the one provided by the @mmsyn6ukr@ package. 
SoXBasics.hs view
@@ -20,6 +20,7 @@ import System.IO import EndOfExe import System.Exit+import Control.Concurrent (threadDelay)  -- | Function 'maxAbs' allows to choose a maximum by absolute value if the values are written as @String@. Bool @True@ corresponds to maximum value, @False@ - to minimum value maxAbs :: (String, String) -> (String, Bool)@@ -72,18 +73,46 @@  -- | Function 'alterVadB' removes an approximate silence measured by the absolute value of the sound amplitude from the beginning of the file.  -- The function must be used with the @FilePath@ parameter containing no directories in its name (that mean the file of the @FilePath@ parameter must be --- in the same directory that also the function is called from).-alterVadB :: FilePath -> Double -> IO ()-alterVadB file lim = if isJust (showE "sox") && isJust (showE "soxi")+-- in the same directory that also the function is called from). The file must have maximum amplitude absolute value close to 1 before call to the 'alterVadB'. +-- The second @Double@ parameter is used to exit the iteration cycle.+alterVadB :: FilePath -> Double -> Double -> IO ()+alterVadB file lim exit | compare lim exit /= GT = putStrLn $ "File " ++ file ++ " is ready for further processing."+                        | otherwise = + if isJust (showE "sox")   then do-    (_, _, herr) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "-n", "trim", "0", showFFloat Nothing lim $ show 0, "stat"] ""-  --  (_, Just hout, _, _) <- createProcess (proc (fromJust (showE "soxi")) ["-d",file]){ std_out = CreatePipe }-    --y0 <- hGetContents hout-    let zs = lines herr in let z = concatMap (dropWhile (not . isDigit)) . take 1 . drop 3 $ zs in if z < "0.04" -      then readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing lim $ show 0, "-0.000"] "" >> return ()-      else alterVadB file (lim / 2.0)+    lim1 <- durationA file+    case (compare lim1 lim) of +      LT -> alterVadB file lim1 exit+      EQ -> do +        (_, _, 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 < "0.04" +          then do +            (_, _, herr3) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim1 / 2.0) $ show 0, "-0.000000"] ""+            threadDelay 100000+            opFile file exit+          else alterVadB file (lim1 / 4.0) exit+      _  -> do+        (_, _, 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 < "0.04" +          then do +            (_, _, herr3) <- readProcessWithExitCode (fromJust (showE "sox")) [file, "7" ++ file, "trim", showFFloat Nothing (lim / 2.0) $ show 0, "-0.000000"] ""+            threadDelay 100000+            opFile file exit+          else alterVadB file (lim / 4.0) exit   else error "SoX is not properly installed in your system. Please, install it properly and then call the function again." +-- | 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.+opFile :: FilePath -> Double -> IO ()+opFile file exit = do+  removeFile file+  exist0 <- doesFileExist file+  if not exist0 +    then do +      renameFile ("7" ++ file) file+      lim2 <- durationA file+      alterVadB file lim2 exit+    else opFile file exit+ -- | 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 mean the file of the @FilePath@ parameter must be  -- in the same directory that also the function is called from).@@ -110,14 +139,17 @@    -- | Function 'alterVadE' removes an approximate silence measured by the absolute value of the sound amplitude from the end of the file.  -- The function must be used with the @FilePath@ parameter containing no directories in its name (that mean the file of the @FilePath@ parameter must be --- in the same directory that also the function is called from).-alterVadE :: FilePath -> Double -> IO ()-alterVadE file lim = if isJust (showE "sox") +-- in the same directory that also the function is called from). The second @Double@ parameter is used to exit the iteration cycle.+alterVadE :: FilePath -> Double -> Double -> IO ()+alterVadE file lim exit | compare lim exit /= GT = putStrLn $ "File " ++ file ++ " is ready for further processing"+                        | otherwise = + if isJust (showE "sox")    then do     _ <- readProcessWithExitCode (fromJust (showE "sox")) [file, "6" ++ file, "reverse"] ""-    alterVadB ("6" ++ file) lim-    _ <- readProcessWithExitCode (fromJust (showE "sox")) ["76" ++ file, "6" ++ file, "reverse"] ""-    removeFile $ "76" ++ file+    alterVadB ("6" ++ file) lim exit+    _ <- readProcessWithExitCode (fromJust (showE "sox")) ["6" ++ file, "76" ++ file, "reverse"] ""+    removeFile $ "6" ++ file+    renameFile ("76" ++ file) 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.
mmsyn7ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn7ukr-version:             0.3.0.1+version:             0.3.1.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@@ -29,6 +29,7 @@   -- 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+  ghc-options:         -threaded     -- hs-source-dirs:   default-language:    Haskell2010