packages feed

mmsyn6ukr 0.5.0.0 → 0.5.1.0

raw patch · 3 files changed

+41/−26 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -86,3 +86,7 @@ ## 0.5.0.0 -- 2019-12-07  * Fifth version. Changed a behaviour of the Main.main function, added a possibility of more control on the program mmsyn6ukr.++## 0.5.0.0 -- 2019-12-09++* Fifth version revised A. Fixed the genControl function, added more documentation, make the exception message more exact.
Main.hs view
@@ -43,15 +43,19 @@ --  -- * Notification. -- --- Please, notice that successful usage of the SoX installed in the system prior to the @mmsyn6ukr@ leads to approximately doubling --- the size of used space in the storage for the resulting files because it adds a header to the .raw file and writes down additionally --- the raw data to form a .wav file. Also notice that the size of the largest data file representing a symbol or their combination is 6792 bytes (with 44-byte --- header included). So, if you expect to create sounding for @n@ symbols of the Ukrainian text, provide at least @2 * (6792 - 44) * n + 44 = 13496 * n + 44@ (bytes) --- of the additional space in the storage (in reality it can occupy much less because other data files are less in size). Afterwards, the program deletes --- the .raw file (this will approximately halve the occupied space by the resulting file) and you can manually compress the .wav file --- (e. g. FLAC compression with the best ratio gives approximately halving the size. Therefore, the resulting file --- for the @mmsyn6ukr@ executable run prior to such operations without command line arguments is expected to be less than about @10^7@ bytes that is about 100 MB --- (for 31416 symbols Ukrainian text)). The best comression is with the .ogg files, but they can lose some quality so be careful if you need it.+-- Please, notice that successful usage of the SoX installed in the system at the moment of running the @mmsyn6ukr@ can lead to approximately doubling +-- (in the most space consuming variant) the size of used space in the storage for the resulting files while being processed because it adds a header +-- to the .raw file and writes down additionally the raw data to form a .wav file. Afterwards, it deletes the .raw file, so space is used finally in the +-- more efficient manner. +-- +-- Also notice that the size of the largest data file representing a symbol or their combination is 6792 bytes (with 44-byte header included). So, if you +-- expect to create sounding for @n@ symbols of the Ukrainian text, provide at least @2 * (6792 - 44) * n + 44 = 13496 * n + 44@ (bytes) of the additional +-- space in the storage (in reality it can occupy much less because other data files are less in size). Afterwards, the program deletes the .raw file (this +-- will approximately halve the occupied space by the resulting file) and you can manually compress the .wav file (e. g. FLAC compression with the best ratio +-- gives approximately 0.53 of the original size. Therefore, the resulting file for the @mmsyn6ukr@ executable run prior to such operations without command +-- line arguments is expected to be less than about @10^7@ bytes that is about 100 MB (for 31416 symbols Ukrainian text)). +-- +-- The best comression ratio is with the .ogg files, but they lose some quality so be careful if you need it. main :: IO () main = bracketOnError (do   args <- getArgs@@ -59,9 +63,9 @@   nameOfSoundFile <- getLine   let nameSF = filter (\x -> not (isSpace x) && not (isControl x) && x /= '}') nameOfSoundFile   return (args, nameSF)) (\(args, nameSF) -> do-    putStr $ "Exception: please, specify the command line argument (if needed) in the form \"ABC\""-    putStrLn $ " where A is either a letter \'f\', \'o\', \'w\' or a digit and B and C are both digits! " -      ++ show args ++ " for the file: " ++ show nameSF) (\(args, nameSF) -> do +    putStr $ "Notice, there was (may be) CmdLineArgument exception. To avoid it, please, specify the command line argument (if needed) in the form \"ABC\""+    putStrLn $ " where A is either a letter \'f\', \'o\', \'w\' or a digit and B and C are both digits! The exception (may be) arose from the command line arguments " +      ++ show args ++ " for the file: " ++ show nameSF ++ ". Please, check also whether the SoX was installed with the support for needed codec.") (\(args, nameSF) -> do           xs <- getContents          let ys = take (nSymbols (let zs = take 1 args in if null zs then [] else fst . genControl . head $ zs)) xs in               withBinaryFile (nameSF ++ ".raw") AppendMode (appendS16LEFile (convertToProperUkrainian ys))@@ -85,11 +89,11 @@                          putStrLn "OR you can install SoX executable in the directory mentioned in the variable PATH and then run: "                          putStrLn "\"Path_to_the_SoX_executable\" -b16 -r22050 -c1 -e signed-integer -L \"name_of_the_file_in_raw_format_with_new._prefix\" \"name_of_the_file_in_raw_format_with_new._prefix\" in the terminal.") --- | Function that converts the first command line argument given, which is a digit in the range @[0..9]@ --- (providing an ascending approximately exponential scale with a basis of 10 starting from 2 and ending at 1000000001), --- to the upper bound of number of symbols that the 'Main.main' function of the @mmsyn6ukr@ executable reads from the 'System.IO.stdin' for sounding.--- The default value (no input) is 31416. If there is another first command line argument then the program --- terminates with the error and informational message. Using the command line argument is done for the security reasons: +-- | Function that converts the first digit in the command line argument (starting the argument or being the second one after the letter character) given, +-- which is a digit in the range @[0..9]@ (providing an ascending approximately exponential scale with a basis of 10 starting from 2 and ending at 1000000001), +-- to the upper bound of number of symbols that the 'main' function of the @mmsyn6ukr@ executable reads from the 'System.IO.stdin' for sounding.+-- The default resulting value (no input) is 31416. If there is another first command line argument then the program +-- terminates with the informational message. Using the command line argument is done for the security reasons:  -- because of performative writing to the resulting file(s) there is a need to limit the used memory. For most cases it is -- enough to use the default value. If you have enough resources and a large Ukrainian text amount then specify the higher values  -- (5 or a greater one). @@ -109,16 +113,23 @@ --  -- A: -- --- \'f\' -> native FLAC format with compression from 0 (least) to 8 (best compression ratio) specified by the third characters; \'9\' is equivalent to \'8\'.--- \'o\' -> Ogg Vorbis format with compression from -1 (best) to 10 (least) specified by the characters after the first two characters;--- \'w\' -> WAV format with two options for bitrate - 11025 if the third character is less than 5 and otherwise 22050 (the default one also for no command line arguments).--- If A is a digit, then it is used accordingly to 'nSymbols' function and SoX (if properly installed) converts the .raw file to the default .wav with 22050 Hz bitrate.+-- \'f\' -> native FLAC format with compression from 0 (least) to 8 (best compression ratio) specified by the third characters; \'9\' is equivalent to \'8\'. This format is optional so, +-- please, check whether it is supported by your SoX binaries. If no, install the SoX with support for the format. For more information, please, refer to the @sox@ documentation. -- --- For more information, please, see the sox manuals (e. g. for @soxformat@).+-- \'o\' -> Ogg Vorbis format with compression from -1 (best) to 10 (least) specified by the characters after the first two characters. The default value is "-1". This format is optional +-- so, please, check whether it is supported by your SoX binaries. If no, install the SoX with support for the format. For more information, please, refer to the @sox@ documentation.+-- +-- \'w\' -> WAV format with two options for bitrate - 11025 if the third character is less than '5' and greater than '0' and otherwise 22050 (the default one also for no command line arguments). +-- +-- If A is a digit, then it is used accordingly to 'nSymbols' function and SoX (if properly installed) quickly converts the .raw file to the default .wav with 22050 Hz bitrate.+-- +-- To obtain the best compression ratio, please specify something like \"o9-1\" or \"o5-1\" (or similar). For the best lossless compression - \"f98\" or \"f58\" (or similar). +-- +-- For more information, please, see the @sox@ manuals (e. g. for @soxformat@). genControl :: String -> (String, (String, String))-genControl (x:xs) | x == 'f' = ([head xs], ("-C" ++ (if tail xs < "9" then tail xs else "8"), ".flac"))-                  | x == 'o' = ([head xs], ("-C" ++ (if (compare (tail xs) "10" /= GT) && (compare (tail xs) "-1" == GT) then tail xs else "-1"), ".ogg"))-                  | x == 'w' = ([head xs], ("-r" ++ (if (compare (tail xs) "4" /= GT) then "11025" else "22050"), ".wav"))+genControl (x:xs) | x == 'f' = ([head xs], ("-C" ++ (if (compare (tail xs) "9" /= GT) && (compare (tail xs) "0" /= LT) then take 1 . tail $ xs else "8"), ".flac"))+                  | x == 'o' = ([head xs], ("-C" ++ (if ((compare (tail xs) "9" /= GT) && (compare (tail xs) "0" /= LT)) then take 1 . tail $ xs else if (tail xs == "10") then "10" else "-1"), ".ogg"))+                  | x == 'w' = ([head xs], ("-r" ++ (if ((compare (tail xs) "4" /= GT) && (compare (tail xs) "0" /= LT)) then "11025" else "22050"), ".wav"))                   | isDigit x = ([x], ("", ".wav"))                   | otherwise = ("", ("", ".wav")) genControl [] = ("", ("", ".wav"))
mmsyn6ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn6ukr-version:             0.5.0.0+version:             0.5.1.0 synopsis:            A musical instrument synthesizer or a tool for Ukrainian language listening description:         A program can be used as a musical instrument synthesizer or for Ukrainian speech synthesis especially for poets and writers homepage:            https://hackage.haskell.org/package/mmsyn6ukr