dobutokO2 0.4.0.0 → 0.5.0.0
raw patch · 4 files changed
+50/−46 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- DobutokO/Sound.hs +34/−44
- README.markdown +10/−1
- dobutokO2.cabal +1/−1
CHANGELOG.md view
@@ -24,3 +24,8 @@ ## 0.4.0.0 -- 2020-03-07 * Fourth version. Fixed issues with wrongly realized rhythm behaviour. Now it corresponds to the documented.++## 0.5.0.0 -- 2020-03-07++* Fifth version. Added the possibility to specify an existing file by its absolute path to be used as a source for the sound information for SoX to generate the+resulting file. Some documentation improvements.
DobutokO/Sound.hs view
@@ -168,7 +168,8 @@ V.zip (V.generate z2 (\i -> note * fromIntegral (i + 1))) $ v2 -- | For the given frequency it generates a musical sound with a timbre. The main component of the sound includes the lower pure quint,--- which can be in the same octave or in the one with the number lower by one.+-- which can be in the same octave or in the one with the number lower by one. Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten. oberSoXSynth :: Double -> IO () oberSoXSynth x = do let note0 = closestNote x@@ -190,7 +191,8 @@ -- | Function to create a melody for the given arguments. 'String' is used to provide a rhythm. The main component of the sound includes the lower pure quint, which -- can be in the same octave or in the one with the number lower by one. The first 'Double' argument from the range [0.01..1.0] is used as a maximum amplitude -- for obertones. If it is set to 1.0 the obertones amplitudes are just the maximum ones, otherwise they are multiplied by the parameter and this results--- in their becoming more silent ones. The second 'Double' argument is a basic sound duration. The default one is 0.5 (second).+-- in their becoming more silent ones. The second 'Double' argument is a basic sound duration. The default one is 0.5 (second). Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten. oberSoXSynthN :: Int -> Double -> Double -> String -> V.Vector Double -> IO () oberSoXSynthN n ampL time3 zs vec0 | compare ampL 0.01 /= LT && compare ampL 1.0 /= GT = @@ -222,43 +224,14 @@ if ampL1 < 0.01 then oberSoXSynthN n 0.01 time3 zs vec0 else oberSoXSynthN n ampL1 time3 zs vec0 -{--uniqOberSoXSynthN n ampL time3 zs wws vec0- | compare ampL 0.01 /= LT && compare ampL 1.0 /= GT =- let (t, ws) = splitAt 1 . syllableStr n $ zs- m = length ws- zeroN = numVZeroesPre vec0- v2 = V.map (\yy -> time3 * fromIntegral (yy * m) / fromIntegral (head t)) . V.fromList $ ws in V.imapM_ (\j x -> do - let note0 = closestNote x -- zs ? vec0 -- are they related to the one object? No, they are obtained from different sources.- note1 = pureQuintNote note0- v0 = uniqOberTonesV note0 wws- v1 = uniqOberTonesV note1 wws- uniqOberSoXSynthHelpN vec = V.imapM_ (\i (noteN, amplN) -> readProcessWithExitCode (fromJust (showE "sox"))- ["-r22050", "-n", "test" ++ prependZeroes zeroN (show (i + 2)) ++ ".wav", "synth", showFFloat (Just 4) (V.unsafeIndex v2 (j `rem` m)) $ show 0,"sine",- showFFloat (Just 4) noteN $ show 0, "vol", showFFloat (Just 4) (amplN * ampL) $ show 0] "") vec- uniqOberSoXSynthHelpN2 vec = V.imapM_ (\i (noteN, amplN) -> readProcessWithExitCode (fromJust (showE "sox"))- ["-r22050", "-n", "testQ" ++ prependZeroes zeroN (show (i + 2)) ++ ".wav", "synth", showFFloat (Just 4) (V.unsafeIndex v2 (j `rem` m)) $ show 0,- "sine", showFFloat (Just 4) noteN $ show 0, "vol", showFFloat (Just 4) (amplN * ampL) $ show 0] "") vec - soxSynthHelpMain note01 note02 = readProcessWithExitCode (fromJust (showE "sox")) ["-r22050", "-n", "testA" ++- prependZeroes zeroN "1" ++ ".wav", "synth", showFFloat (Just 4) (V.unsafeIndex v2 (j `rem` m)) $ show 0,"sine", showFFloat (Just 4) note01 $ show 0,- "synth", showFFloat (Just 4) (V.unsafeIndex v2 (j `rem` m)) $ show 0,"sine", "mix", showFFloat (Just 4) note02 $ show 0] ""- soxSynthHelpMain note0 note1- uniqOberSoXSynthHelpN v0- uniqOberSoXSynthHelpN2 v1- paths0 <- listDirectory "."- let paths = sort . filter (isPrefixOf "test") $ paths0- _ <- readProcessWithExitCode (fromJust (showE "sox")) (["--combine", "mix"] ++ paths ++ ["result" ++ prependZeroes zeroN (show j) ++ ".wav","vol","0.3"]) ""- mapM_ removeFile paths ) vec0- | otherwise = let ampL1 = ampL - (fromIntegral . truncate $ ampL) in- if ampL1 < 0.01 then uniqOberSoXSynthN n 0.01 time3 zs wws vec0- else uniqOberSoXSynthN n ampL1 time3 zs wws vec0- -}- -- | Similar to 'oberSoXSynthN', but uses a sound file to obtain the information analogous to 'V.Vector' in the latter one. Besides, the function lifts -- the frequencies to the octave with the given by 'Int' parameter number (better to use from the range [1..8]). The first 'Double' argument from -- the range [0.01..1.0] is used as a maximum amplitude for obertones. If it is set to 1.0 the obertones amplitudes are just maximum ones, -- otherwise they are multiplied by the parameter and this results in their becoming more silent ones.--- The second 'Double' argument is a basic sound duration. The default one is 0.5 (second).+-- The second 'Double' argument is a basic sound duration. The default one is 0.5 (second). Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten.+--+-- For better usage the 'FilePath' should be a filepath for the .wav file. oberSoXSynthNGen :: FilePath -> Int -> Double -> Double -> String -> IO () oberSoXSynthNGen file m ampL time3 zs = do duration0 <- durationA file@@ -298,7 +271,8 @@ -- package). The timbre for another given text usually differs, but can be the same. The last one is only if the uniqueness structure and length are the -- same for both 'String'. Otherwise, they differs. This gives an opportunity to practically and quickly synthesize differently sounding intervals. -- The main component of the sound includes the lower pure quint, which can be in the same octave or in the one with--- the number lower by one.+-- the number lower by one. Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten. uniqOberSoXSynth :: Double -> String -> IO () uniqOberSoXSynth x wws = do let note0 = closestNote x@@ -323,7 +297,8 @@ -- If it is set to 1.0 the obertones amplitudes are just maximum ones, otherwise they are multiplied by the parameter and this results in -- their becoming more silent ones. The main component of the sound is in the given octave with a number given -- by 'Int' parameter. Besides, another main component of the sound includes the lower pure quint, which can be in the same octave or in the one with--- the number lower by one. The second 'Double' argument is a basic sound duration. The default one is 0.5 (second).+-- the number lower by one. The second 'Double' argument is a basic sound duration. The default one is 0.5 (second). Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten. uniqOberSoXSynthN :: Int -> Double -> Double -> String -> String -> V.Vector Double -> IO () uniqOberSoXSynthN n ampL time3 zs wws vec0 | compare ampL 0.01 /= LT && compare ampL 1.0 /= GT =@@ -359,7 +334,10 @@ -- Besides, the function lifts the frequencies to the octave with the given by 'Int' parameter number (better to use from the range [1..8]). -- The first 'Double' argument from the range [0.01..1.0] is used as a maximum amplitude for obertones. If it is set to 1.0 the -- obertones amplitudes are just the maximum ones, otherwise they are multiplied by the parameter and this results in their becoming more silent ones.--- The second 'Double' argument is a basic sound duration. The default one is 0.5 (second).+-- The second 'Double' argument is a basic sound duration. The default one is 0.5 (second). Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten.+--+-- For better usage the 'FilePath' should be a filepath for the .wav file. uniqOberSoXSynthNGen :: FilePath -> Int -> Double -> Double -> String -> String -> IO () uniqOberSoXSynthNGen file m ampL time3 zs wws = do duration0 <- durationA file@@ -378,29 +356,41 @@ _ <- readProcessWithExitCode (fromJust (showE "sox")) (paths3 ++ ["end.wav"]) "" mapM_ removeFile paths3 --- | Function that actually makes processing in the @dobutokO2@ executable.+-- | Function that actually makes processing in the @dobutokO2@ executable. Please, check before executing+-- whether there is no \"x.wav\", \"test*\", \"result*\" and \"end.wav\" files in the current directory, because they can be overwritten. dobutokO2 :: IO () dobutokO2 = do args <- getArgs let arg1 = concat . take 1 $ args file = concat . drop 1 . take 2 $ args+ exist2 <- doesFileExist file case arg1 of "1" -> do- [_,_,octave,ampLS,time2] <- mapM (recAndProcess file) [1..5]+ [_,_,octave,ampLS,time2] <- mapM (recAndProcess file) (if exist2 then [1..5] else 0:[2..5]) let octave1 = read octave::Int ampL = read ampLS::Double time3 = read time2::Double- oberSoXSynthNGen (file ++ ".wav") octave1 ampL time3 (unwords . drop 2 $ args)+ oberSoXSynthNGen file octave1 ampL time3 (unwords . drop 2 $ args) _ -> do- [_,_,octave,ampLS,time2,wws] <- mapM (recAndProcess file) [1..6]+ [_,_,octave,ampLS,time2,wws] <- mapM (recAndProcess file) (if exist2 then [1..6] else 0:[2..6]) let octave1 = read octave::Int ampL = read ampLS::Double time3 = read time2::Double- uniqOberSoXSynthNGen (file ++ ".wav") octave1 ampL time3 (unwords . drop 2 $ args) wws+ uniqOberSoXSynthNGen file octave1 ampL time3 (unwords . drop 2 $ args) wws --- | Function records and processes the sound data needed to generate the \"end.wav\" file in the 'dobutokO2' function.+-- | Function records and processes the sound data needed to generate the \"end.wav\" file in the 'dobutokO2' function. Please, check before executing+-- whether there is no \"x.wav\" file in the current directory, because it can be overwritten. recAndProcess :: String -> Int -> IO String recAndProcess file x+ | x == 0 = onException (readProcessWithExitCode (fromJust (showE "sox")) [file, "x.wav", "-r22050", "channels", "1"] "" >> putStrLn "" >> return "") (do+ exist <- doesFileExist "x.wav"+ if exist then removeFile "x.wav"+ else putStr ""+ putStrLn ""+ putStr "The process was not successful may be because of the not valid data OR SoX cannot convert the given file to the .wav format. "+ putStrLn "Interrupt the program and start again with the valid file. "+ putStrLn "_______________________________________________________________________"+ recAndProcess file 0) | x == 1 = onException (do tempeRa 0 putStrLn "Please, specify, how many seconds long sound data you would like to record."
README.markdown view
@@ -7,9 +7,18 @@ You can use it as a library or an executable. +Please, check before executing whether there is no "x.wav", "test*.wav",+"result*.wav" and "end.wav" files in the current directory, because they+can be overwritten. The same can be said about "nx*.wav" files in the directory.+ For the executable you enter in the terminal: -dobutokO2 {1 | 2} {name-of-the-file-to-be-recorded-to-obtain-sound-information-from-without-file-extension} {Ukrainian text}+dobutokO2 {1 | 2} {fileName} {Ukrainian text}++ where filename is:+ the full name of the file to be recorded in the current directory or+ the full absolute path to the sound .wav file (or other one format+ that is supported by your SoX installation) to obtain sound information from. If the first command line argument equals to "1" then the executable uses the oberTones funcions, so for the given parameters the obertones
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dobutokO2-version: 0.4.0.0+version: 0.5.0.0 synopsis: A program and a library to create experimental music from a mono audio and a Ukrainian text description: It can also create a timbre for the notes homepage: https://hackage.haskell.org/package/dobutokO2