mmsyn7l 0.4.3.0 → 0.5.0.0
raw patch · 4 files changed
+144/−5 lines, 4 filesdep +mmsyn3dep +processPVP ok
version bump matches the API change (PVP)
Dependencies added: mmsyn3, process
API changes (from Hackage documentation)
+ MMSyn7l: cfw2wf :: FilePath -> FilePath
+ MMSyn7l: efw2 :: FilePath -> String
+ MMSyn7l: efw2vv :: FilePath -> String
+ MMSyn7l: f2w :: FilePath -> FilePath
+ MMSyn7l: fadeEnds :: FilePath -> IO ()
+ MMSyn7l: fadeEndsMil2 :: FilePath -> IO ()
+ MMSyn7l: fadeEndsMilN :: Int -> FilePath -> IO ()
+ MMSyn7l: fadeWav002 :: IO ()
+ MMSyn7l: fadeWavN :: Int -> IO ()
+ MMSyn7l: flacToWav :: String -> FilePath -> IO ()
+ MMSyn7l: soxE :: FilePath -> [String] -> IO ()
+ MMSyn7l: w2f :: FilePath -> FilePath
+ MMSyn7l: wOrf :: FilePath -> String
+ MMSyn7l: wavToFlac :: String -> FilePath -> IO ()
Files
- CHANGELOG.md +5/−0
- MMSyn7l.hs +128/−2
- README.markdown +8/−0
- mmsyn7l.cabal +3/−3
CHANGELOG.md view
@@ -66,3 +66,8 @@ * Fourth version revised C. Changed bounds for the dependencies so that now also GHC 8.10* series are supported. +## 0.5.0.0 -- 2020-05-20++* Fifth version. From DobutokO.Sound.IntermediateF module (dobutokO2 package) some functions were moved here. They are in MMSyn7l module. This was +done to allow their usage without the necessity to install dobutokO2 package (just using mmsyn7* series). Added new fade functions to the same +module using the moved ones.
MMSyn7l.hs view
@@ -12,8 +12,8 @@ module MMSyn7l where -import qualified Data.List as L (sort,isPrefixOf)-import System.Directory (listDirectory)+import qualified Data.List as L (sort,isPrefixOf,isSuffixOf)+import System.Directory import Data.Char (toUpper, isDigit) import qualified SoXBasics as SB import qualified SoXBasics1 as SB1@@ -21,7 +21,13 @@ import Control.Exception (onException) import CaseBi (getBFst') import Control.Exception.FinalException+import System.Process+import System.Exit (ExitCode(ExitSuccess))+import EndOfExe (showE)+import Data.Maybe (fromJust)+import Numeric + -- | 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 preceded by a symbol \"-\"). If the @String@ @@ -181,3 +187,123 @@ ; putStrLn "" ; putStrLn "Now you have changed (or left unchanged) the amplitudes for the needed \"result*.wav\" sound files." }) (do error "Please, specify a right numbers for the first and last files to be adjusted starting count from 0.")++-----------------------------------------------------------------------------------------------++-- Taken from the DobutokO.Sound.IntermediateF module here so that they are more used this way. ++-- | Takes a filename to be applied a SoX chain of effects (or just one) as list of 'String' (the second argument). Produces the temporary+-- new file with the name ((name-of-the-file) ++ (\"effects.wav\" OR \"effects.flac\") -- the type is preserved), which then is removed. +--+-- The syntaxis is that every separate literal for SoX must be a new element in the list. Please, for more information, refer to SoX documentation.+-- Please, check by yourself whether you have enough permissions to read and write to the 'FilePath'-specified+-- file and to the containing it directory. The function is not intended to be used in otherwise cases.+soxE :: FilePath -> [String] -> IO ()+soxE file arggs = do+ (code,_,_) <- readProcessWithExitCode (fromJust (showE "sox")) ([file,file ++ "effects" ++ efw2 file] ++ arggs) ""+ case code of+ ExitSuccess -> renameFile (file ++ "effects" ++ efw2 file) file+ _ -> do+ removeFile $ file ++ "effects" ++ efw2 file+ putStrLn $ "MMSyn7l.soxE \"" ++ file ++ "\" has not been successful. The file has not been changed at all. "++-- | Applies \"fade\" effect to both ends of the supported by SoX sound file 'FilePath' so that concatenating them consequently after such application +-- leads to no clipping. Otherwise, the clipping exists if not prevented by may be some other means. For more information, please, refer to the+-- SoX documentation.+fadeEnds :: FilePath -> IO ()+fadeEnds = fadeEndsMilN 10++-- | Applies \"fade\" effect to both ends of the supported by SoX sound file 'FilePath' so that concatenating them consequently after such application +-- leads to no clipping. Otherwise, the clipping exists if not prevented by may be some other means. The duration of the changes are in 5 times +-- smaller than for 'fadeEnds' function and is equal to 0.002 sec. For more information, please, refer to the SoX documentation.+fadeEndsMil2 :: FilePath -> IO ()+fadeEndsMil2 = fadeEndsMilN 2++-- | Applies \"fade\" effect to both ends of the supported by SoX sound file 'FilePath' so that concatenating them consequently after such application +-- leads to no clipping. Otherwise, the clipping exists if not prevented by may be some other means. The duration of the changes are usually +-- smaller than for 'fadeEnds' function and is equal to 0.001 \* n sec (where n is in range [1..10]). +-- For more information, please, refer to the SoX documentation.+fadeEndsMilN :: Int -> FilePath -> IO ()+fadeEndsMilN n file = soxE file ["fade","q", showFFloat (Just 4) (if (n `rem` 11) /= 0 then 0.001 * fromIntegral (n `rem` 11) else 0.002) "","-0.0"]++------------------------------------------------------------------------------------------------------++-- New functions with usage of the moved here fadeEnds* and 'soxE' functions.++-- | Using a new function 'fadeEndsMil2' fades the ends of the .wav files in the current directory.+fadeWav002 :: IO ()+fadeWav002 = do+ dir0 <- fmap (filter (`L.isSuffixOf` ".wav")) . listDirectory $ "."+ mapM_ fadeEndsMil2 dir0++-- | Using a new function 'fadeEndsMilN' fades the ends of the .wav files in the current directory. The first argument is the 'Int' argument +-- for the 'fadeEndsMilN' and is a number of milliseconds to be used for fading (usually from 1 to 10). +fadeWavN :: Int -> IO ()+fadeWavN n = do+ dir0 <- fmap (filter (`L.isSuffixOf` ".wav")) . listDirectory $ "."+ mapM_ (fadeEndsMilN n) dir0 ++-- | Converts WAV file to FLAC file using SoX (please, check before whether your installation supports FLAC files) using possible rate and bit depth+-- conversion accordingly to 'soxBasicParams' format. If the conversion is successful ('ExitCode' is 'ExitSuccess') then removes the primary file.+wavToFlac :: String -> FilePath -> IO ()+wavToFlac ys file = do+ let (ts,zs) = splitAt 2 . init $ ys+ (code,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) [file,getBFst' ("-r22050",V.fromList . zip ["11","16", "17", "19", "32", "44", "48",+ "80", "96"] $ ["-r11025","-r16000","-r176400","-r192000","-r32000","-r44100","-r48000","-r8000","-r96000"]) ts, if zs == "2" then "-b24"+ else "-b16",take (length file - 3) file ++ "flac"] ""+ case code of+ ExitSuccess -> removeFile file+ _ -> do+ putStrLn $ "DobutokO.Sound.IntermediateF.wavToFlac: " ++ herr+ exi <- doesFileExist $ take (length file - 3) file ++ "flac"+ if exi then removeFile (take (length file - 3) file ++ "flac") >> error ""+ else error ""++-- | Converts FLAC file to WAV file using SoX (please, check before whether your installation supports FLAC files) using possible rate and bit depth+-- conversion accordingly to 'soxBasicParams' format. If the conversion is successful ('ExitCode' is 'ExitSuccess') then removes the primary file.+flacToWav :: String -> FilePath -> IO ()+flacToWav ys file = do+ let (ts,zs) = splitAt 2 . init $ ys+ (code,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) [file,getBFst' ("-r22050",V.fromList . zip ["11","16", "17", "19", "32", "44", "48",+ "80", "96"] $ ["-r11025","-r16000","-r176400","-r192000","-r32000","-r44100","-r48000","-r8000","-r96000"]) ts, if zs == "2" then "-b24"+ else "-b16",take (length file - 4) file ++ "wav"] ""+ case code of+ ExitSuccess -> removeFile file+ _ -> do+ putStrLn $ "DobutokO.Sound.IntermediateF.flacToWav: " ++ herr+ exi <- doesFileExist $ take (length file - 4) file ++ "wav"+ if exi then removeFile (take (length file - 4) file ++ "wav") >> error ""+ else error "" ++w2f :: FilePath -> FilePath+w2f file = let (zs,ts) = splitAt (length file - 4) file in if ts == ".wav" then zs ++ ".flac" else error "You give not a WAV file! "+ +f2w :: FilePath -> FilePath+f2w file = let (zs,ts) = splitAt (length file - 5) file in if ts == ".flac" then zs ++ ".wav" else error "You give not a FLAC file! "++wOrf :: FilePath -> String+wOrf file =+ let (_,us) = splitAt (length file - 4) file in+ case us of+ ".wav" -> "w"+ "flac" -> "f"+ _ -> error "You give neither a WAV nor a FLAC file! "++cfw2wf :: FilePath -> FilePath+cfw2wf file+ | wOrf file == "w" = w2f file+ | wOrf file == "f" = f2w file+ | otherwise = error "You give neither a WAV nor a FLAC file! "++efw2 :: FilePath -> String+efw2 file+ | wOrf file == "w" = ".wav"+ | wOrf file == "f" = ".flac"+ | otherwise = error "You give neither a WAV nor a FLAC file! "++efw2vv :: FilePath -> String+efw2vv file+ | wOrf file == "w" = ".flac"+ | wOrf file == "f" = ".wav"+ | otherwise = error "You give neither a WAV nor a FLAC file! "+
README.markdown view
@@ -54,3 +54,11 @@ their volume. You can additionally specify the numbers for the first and for the last files to be adjusted. + ***** Library Functions to Edit Sound *****+ -------------------------------------------++Since the 0.5.0.0 version from DobutokO.Sound.IntermediateF module (dobutokO2 package) +some functions were moved here. They are in MMSyn7l module. This was done to allow +their usage without the necessity to install dobutokO2 package (just using mmsyn7* +series). Added new functions that use the moved ones.+
mmsyn7l.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn7l-version: 0.4.3.0+version: 0.5.0.0 synopsis: Modifies the amplitudes of the Ukrainian sounds representations created by mmsyn7ukr package. description: A program and a library to modify the amplitudes of the Ukrainian sounds representations created by mmsyn7ukr package or somehow otherwise. homepage: https://hackage.haskell.org/package/mmsyn7l@@ -20,7 +20,7 @@ exposed-modules: Main, MMSyn7l -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.15, mmsyn7ukr >=0.15.4 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.8 && <1, directory >=1.2.7 && <2+ build-depends: base >=4.7 && <4.15, mmsyn7ukr >=0.15.4 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.8 && <1, directory >=1.2.7 && <2, process >=1.4 && <1.9, mmsyn3 >=0.1.5 && <1 -- hs-source-dirs: default-language: Haskell2010 @@ -28,6 +28,6 @@ main-is: Main.hs -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.15, mmsyn7ukr >=0.15.4 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.8 && <1, directory >=1.2.7 && <2+ build-depends: base >=4.7 && <4.15, mmsyn7ukr >=0.15.4 && <1, vector >=0.11 && <0.14, mmsyn2 >=0.1.8 && <1, directory >=1.2.7 && <2, process >=1.4 && <1.9, mmsyn3 >=0.1.5 && <1 -- hs-source-dirs: default-language: Haskell2010