packages feed

dobutokO2 0.28.0.0 → 0.29.0.0

raw patch · 4 files changed

+89/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ DobutokO.Sound.Executable: h2 :: OvertonesO -> (Double, Double) -> Int -> Int -> Double -> IO ()
+ DobutokO.Sound.Executable: soundGen3G_O :: Int -> Int -> Double -> FilePath -> (Double -> OvertonesO) -> Double -> String -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (Int -> OvertonesO) -> (OvertonesO -> (Double, Double)) -> (Double -> OvertonesO) -> IO ()
+ DobutokO.Sound.Executable: soundGen3G_O2 :: ((Double -> OvertonesO, Int -> Double -> OvertonesO, Int -> Double -> OvertonesO) -> Vector (Int, Int) -> Vector (Double, Double -> OvertonesO)) -> Int -> Int -> Double -> FilePath -> (Double -> OvertonesO) -> Double -> String -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (Int -> OvertonesO) -> (OvertonesO -> (Double, Double)) -> (Double -> OvertonesO) -> IO ()

Files

CHANGELOG.md view
@@ -272,3 +272,8 @@ * Twenty-eigth version. Some code in existing modules generalization. Added a new explicit dependency -- bytestring package (earlier it was implicit  dependency for the package dependencies). Added a new module DobutokO.Sound.Keyboard to deal with textual and possibly binary source of variativity.  Some minor documentation improvements.++## 0.29.0.0 -- 2020-04-14++* Twenty-ninth version. Recent code in the DobutokO.Sound.Executable generalization. Added new functions for this. Added info about +the YouTube list with some of the generated sounds as videos. Some minor documentation improvements.
DobutokO/Sound/Executable.hs view
@@ -20,7 +20,10 @@   -- * Library functions   , testSoundGen2G   , soundGen3G+  , soundGen3G_O+  , soundGen3G_O2   , h1+  , h2 ) where  import Control.Monad (void)@@ -35,7 +38,7 @@ import Data.Char (isDigit,isSpace) import System.Process import EndOfExe (showE)-import qualified Data.Vector as V (Vector (..),generate,fromList,length,imapM_,snoc,toList,unsafeSlice,mapM_,imap,unsafeIndex,map,filter)+import qualified Data.Vector as V (Vector (..),generate,fromList,length,imapM_,snoc,toList,unsafeSlice,mapM_,imap,unsafeIndex,map,filter,singleton) import System.Directory import SoXBasics import Processing_mmsyn7ukr@@ -679,6 +682,70 @@         renameFile ("result.wav") $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++ ".wav") vecB   endFromResult +-- | Generates a sequence of sounds with changing timbre. Uses several functions as parameters. Unlike the 'soundGen3G', the last two +-- functions as arguments their first argument have not ('Double','Double'), but 'V.Vector' of them so areapplied to 'OvertonesO'. To +-- provide a generalized functionality it uses two additional functions @freq0 :: Int -> OvertonesO@ and @proj :: OvertonesO -> (Double,Double)@ +-- to define the first element to which are applied @gAdds@ and @gRems@ and the way to obtain a one tuple from the 'V.Vector' of them (possibly, each +-- element of which differs from the result). Besides, it lifts notes into specified with the first two 'Int' arguments enku (see 'liftInEnku'). +-- The 'Double' argument is expected to be not used, though it is specified.+soundGen3G_O :: Int -> Int -> Double -> FilePath -> (Double -> OvertonesO) -> Double -> String -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) +  -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (Int -> OvertonesO) -> (OvertonesO -> (Double,Double)) -> +    (Double -> OvertonesO) -> IO ()+soundGen3G_O m ku freq1 file f y zs gAdds gRems freq0 proj f0 = do+  vecA0 <- fmap (V.map (\t -> quotRem t 108)) (readFileDoubles file) -- >>= print+  let n = V.length vecA0+      fA1 j = fAddFElems (freq0 (j + 1)) (fst . proj . freq0 $ j) f0 gAdds+-- It can be: proj . freq0 $ j = if V.null (freq0 j) then (V.unsafeIndex notes (snd . V.unsafeIndex vecA0 $ j `rem` n),0.5) else V.unsafeIndex (freq0 j) 0+      fR1 j = fRemoveFElems (freq0 (j + 1)) (fst . proj . freq0 $ j) f0 gRems+      vecB = V.imap (\j r -> (V.unsafeIndex notes (snd r),+       case fst r of+         0 -> (\vv -> f0 vv)+         1 -> fA1 j+         2 -> fA1 j+         3 -> fA1 j+         4 -> fA1 j+         _ -> fR1 j)) vecA0+      (t, ws) = splitAt 1 . syllableStr n $ zs+      m0    = length ws+      zeroN = numVZeroesPre vecB+      v2    = V.map (\yy -> y * fromIntegral (yy * m0) / fromIntegral (head t)) . V.fromList $ ws in V.imapM_ (\j (x,k) -> do+        h2 (k x) (x, (V.unsafeIndex v2 (j `rem` (V.length v2)))) m ku freq1+        renameFile ("result.wav") $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++ ".wav") vecB+  endFromResult  ++-- | Generates a sequence of sounds with changing timbre. Is a generalized version of the 'soundGen3G_O', instead of predefined conversion function +-- inside, it uses a user-defined one. +-- +-- > soundGen3G_O = soundGen3G_O2 +-- with the first argument +-- > conversionFII (f0,fA1,fR1) = V.imap (\j r -> (V.unsafeIndex notes (snd r),+-- >      case fst r of+-- >        0 -> (\vv -> f0 vv)+-- >        1 -> fA1 j+-- >        2 -> fA1 j+-- >        3 -> fA1 j+-- >        4 -> fA1 j+-- >        _ -> fR1 j))+-- +soundGen3G_O2 :: ((Double -> OvertonesO,Int -> Double -> OvertonesO,Int -> Double -> OvertonesO) -> V.Vector (Int,Int) -> +  V.Vector (Double,Double -> OvertonesO)) -> Int -> Int -> Double -> FilePath -> (Double -> OvertonesO) -> Double -> String -> +    (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> (OvertonesO -> Double -> (Double -> OvertonesO) -> OvertonesO) -> +      (Int -> OvertonesO) -> (OvertonesO -> (Double,Double)) -> (Double -> OvertonesO) -> IO ()+soundGen3G_O2 conversionFII m ku freq1 file f y zs gAdds gRems freq0 proj f0 = do+  vecA0 <- fmap (V.map (\t -> quotRem t 108)) (readFileDoubles file) -- >>= print+  let n = V.length vecA0+      fA1 j = fAddFElems (freq0 (j + 1)) (fst . proj . freq0 $ j) f0 gAdds+-- It can be: proj . freq0 $ j = if V.null (freq0 j) then (V.unsafeIndex notes (snd . V.unsafeIndex vecA0 $ j `rem` n),0.5) else V.unsafeIndex (freq0 j) 0+      fR1 j = fRemoveFElems (freq0 (j + 1)) (fst . proj . freq0 $ j) f0 gRems+      vecB = conversionFII (f0,fA1,fR1) vecA0+      (t, ws) = splitAt 1 . syllableStr n $ zs+      m0    = length ws+      zeroN = numVZeroesPre vecB+      v2    = V.map (\yy -> y * fromIntegral (yy * m0) / fromIntegral (head t)) . V.fromList $ ws in V.imapM_ (\j (x,k) -> do+        h2 (k x) (x, (V.unsafeIndex v2 (j `rem` (V.length v2)))) m ku freq1+        renameFile ("result.wav") $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++ ".wav") vecB+  endFromResult    + -- | For the given parameters generates a single sound with overtones. h1 :: (Double -> OvertonesO) -> (Double, Double) -> Int -> IO () h1 f (x, y) j = do@@ -688,4 +755,15 @@     (code,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) ["-r22050", "-n", "testA.wav", "synth", ts,"sine",showFFloat Nothing note0 ""] ""     print herr     partialTest_k v0 0 ts+    mixTest++-- | For the given parameters generates a single sound with overtones. Unlike the 'h1' function, it lifts into specified by 'Int' arguments enku +-- (see 'liftInEnku') the frequency.+h2 :: OvertonesO -> (Double, Double) -> Int -> Int -> Double -> IO ()+h2 v (x, y) m ku freq1 = do+    let note0 = fromMaybe freq1 . liftInEnku m ku . closestNote $ (if x /= 0.0 then abs x else V.unsafeIndex notes 0)+        ts = showFFloat (Just 4) (abs y) ""+    (code,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) ["-r22050", "-n", "testA.wav", "synth", ts,"sine",showFFloat Nothing note0 ""] ""+    print herr+    partialTest_k v 0 ts     mixTest
README.markdown view
@@ -242,7 +242,10 @@                 --------------------  Starting from the 0.24.0.0 version, you can refer to examples in the GitHub special-repository (https://github.com/OleksandrZhabenko/dobutokO2-examples/)+repository (https://github.com/OleksandrZhabenko/dobutokO2-examples/). +You can also see some of the generated sounds on the YouTube list:+https://www.youtube.com/playlist?list=PLuG3zSZWV7yollV9nMPcRtm3udVuYVlFS+                  ***** Support for not Sound File Variativity Sources *****                 ----------------------------------------------------------
dobutokO2.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO2-version:             0.28.0.0+version:             0.29.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