packages feed

dobutokO2 0.8.1.0 → 0.8.2.0

raw patch · 3 files changed

+24/−14 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -79,4 +79,9 @@  ## 0.8.1.0 -- 2020-03-12 -* Eigth version revised B. Changed the sofisticated mechanism to provide real obertones in the 'oberSoXSynth2FDN' function.+* Eigth version revised B. Changed the sophisticated mechanism to provide real obertones in the 'oberSoXSynth2FDN' function.++## 0.8.2.0 -- 2020-03-12++* Eigth version revised C. Changed the sophisticated mechanism to provide real obertones in the 'oberSoXSynth2FDN' function. Fixed issues with some zeroes+in the functions. Some code improvements that give more stability. Documentation improvement.
DobutokO/Sound.hs view
@@ -68,7 +68,7 @@ import Numeric import Control.Exception (onException) import System.Environment (getArgs)-import Data.List (isPrefixOf,sort,sortBy)+import Data.List (isPrefixOf,sort,sortBy,nubBy) import Data.Maybe (isJust,isNothing,fromJust) import Data.Char (isDigit) import qualified Data.Vector as V@@ -234,7 +234,7 @@ -- 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+  let note0 = if x /= 0.0 then closestNote (abs x) else V.unsafeIndex notes 0       note1 = pureQuintNote note0       v0    = oberTones note0       v1    = oberTones note1@@ -307,21 +307,24 @@     _ <- readProcessWithExitCode (fromJust (showE "sox")) (["--combine", "mix"] ++ paths ++ ["result.wav","vol","0.3"]) ""     mapM_ removeFile paths --- | Similar to 'oberSoXSynth2DN' but instead of 'oberTones' function, it uses volatile function @f::Double -> V.Vector (Double, Double)@ with--- somewhat sofisticated mechanism to normalize the resulting 'V.Vector' elements @(Double, Double)@. The last one is experimental feature, so+-- | Similar to 'oberSoXSynth2DN' but instead of 'oberTones' function, it uses volatile function @f::Double -> Vector (Double, Double)@ with+-- somewhat sophisticated mechanism to normalize the resulting 'V.Vector' elements @(Double, Double)@. The last one is experimental feature, so -- it is your responsibility to provide a function so that it does not lead to clipping. In such a case, the result of application of the -- 'convertToProperUkrainian' to the 'String' parameter must not be 'V.empty'.+--+-- Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function.+-- But for a lot of functions this works well. oberSoXSynth2FDN :: (Double -> V.Vector (Double, Double)) -> Double -> Double -> String -> IO () oberSoXSynth2FDN f x y zs  | V.null . convertToProperUkrainian $ zs = oberSoXSynth x  | otherwise = do-    let note0 = closestNote x+    let note0 = closestNote (if x /= 0.0 then abs x else V.unsafeIndex notes 0)         note1 = dNote (V.unsafeIndex (intervalsFromString zs) 0) note0-        g0    = V.fromList . sortBy (\(x1,_) (x2,_) -> compare x1 x2) . V.toList . V.map (\(noteX, amplX) -> (closestNote noteX, abs (amplX - (fromIntegral .-           truncate $ amplX)))) . f-        g k   = if V.null (g0 k) then V.empty-                else V.takeWhile (\w -> compare (fst w) (V.unsafeIndex notes 107) /= GT && compare (snd w) 0.001 == GT) . V.imap (\i (noteY,z0) ->-                  (fromIntegral (i + 1) * (fst . V.unsafeIndex (g0 k) $ 0), z0)) . g0 $ k+        g0    = V.fromList . nubBy (\(x1,_) (x2,_) -> x1 == x2) . sortBy (\(x1,_) (x2,_) -> compare x1 x2) . V.toList . V.map (\(noteX, amplX) ->+           if noteX <= 0.0 then (fromIntegral 2 * note0, abs (amplX - (fromIntegral . truncate $ amplX))) else (closestNote noteX,+             abs (amplX - (fromIntegral . truncate $ amplX)))) . f+        g k   = V.takeWhile (\w -> compare (fst w) (V.unsafeIndex notes 107) /= GT && compare (snd w) 0.001 == GT) .+                   V.imap (\i (noteY,z0) -> (fromIntegral (i + 1) * (fst . V.unsafeIndex (g0 k) $ 0), z0)) . g0 $ k          v0    = g note0         v1    = if isNothing note1 then V.empty                 else g . fromJust $ note1@@ -333,7 +336,8 @@             "vol", showFFloat (Just 4) amplN $ show 0] "") vec     _ <- readProcessWithExitCode (fromJust (showE "sox")) ["-r22050", "-n", "testA.wav", "synth", showFFloat (Just 4) y $ show 0,"sine",        showFFloat (Just 4) note0 $ show 0] ""-    if isNothing note1 then do oberSoXSynthHelp v0+    if isNothing note1 then do+      oberSoXSynthHelp v0     else do        _ <- readProcessWithExitCode (fromJust (showE "sox")) ["-r22050", "-n", "testB.wav", "synth", showFFloat (Just 4) y $ show 0,"sine",          showFFloat (Just 4) (fromJust note1) $ show 0] ""@@ -342,7 +346,8 @@     paths0 <- listDirectory "."     let paths = sort . filter (isPrefixOf "test") $ paths0     _ <- readProcessWithExitCode (fromJust (showE "sox")) (["--combine", "mix"] ++ paths ++ ["result.wav","vol","0.3"]) ""-    mapM_ removeFile paths      +    mapM_ removeFile paths+     -- | 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. Please, check before executing
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO2-version:             0.8.1.0+version:             0.8.2.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