packages feed

dobutokO2 0.23.0.0 → 0.24.0.0

raw patch · 7 files changed

+99/−8 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ DobutokO.Sound.Functional: fVecCoefs :: Int -> Double -> String -> Vector Double
+ DobutokO.Sound.Functional: maybeFFromStrVec :: Int -> Double -> String -> Maybe (Double, Double -> Vector (Double, Double))
+ DobutokO.Sound.Functional: showFFromStrVec :: Int -> Double -> String -> String
+ DobutokO.Sound.IntermediateF: flacToWav :: String -> FilePath -> IO ()

Files

CHANGELOG.md view
@@ -213,3 +213,9 @@ * Twenty-third version. Added 2G generalized functions to the DobutokO.Sound.Functional, and DobutokO.Sound.IntermediateF, and to DobutokO.Sound.Executable modules. They allow to specify sound quality of the resulting files using additional parameter. Added also additional (including 1G) functions to the same modules. Some code and documentation improvements. Added new command line options with "2" at the end.++## 0.24.0.0 -- 2020-04-04++* Twenty-fourth version. Fixed issue with being not compiled because of the unsupported operator (<$>) for GHC 7.8.4. Added possibilities to+work with DobutokO.Sound.Functional module function f more explicitly by three functions 'maybeFFromStrVec', 'fVecCoefs' and 'showFFromStrVec'. Provided+information about examples in the GitHub repository dobutokO2-examples. Some code and documentation improvements. 
DobutokO/Sound/Executable.hs view
@@ -488,7 +488,7 @@ processD3 = onException (do   putStr "Please, specify the octave number, to which you would like all the main components (not taking into account their respective lower pure quints) "   putStrLn "should belong. The number should be better in the range [1..8]"-  d3H <$> getLine) (do+  fmap d3H getLine) (do     putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."     putStrLn "_______________________________________________________________________"     processD3)@@ -503,7 +503,7 @@   putStr "Please, specify the amplitude for the generated overtones as an Int number in the range [0..99]. "   putStrLn "The default one is 99"   putStrLn "To use the default value, you can simply press Enter."-  d4H <$> getLine) (do+  fmap d4H getLine) (do              putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."              putStrLn "_______________________________________________________________________"              processD4)@@ -524,7 +524,7 @@   putStr "Please, specify the basic duration for the generated sounds as a Double number in the range [0.1..4.0]. "   putStrLn "The default one is 0.5"   putStrLn "To use the default value, you can simply press Enter."-  d5H <$> getLine) (do+  fmap d5H getLine) (do              putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."              putStrLn "_______________________________________________________________________"              processD5)@@ -544,7 +544,7 @@ processD7 :: IO String processD7 = onException (do   putStrLn "Please, input the Ukrainian text that will be used to define signs for the harmonics coefficients to produce a special timbre for the notes: "-  d7H <$> getLine) (do+  fmap d7H getLine) (do     putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."     putStrLn "_______________________________________________________________________"     processD7)@@ -561,7 +561,7 @@   putStr "Please, specify in how many times the amplitude for the second lower note (if any) is greater than the amplitude for the main note. "   putStrLn "The number is in the range [0.1..2.0]. The default one is 1.0"   putStrLn "To use the default value, you can simply press Enter."-  d8H <$> getLine) (do+  fmap d8H getLine) (do              putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."              putStrLn "_______________________________________________________________________"              processD8)@@ -583,7 +583,7 @@   putStrLn "Please, input the Ukrainian text that will be used to define intervals to be used to produce the lower note for the given main one. "   putStrLn "The default one is \"й\". "   putStrLn "To use the default value, you can simply press Enter."-  d9H <$> getLine) (do+  fmap d9H getLine) (do     putStrLn "The process was not successful may be because of the not valid data. Please, specify the valid data as requested."     putStrLn "_______________________________________________________________________"     processD9)
DobutokO/Sound/Functional.hs view
@@ -94,8 +94,13 @@   , doubleVecFromVecOfDouble   , helpF1   , helpF0+  -- * Working with 'ObertonesO' and function f+  , maybeFFromStrVec+  , fVecCoefs+  , showFFromStrVec ) where +import Text.Read (readMaybe) import CaseBi (getBFst') import Data.Char (isDigit) import System.Exit (ExitCode( ExitSuccess ))@@ -917,3 +922,62 @@ overTones note =   V.takeWhile (\(!w,!z) -> compare w (V.unsafeIndex notes 107) /= GT && compare (abs z) 0.001 == GT) . V.zip (V.generate 1024 (\i ->     note * fromIntegral (i + 2))) $ (V.generate 1024 (\i -> 1 / fromIntegral ((i + 1) * (i + 1))))++-----------------------------------------------------------------------------------++-- | Gets a function @f::Double -> ObertonesO@ that can be used further. Has two variants with usage of 'closestNote' ('Int' argument is greater than 0)+--  and without it ('Int' argument is less than 0). For both cases 'String' must be in a form list of tuples of pairs of 'Double' to get somewhat+-- reasonable result. The function @f@ can be shown using a special printing function 'showFFromStrVec'. It is a simplest multiplicative (somewhat+-- acoustically and musically reasonable) form for the function that can provide such a result that fits into the given data.+--+-- > let (y,f1) = fromJust (maybeFFromStrVec 1 3583.9783 "[(25.368,0.2486356),(37.259,0.6464867),(486.153,0.374618646),(789.563,0.463486461)]") in (y,f1 3583.9783)+-- >+-- > (3520.0,[(25.829079975681818,0.2486356),(37.936206670369316,0.6464867),(494.9891484317899,0.374618646),(803.9138234326421,0.463486461)])+-- >+-- > let (y,f1) = fromJust (maybeFFromStrVec (-1) 3583.9783 "[(25.368,0.2486356),(37.259,0.6464867),(486.153,0.374618646),(789.563,0.463486461)]") in (y,f1 3583.9783)+-- > +-- > (3583.9783,[(25.368,0.2486356),(37.259,0.6464867),(486.153,0.374618646),(789.563,0.463486461)])+-- +maybeFFromStrVec :: Int -> Double -> String -> Maybe (Double,(Double -> V.Vector (Double,Double)))+maybeFFromStrVec n x ys+  | n == 0 || null ys = Nothing+  | n > 0 = +     let y = closestNote (if x /= 0.0 then abs x else V.unsafeIndex notes 0)+         v = readMaybe ys::Maybe (V.Vector (Double,Double))+         v2 = fromMaybe V.empty v+         v3 = V.map (\(t,w) -> t / y) v2 in+           if V.null v3 then Nothing+           else Just (y,(\t1 -> V.imap (\i (t2,ampl2) -> ((V.unsafeIndex v3 i) * t1,ampl2)) v2))+  | otherwise = +     let y = (if x /= 0.0 then abs x else V.unsafeIndex notes 0)+         v = readMaybe ys::Maybe (V.Vector (Double,Double))+         v2 = fromMaybe V.empty v+         v3 = V.map (\(t,w) -> t / y) v2 in+           if V.null v3 then Nothing+           else Just (y,(\t1 -> V.imap (\i (t2,ampl2) -> ((V.unsafeIndex v3 i) * t1,ampl2)) v2))++-- | Gets multiplication coefficients for @f::Double -> Vector (Double,Double)@ from the 'maybeFFromStrVec' with the same arguments.+fVecCoefs :: Int -> Double -> String -> V.Vector Double+fVecCoefs n x ys =+  let rs = maybeFFromStrVec n x ys in+    case rs of+      Nothing -> V.empty+      _       ->+        let (y,f1) = fromJust $ rs in+          V.map fst (f1 1)++-- | Experimental 'show' for @f::Double -> Vector (Double,Double)@ that is used only for visualisation. It is correct only with 'maybeFFromStrVec' or+-- equivalent function. Because the shape of the @f@ is known the function can be defined.+-- > +-- > showFFromStrVec (-1) 440 "[(25.358,0.3598),(489.35,0.4588962),(795.35,0.6853)]" +-- >+-- > "(440.00,(\t -> <(0.05763181818181818 * t, 0.3598),(1.112159090909091 * t, 0.4588962),(1.8076136363636364 * t, 0.6853)>))"+-- +showFFromStrVec :: Int -> Double -> String -> String+showFFromStrVec n x ys+ | isNothing . maybeFFromStrVec n x $ ys = ""+ | otherwise =+    let (y,f) = fromJust . maybeFFromStrVec n x $ ys+        l = length ("(" ++ (showFFloat Nothing y $ show 0) ++ ",(\t -> <(" ++ concat (V.toList . V.map (\z -> (showFFloat Nothing (fst z) $+              " * t, " ++ (showFFloat Nothing (snd z) $ "),("))) $ (f 1))) in take (l - 2) ("(" ++ (showFFloat Nothing y $ show 0) ++ ",(\t -> <("+                ++ concat (V.toList . V.map (\z -> (showFFloat Nothing (fst z) $ " * t, " ++ (showFFloat Nothing (snd z) $ "),("))) $ (f 1))) ++ ">))"
DobutokO/Sound/IntermediateF.hs view
@@ -94,6 +94,7 @@   , efw2vv   , wOrf   , wavToFlac+  , flacToWav ) where  import CaseBi (getBFst')
DobutokO/Sound/ParseList.hs view
@@ -15,7 +15,7 @@ import Data.Char (isSpace) import qualified Data.Vector as V import Text.Read (lex,readMaybe)-import Data.Maybe (isNothing,fromJust,fromMaybe)+import Data.Maybe (isNothing,fromMaybe)  parseTup :: String -> [String] parseTup xs = map (dropWhile isSpace . fst) (takeWhile (/= ("","")) . iterate (head . lex . snd) $ head (lex xs))
README.markdown view
@@ -152,15 +152,25 @@               two digits are a code for rate and the third one -- a code for bit depth                 ('1' -- for 16 bit and '2' -- for 24 bit). The list of possible first                   two digits and their corresponding frequency rate in Hz:+                      "11" -> 11025+                      "16" -> 16000+                      "17" -> 176400+                      "19" -> 192000+                      "32" -> 32000+                      "44" -> 44100+                      "48" -> 48000+                      "80" -> 8000+                      "96" -> 96000+                      The default one behaviour is equivalent to "221w".    "820" -> the same as "80", but similarly to "82" it gives you the opportunity to@@ -205,9 +215,19 @@ DobutokO.Sound.Executable modules. They allow to specify sound quality of the resulting files using additional parameter. +Since the 0.24.0.0 version the library includes functions to work more explicitly+with f function in the DobutokO.Sound.Functional module. They are based on the+simplest (but still meaningful) multiplicative data fitting.+ ** Note:  * Better to execute in the RAM. Need rather a lot of space on the disk for the resulting file "end.wav" and auxiliary files (MBs) for a short sound in the second command line arguments.++                ***** Examples *****+                --------------------++Starting from the 0.24.0.0 version, you can refer to examples in the GitHub special+repository (https://github.com/OleksandrZhabenko/dobutokO2-examples/)[https://github.com/OleksandrZhabenko/dobutokO2-examples/] 
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO2-version:             0.23.0.0+version:             0.24.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. Uses SoX inside. homepage:            https://hackage.haskell.org/package/dobutokO2