packages feed

algorithmic-composition-basic 0.3.0.0 → 0.3.1.0

raw patch · 4 files changed

+50/−11 lines, 4 filesdep ~process-sequentialPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: process-sequential

API changes (from Hackage documentation)

+ Composition.Sound.Functional.Params: overMeloPar2G :: String -> (Float -> OvertonesO) -> (Float -> Float) -> Params -> Float -> Float -> Float -> IO ()

Files

CHANGELOG.md view
@@ -30,3 +30,9 @@ * Third version. Fixed some issues with functions in the Composition.Sound.IntermediateF module. Added a new function to it and some other new functions to the Composition.Sound.Functional.Basics module. Added process-sequential as a new lightweight  dependency.++## 0.3.1.0 -- 2021-03-09++* Third version revised A. Added new function overMeloPar2G to the Composition.Sound.Functional.Params module. Changed the +dependency boundaries for process-sequential.+
Composition/Sound/Functional/Basics.hs view
@@ -415,7 +415,6 @@   mapM_ (\(j, vel) -> overSoXSynthHelpG j vel) . zip [0..] $ vs   mixTest     - -- | Generalized variant of the 'overSoXSynth3G' with the possibility to set the sound rate. overSoXSynth4G :: [(Float -> Float)] -> (Float -> OvertonesO) -> String -> Float -> Float -> IO () overSoXSynth4G progressionHarmonizerList g ys duration x = do
Composition/Sound/Functional/Params.hs view
@@ -1,13 +1,12 @@ -- | -- Module      :  Composition.Sound.Functional.Params--- Copyright   :  (c) OleksandrZhabenko 2020+-- Copyright   :  (c) OleksandrZhabenko 2020-2021 -- License     :  MIT -- Stability   :  Experimental -- Maintainer  :  olexandr543@yahoo.com -- -- Helps to create experimental music from a file (or its part) and a Ukrainian text. --- It can also generate a timbre for the notes. Uses SoX inside. Is more complicated than--- dobutokO2 and uses its functionality.+-- It can also generate a timbre for the notes. Uses SoX inside.   {-# LANGUAGE BangPatterns, LambdaCase #-} {-# OPTIONS_GHC -threaded #-}@@ -39,6 +38,7 @@   , overSoXSynthGen2FDN_Sf3G2GPar     -- * Creating melody from overtones   , overMeloPar+  , overMeloPar2G   -- * Additional functions   , str2DurationsDef   , signsFromString@@ -152,7 +152,7 @@         h f (x, (unsafeAt v2 (j `rem` l2))) j wws ys         renameFile ("result." ++ if drop 3 ys == "f" then "flac" else "wav") $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++           if drop 3 ys == "f" then ".flac" else ".wav") . zip [0..] $ vecB-  endFromResult2G ys    +  endFromResult2G ys  -- | Generalized version of the 'overSoXSynthGen2FDN_Sf3G' where instead of lifting with 'liftInEnkuV' 'liftInParamsV' is used. It allows e. g. to  -- use some tonality. For more information, please, refer to 'filterInParams'.@@ -167,7 +167,7 @@       !l2 = numElements v2 in mapM_ (\(j, x) -> do         h f (x, (unsafeAt v2 (j `rem` l2)), t0) j wws         renameFile "result.wav" $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++ ".wav") . zip [0..] $ vecB-  endFromResult  +  endFromResult  -- | Generalized version of the 'overSoXSynthGen2FDN_Sf3G2G' where instead of lifting with 'liftInEnkuV' 'liftInParamsV' is used. It allows e. g. to  -- use some tonality. For more information, please, refer to 'filterInParams'.@@ -183,7 +183,7 @@         h f (x, (unsafeAt v2 (j `rem` l2)), t0) j wws ys         renameFile ("result." ++ if drop 3 ys == "f" then "flac" else "wav") $ "result0" ++ prependZeroes zeroN (show (j + 1)) ++ if drop 3 ys == "f"           then ".flac" else ".wav") . zip [0..] $ vecB-  endFromResult2G ys    +  endFromResult2G ys  -- | A way to get from a 'Params' a corresponding 'Array' 'Int' of 'Float' (if any) and so to work with them further. May contain some issues  -- so please, before production usage check thoroughly. @@ -425,6 +425,40 @@         | otherwise = putStrLn "Zero length of the sound! "    mapM_ (\(j, zz) -> h42 j zz) . zip [0..] . zip4 v v2 vD $ vS +{-| A variant of the 'overMeloPar2G' with the first argument controlling the sound quality parameters. For more information,+please, refer to 'soxBasicParams' documentation. -}+overMeloPar2G :: String -> (Float -> OvertonesO) -> (Float -> Float) -> Params -> Float -> Float -> Float -> IO ()+overMeloPar2G ys f g params coeff freq0 freq = do +  let v = f freq+      vFreqs = map ((\z -> if z == 11440.0 then freq0 else z) . flip liftInParams params . fst) v+      vD = map (g . (* coeff) . snd) v+      v2 = map f vFreqs+      vS = map (\z -> showFFloat (Just 4) (abs z) "") vD+      !l3 = length v2+      h42 j (x,v3,y,ts) +        | y > 0.0 = do +           (_,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) ((if null ys then id else soxBasicParams ys) ["-r22050", "-n", "testA.wav", "synth", ts,"sine",showFFloat Nothing (fst x) ""]) ""+           print herr+           partialTest_k2G v3 0 ts ((\rs -> listArray (0, l3 - 1) rs) . replicate l3 $ 0.0) ys+           mixTest2G ys+           wavF <- doesFileExist "result.wav"+           if wavF then renameFile "result.wav" $ "result" ++ prependZeroes (numVZeroesPre v) (show j) ++ ".wav"+           else do+            flacF <- doesFileExist "result.flac"+            if flacF then renameFile "result.flac" $ "result" ++ prependZeroes (numVZeroesPre v) (show j) ++ ".flac"+            else putStrLn "Composition.Sound.Functional.Params.overMeloPar2G: No \"result*\" file is present in the directory. "+        | y < 0.0 = do +           (_,_,herr) <- readProcessWithExitCode (fromJust (showE "sox")) ((if null ys then id else soxBasicParams ys) ["-r22050", "-n", "result.wav", "synth", ts,"sine",showFFloat Nothing (fst x) "","vol","0"]) "" +           putStr herr+           wavF <- doesFileExist "result.wav"+           if wavF then renameFile "result.wav" $ "result" ++ prependZeroes (numVZeroesPre v) (show j) ++ ".wav"+           else do+            flacF <- doesFileExist "result.flac"+            if flacF then renameFile "result.flac" $ "result" ++ prependZeroes (numVZeroesPre v) (show j) ++ ".flac"+            else putStrLn "Composition.Sound.Functional.Params.overMeloPar2G: No \"result*\" file is present in the directory. "+        | otherwise = putStrLn "Zero length of the sound! " +  mapM_ (\(j, zz) -> h42 j zz) . zip [0..] . zip4 v v2 vD $ vS+ -- | A default way to get 'Durations' for the sounds up to 0.35.2.0 version of the package including. It is based on the number of Ukrainian  -- sounds representations (see, 'convertToProperUkrainianS') in a Ukrainian syllables or somewhat generated by the same rules as they.  -- The rhythm using the function is very often not binary but its ratios are almost always a ratios of the small natural numbers (1, 2, 3, 4, 5, 6, 7 etc.).@@ -504,7 +538,7 @@       ts = showFFloat (Just 4) (abs y) "" -- duration of the sound to be generated   mapM_ (\(i, w, u, vv) -> do     _ <- readProcessWithExitCode (fromJust (showE "sox")) ((if null ys then id else soxBasicParams ys) (((\wwws -> adjust_dbVol wwws vv)) ["-r22050", "-n", "test" ++ helpF0 i ++ ".wav", "synth",ts,-         "sine", showFFloat Nothing w "","vol", if compare y 0.0 == GT then "1.0" else "0"])) ""+         "sine", showFFloat Nothing w "","vol", if y > 0.0 then "1.0" else "0"])) ""     partialTest_k2G u i ts vdB ys) . zip4 [0..] vDz vNotes . elems $ vdB  helpF0 :: Int -> String@@ -522,4 +556,4 @@ -- | Generates a list of 'OvertonesO' that represents the melodic line.  doubleVecFromVecOfFloat :: (Float -> OvertonesO) -> Float -> [Maybe Float] -> [OvertonesO] doubleVecFromVecOfFloat f t0 =-  map (\note1 -> if isNothing note1 then [] else filter (\(_,!z) -> compare (abs z) t0 == GT) . f . fromJust $ note1)+  map (\note1 -> if isNothing note1 then [] else filter (\(_,!z) -> abs z > t0) . f . fromJust $ note1)
algorithmic-composition-basic.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                algorithmic-composition-basic-version:             0.3.0.0+version:             0.3.1.0 synopsis:            Helps to create experimental music from a file (or its part) and a Ukrainian text. description:         It can also generate a timbre for the notes. Uses SoX inside. homepage:            https://hackage.haskell.org/package/algorithmic-composition-basic@@ -20,6 +20,6 @@   exposed-modules:     Composition.Sound.IntermediateF, Composition.Sound.Keyboard, Composition.Sound.Functional.Basics, Composition.Sound.Functional.Params, Composition.Sound.Functional.Elements   -- other-modules:   other-extensions:    BangPatterns-  build-depends:       base >=4.8 && <4.15, bytestring >= 0.10.6 && <1, process >=1.4 && <1.9, mmsyn3 >=0.1.5 && <1,  directory >=1.2.7 && <1.7, mmsyn7ukr-common >=0.1.1 && <1, mmsyn2-array >=0.1.1 && <1, ukrainian-phonetics-basic-array >=0.1.2 && <1, mmsyn7l >=0.9 && <1, phonetic-languages-simplified-base >=0.2 && <1, foldable-ix >=0.2 && <1, process-sequential >=0.1 && <1+  build-depends:       base >=4.8 && <4.15, bytestring >= 0.10.6 && <1, process >=1.4 && <1.9, mmsyn3 >=0.1.5 && <1,  directory >=1.2.7 && <1.7, mmsyn7ukr-common >=0.1.1 && <1, mmsyn2-array >=0.1.1 && <1, ukrainian-phonetics-basic-array >=0.1.2 && <1, mmsyn7l >=0.9 && <1, phonetic-languages-simplified-base >=0.2 && <1, foldable-ix >=0.2 && <1, process-sequential >=0.1.1 && <1   -- hs-source-dirs:   default-language:    Haskell2010