dobutokO4 0.1.1.0 → 0.2.0.0
raw patch · 4 files changed
+139/−61 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ DobutokO.Sound.Faded: basicF2CN :: FilePath -> String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> Vector Double -> IO ()
+ DobutokO.Sound.Faded: basicF2N :: FilePath -> String -> String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> Vector Double -> IO ()
+ DobutokO.Sound.Faded: basicFCN :: FilePath -> String -> Double -> Double -> Double -> Double -> (Double -> Double) -> Vector Double -> IO ()
+ DobutokO.Sound.Faded: basicFN :: FilePath -> String -> String -> Double -> Double -> Double -> Double -> (Double -> Double) -> Vector Double -> IO ()
+ DobutokO.Sound.Faded: mixGTestN :: FilePath -> String -> IO ()
+ DobutokO.Sound.Faded: overChangeVolCN :: FilePath -> String -> Char -> Int -> Double -> Double -> Double -> (Double, Double) -> (Double, Double) -> IO ()
+ DobutokO.Sound.Faded: overChangeVolFN :: FilePath -> String -> Char -> Int -> Double -> Double -> (Double, Double) -> (Double, Double) -> Double -> IO ()
+ DobutokO.Sound.Faded: overChangeVolGCN :: FilePath -> String -> String -> Int -> Double -> Double -> Double -> Double -> (Double, Double) -> (Double, Double) -> IO ()
+ DobutokO.Sound.Faded: overChangeVolGFN :: FilePath -> String -> String -> Int -> Double -> Double -> (Double, Double) -> (Double, Double) -> Double -> Double -> IO ()
+ DobutokO.Sound.Faded: overChangeVolGN :: FilePath -> String -> String -> Int -> Double -> Double -> Double -> Double -> ((Double, Double), (Double, Double)) -> IO ()
+ DobutokO.Sound.Faded: overChangeVolN :: FilePath -> String -> Char -> Int -> Double -> Double -> Double -> ((Double, Double), (Double, Double)) -> IO ()
Files
- ChangeLog.md +4/−0
- DobutokO/Sound/Faded.hs +125/−53
- DobutokO/Sound/Presentation.hs +9/−7
- dobutokO4.cabal +1/−1
ChangeLog.md view
@@ -8,3 +8,7 @@ * First version revised A. Fixed issue with being not compiled for GHC <= 8.4.*. +## 0.2.0.0 -- 2020-06-09++* Second version. Added a README.markdown file. Added new functions to the DobutokO.Sound.Faded module with 'N' ending to generalize the name(s) of the resulting +file(s). Some minor code improvements.
DobutokO/Sound/Faded.hs view
@@ -6,26 +6,37 @@ -- Maintainer : olexandr543@yahoo.com -- -- Helps to create experimental music. --- Uses SoX fade (in a special 2D way) and frequency modulation.+-- Uses SoX fade (in a special 2D way) effect and frequency modulation. {-# OPTIONS_GHC -threaded #-} {-# LANGUAGE CPP #-} module DobutokO.Sound.Faded (- -- * Create special faded effects- overChangeVolG+ -- * Provide special faded effects and frequency modulation+ overChangeVolGN+ , overChangeVolG , overChangeVolGC , overChangeVolGF , overChangeVol , overChangeVolC , overChangeVolF+ , overChangeVolGCN+ , overChangeVolGFN+ , overChangeVolN+ , overChangeVolCN+ , overChangeVolFN -- * Mixing function , mixGTest+ , mixGTestN -- * Generate several files+ , basicFN , basicF , basicFC , basicF2 , basicF2C+ , basicFCN+ , basicF2N+ , basicF2CN -- * Auxiliary functions , endingWF , charFadeType@@ -59,11 +70,15 @@ #endif #endif --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale with possibily changing frequency (they are specified by --- the first and the second 'Double' arguments). Uses SoX inside especially \"fade\" and \"synth\" effects. For the equal frequencies generates specifically --- faded output. +-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points at the time-volume scale with possibly +-- changing frequency (they are specified by the first and the second 'Double' arguments). Uses SoX inside especially the \"fade\" and \"synth\" effects. +-- For the equal frequencies generates specifically faded output without frequency modulation. overChangeVolG :: String -> String -> Int -> Double -> Double -> Double -> Double -> ((Double,Double), (Double,Double)) -> IO ()-overChangeVolG ys cs j freq1 freq2 x0 xdelta ((t0,v0), (t1,v1)) +overChangeVolG = overChangeVolGN "test"+ +-- | A generalized version of the 'overChangeVolGN' with a possibility to specify the name of the resulting file (by default it is \"test\" based).+overChangeVolGN :: FilePath -> String -> String -> Int -> Double -> Double -> Double -> Double -> ((Double,Double), (Double,Double)) -> IO ()+overChangeVolGN filestart ys cs j freq1 freq2 x0 xdelta ((t0,v0), (t1,v1)) | x0 /= 0 && compare (abs x0) 1.0 /= GT && compare freq1 16 == GT && compare freq1 20000 == LT = case compare (v1 * v0) 0 of GT -> do@@ -73,58 +88,58 @@ if compare ((v1 - v0) * (t1 - t0)) 0 /= LT then [showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) ""] else ["0", "-0.0", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "vol", showFFloat (Just 4) (signum v1 * abs (v1 - v0)) ""]) ""- if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr1+ if code1 /= ExitSuccess then error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr1 else do (code2,_,herr2) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n","test0.wav","synth", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "sine", showFFloat (Just 4) freq1 (freqChange (drop 1 cs) freq2 freq1), "vol", showFFloat (Just 4) (min v0 v1) ""]) "" if code2 == ExitSuccess then do- (code3,_,herr3) <- readProcessWithExitCode (fromJust (showE "sox")) ["-m","test0" ++ endingWF ys,"test1" ++ endingWF ys, "testG" ++ + (code3,_,herr3) <- readProcessWithExitCode (fromJust (showE "sox")) ["-m","test0" ++ endingWF ys,"test1" ++ endingWF ys, (filestart ++ "G") ++ prependZeroes 6 (show j) ++ endingWF ys, "vol", "2"] "" if code3 == ExitSuccess then removeFile ("test0" ++ endingWF ys) >> removeFile ("test1" ++ endingWF ys)- else error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr3- else print herr2 >> error "DobutokO.Sound.Times.overChangeVol: Operation not successful. "+ else error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr3+ else print herr2 >> error "DobutokO.Sound.Faded.overChangeVolGN: Operation not successful. " LT -> do - overChangeVolG ys cs j freq1 freq2 x0 xdelta ((t0,v0), ((v0 * t1 - v1 * t0) / (v0 - v1),0)) >> renameFile ("testG" ++ prependZeroes 6 (show j) ++ - endingWF ys) ("temp0" ++ endingWF ys)- overChangeVolG ys cs j freq1 freq2 x0 xdelta (((v0 * t1 - v1 * t0) / (v0 - v1),0), (t1,v1)) >> renameFile ("testG" ++ prependZeroes 6 (show j) ++ - endingWF ys) ("temp1" ++ endingWF ys)- (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) ["temp0" ++ endingWF ys,"temp1" ++ endingWF ys, "testG" ++ + overChangeVolGN filestart ys cs j freq1 freq2 x0 xdelta ((t0,v0), ((v0 * t1 - v1 * t0) / (v0 - v1),0)) >> renameFile ((filestart ++ "G") ++ + prependZeroes 6 (show j) ++ endingWF ys) ("temp0" ++ endingWF ys)+ overChangeVolGN filestart ys cs j freq1 freq2 x0 xdelta (((v0 * t1 - v1 * t0) / (v0 - v1),0), (t1,v1)) >> renameFile ((filestart ++ "G") ++ + prependZeroes 6 (show j) ++ endingWF ys) ("temp1" ++ endingWF ys)+ (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) ["temp0" ++ endingWF ys,"temp1" ++ endingWF ys, (filestart ++ "G") ++ prependZeroes 6 (show j) ++ endingWF ys] "" if code1 == ExitSuccess then removeFile ("temp0" ++ endingWF ys) >> removeFile ("temp1" ++ endingWF ys)- else error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr1 + else error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr1 _ -> case v1 of 0 -> if v0 == 0 then do- (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n","testG" ++ prependZeroes 6 (show j) ++ + (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n",(filestart ++ "G") ++ prependZeroes 6 (show j) ++ ".wav","delay", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "trim", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) ""]) ""- if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr1+ if code1 /= ExitSuccess then error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr1 else return () else do - (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n","testG" ++ prependZeroes 6 (show j) ++ + (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n",(filestart ++ "G") ++ prependZeroes 6 (show j) ++ ".wav","synth", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "sine", showFFloat (Just 4) freq1 (freqChange (drop 1 cs) freq2 freq1), "fade", charFadeType (if null cs then 'l' else head cs)] ++ if compare t0 t1 == GT then [showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) ""] else ["0", "-0.0", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "vol", showFFloat (Just 4) v0 ""]) ""- if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr1+ if code1 /= ExitSuccess then error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr1 else return () _ -> do- (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n","testG" ++ prependZeroes 6 (show j) ++ ".wav",+ (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (soxBasicParams ys ["","-n",(filestart ++ "G") ++ prependZeroes 6 (show j) ++ ".wav", "synth", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "sine", showFFloat (Just 4) freq1 (freqChange (drop 1 cs) freq2 freq1), "fade", charFadeType (if null cs then 'l' else head cs)] ++ if compare t1 t0 == GT then [showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) ""] else ["0", "-0.0", showFFloat Nothing (if compare (abs (t1 - t0)) xdelta /= GT then abs x0 else abs (t1 - t0)) "", "vol", showFFloat (Just 4) v1 ""]) ""- if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.overChangeVol: " ++ herr1+ if code1 /= ExitSuccess then error $ "DobutokO.Sound.Faded.overChangeVolGN: " ++ herr1 else return ()- | otherwise = error "DobutokO.Sound.Times.overChangeVol: sound for these conditions is not defined. "+ | otherwise = error "DobutokO.Sound.Faded.overChangeVolGN: sound for these conditions is not defined. " freqChange :: String -> Double -> Double -> String freqChange xs freq freq1 @@ -137,41 +152,63 @@ else "" | otherwise = error "DobutokO.Sound.Faded.freqChange: undefined for this value of the frequency (the first Double argument). " --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale. Uses SoX inside especially \"fade\" --- and \"synth\" effects. A frequency does not change and is specified (in Hz) by the first 'Double' argument.+-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points at the time-volume scale. Uses SoX inside +-- especially the \"fade\" and \"synth\" effects. A frequency does not change and is specified (in Hz) by the first 'Double' argument. overChangeVol :: String -> Char -> Int -> Double -> Double -> Double -> ((Double,Double), (Double,Double)) -> IO () -overChangeVol ys c j freq1 = overChangeVolG ys [c] j freq1 freq1+overChangeVol ys c j freq1 = overChangeVolGN "test" ys [c] j freq1 freq1 --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale. Uses SoX inside especially \"fade\" --- and \"synth\" effects. A frequency does not change and is specified (in Hz) by the first 'Double' argument. Is a curried variant of the +-- | A generalized version of the 'overChangeVol' with a possibility to specify the name for the mixed files (by default is \"test\" based).+overChangeVolN :: FilePath -> String -> Char -> Int -> Double -> Double -> Double -> ((Double,Double), (Double,Double)) -> IO () +overChangeVolN filestart ys c j freq1 = overChangeVolGN filestart ys [c] j freq1 freq1++-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points in the time-volume scale. Uses SoX inside especially +-- the \"fade\" and \"synth\" effects. A frequency does not change and is specified (in Hz) by the first 'Double' argument. Is a curried variant of the -- 'overChangeVol' in its two last arguments. overChangeVolC :: String -> Char -> Int -> Double -> Double -> Double -> (Double,Double) -> (Double,Double) -> IO () overChangeVolC ys c j freq x0 xdelta w1 = overChangeVol ys c j freq x0 xdelta . (,) w1 --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale with possibily changing frequency (they are specified by --- the first and the second 'Double' arguments). Uses SoX inside especially \"fade\" and \"synth\" effects. For the equal frequencies generates specifically --- faded output. Is a curried variant of the 'overChangeVolG' in its two last arguments.+-- | A generalized version of the 'overChangeVolC' with a possibility to specify the name for the mixed files (by default is \"test\" based).+overChangeVolCN :: FilePath -> String -> Char -> Int -> Double -> Double -> Double -> (Double,Double) -> (Double,Double) -> IO ()+overChangeVolCN filestart ys c j freq x0 xdelta w1 = overChangeVolN filestart ys c j freq x0 xdelta . (,) w1++-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points in the time-volume scale with possibly changing frequency (they are specified by +-- the first and the second 'Double' arguments). Uses SoX inside especially the \"fade\" and \"synth\" effects. For the equal frequencies generates specifically +-- faded output without frequency modulation. Is a curried variant of the 'overChangeVolG' in its two last arguments. overChangeVolGC :: String -> String -> Int -> Double -> Double -> Double -> Double -> (Double,Double) -> (Double,Double) -> IO () overChangeVolGC ys cs j freq1 freq2 x0 xdelta w1 = overChangeVolG ys cs j freq1 freq2 x0 xdelta . (,) w1 --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale. Uses SoX inside especially \"fade\" --- and \"synth\" effects. Is a somewhat flipped variant of the 'overChangeVol' with changed order of the arguments (is provided here for convenience).+-- | A generalized version of the 'overChangeVolGC' with a possibility to specify the name for the mixed files (by default is \"test\" based).+overChangeVolGCN :: FilePath -> String -> String -> Int -> Double -> Double -> Double -> Double -> (Double,Double) -> (Double,Double) -> IO ()+overChangeVolGCN filestart ys cs j freq1 freq2 x0 xdelta w1 = overChangeVolGN filestart ys cs j freq1 freq2 x0 xdelta . (,) w1++-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points in the time-volume scale. Uses SoX inside especially +-- the \"fade\" and \"synth\" effects. Is a somewhat flipped variant of the 'overChangeVol' with changed order of the arguments (is provided here +-- for convenience). overChangeVolF :: String -> Char -> Int -> Double -> Double -> (Double,Double) -> (Double,Double) -> Double -> IO () overChangeVolF ys c j x0 xdelta w1 w2 freq = overChangeVol ys c j freq x0 xdelta (w1,w2) --- | Generates sound the volume of which comes through the given 2D points in the time-volume scale with possibily changing frequency (they are specified by --- the first and the second 'Double' arguments). Uses SoX inside especially \"fade\" and \"synth\" effects. For the equal frequencies generates specifically --- faded output. Is a somewhat flipped variant of the 'overChangeVolG' with changed order of the arguments (is provided here for convenience).+-- | A generalized version of the 'overChangeVolF' with a possibility to specify the name for the mixed files (by default is \"test\" based).+overChangeVolFN :: FilePath -> String -> Char -> Int -> Double -> Double -> (Double,Double) -> (Double,Double) -> Double -> IO ()+overChangeVolFN filestart ys c j x0 xdelta w1 w2 freq = overChangeVolN filestart ys c j freq x0 xdelta (w1,w2)++-- | Generates a sound, the volume of which (being plotted graphically) comes through the given 2D points in the time-volume scale with possibly +-- changing frequency (they are specified by the first and the second 'Double' arguments). Uses SoX inside especially the \"fade\" and \"synth\" effects. +-- For the equal frequencies generates specifically faded output without frequency modulation. Is a somewhat flipped variant of the 'overChangeVolGC' +-- with changed order of the arguments (is provided here for convenience). overChangeVolGF :: String -> String -> Int -> Double -> Double -> (Double,Double) -> (Double,Double) -> Double -> Double -> IO () overChangeVolGF ys cs j x0 xdelta w1 w2 freq1 freq2 = overChangeVolG ys cs j freq1 freq2 x0 xdelta (w1,w2) --- | A simplified variant of the 'soxBasicParameters' function with defining only file extension.+-- | A generalized version of the 'overChangeVolGF' with a possibility to specify the name for the mixed files (by default is \"test\" based).+overChangeVolGFN :: FilePath -> String -> String -> Int -> Double -> Double -> (Double,Double) -> (Double,Double) -> Double -> Double -> IO ()+overChangeVolGFN filestart ys cs j x0 xdelta w1 w2 freq1 freq2 = overChangeVolGN filestart ys cs j freq1 freq2 x0 xdelta (w1,w2)++-- | A simplified variant of the 'soxBasicParameters' function with defining only a file extension. endingWF :: String -> String endingWF ys | not (null ys) = if last ys == 'f' then ".flac" else ".wav" | otherwise = ".wav" --- | Converts a character into a corresponding string using as a default one \"l\" (a logarithmic one). An output can specify then the fade type for SoX.+-- | Converts a character into a corresponding string using \"l\" (a logarithmic one) as the default one. An output can specify then the fade type for SoX. charFadeType :: Char -> String charFadeType c = case c of@@ -190,6 +227,15 @@ endingWF ys `isSuffixOf` xs) dir, ["resultG" ++ endingWF ys]]) "" if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.mixGTest: " ++ herr1 else mapM_ removeFile . filter (\xs -> "testG" `isPrefixOf` xs && endingWF ys `isSuffixOf` xs) $ dir++-- | A generalized version of the 'mixGTest' with a possibility to specify the name for the mixed files (by default is \"test\" based).+mixGTestN :: FilePath -> String -> IO ()+mixGTestN filestart ys = do+ dir <- listDirectory "."+ (code1,_,herr1) <- readProcessWithExitCode (fromJust (showE "sox")) (mconcat [["-m"], filter (\xs -> (filestart ++ "G") `isPrefixOf` xs && + endingWF ys `isSuffixOf` xs) dir, ["resultG" ++ endingWF ys]]) ""+ if code1 /= ExitSuccess then error $ "DobutokO.Sound.Times.mixGTestN: " ++ herr1+ else mapM_ removeFile . filter (\xs -> (filestart ++ "G") `isPrefixOf` xs && endingWF ys `isSuffixOf` xs) $ dir -- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic is going through the 2D points obtained -- with the last two arguments.@@ -204,33 +250,59 @@ overChangeVol ys c1 i freq x0 xdelta x fadeEndsTMB c2 per $ "testG" ++ prependZeroes 6 (show i) ++ endingWF ys) v1 --- | Splits its argument (like 'splitAt') into two 'String' with the length of (if possible) 4 and 2 characters. The rest of the argument is not used.+-- | A generalized version of the 'basicF' with a possibility to specify the name for the generated files (by default is \"test\" based).+basicFN :: FilePath -> String -> String -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()+basicFN filestart ys x2s freq x0 xdelta per f v = do+ let (xs1,xs2) = splitAt 1 x2s+ c1 = if null xs1 then 'l' else head xs1+ c2 = if null xs2 then 'l' else head xs2+ v1 <- evalSndFV f v+ V.imapM_ (\i x -> do+ overChangeVolGN filestart ys [c1] i freq freq x0 xdelta x+ fadeEndsTMB c2 per $ (filestart ++ "G") ++ prependZeroes 6 (show i) ++ endingWF ys) v1++-- | Splits its argument (the first six symbols if present) (like 'splitAt') into two 'String' with the length of (if possible) 4 and 2 characters. +-- The rest of the argument is not used. argString :: String -> (String,String) argString xs = (take 4 xs,take 2 . drop 4 $ xs) --- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic is going through the 2D points obtained --- with the last two arguments.--- The 'String' should consist of 6 alphanumeric characters. The first four as for the 'soxBasicParams' and the last two -- letters from the \"hlpqt\". +-- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic (if being plotted graphically) is going through +-- the 2D points obtained with the last two arguments.+-- The 'String' should consist of 6 alphanumeric characters. The first four as for the 'soxBasicParams', and the fifth one -- a letter from the \"hlpqt\". The +-- sixth one is one of the \"els\" or some other symbol. -- Otherwise, the default values are used (\"221w\" for the first and \"ll\" for the second one). basicFC :: String -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()-basicFC xs freq x0 xdelta per f v = let (ys,x2s) = argString xs in basicF ys x2s freq x0 xdelta per f v+basicFC = basicFCN "test" --- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic is going through the 2D points obtained +-- | A generalized version of the 'basicFC' with a possibility to specify the name for the mixed files (by default is \"test\" based).+basicFCN :: FilePath -> String -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()+basicFCN filestart xs freq x0 xdelta per f v = let (ys,x2s) = argString xs in basicFN filestart ys x2s freq x0 xdelta per f v++-- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic (if being plotted graphically) is going through the 2D points obtained -- with the last two arguments. -- Uses 'fadeEndsTMN', the arguments for which are specified by the second symbol in the second 'String' and by the third and fourth 'Double' arguments. basicF2 :: String -> String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()-basicF2 ys x2s freq x0 xdelta per1 per2 f v = do+basicF2 = basicF2N "test"++-- | A generalized version of the 'basicF2' with a possibility to specify the name for the mixed files (by default is \"test\" based).+basicF2N :: FilePath -> String -> String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()+basicF2N filestart ys x2s freq x0 xdelta per1 per2 f v = do let (xs1,xs2) = splitAt 1 x2s c1 = if null xs1 then 'l' else head xs1 c2 = if null xs2 then 'l' else head xs2 v1 <- evalSndFV f v V.imapM_ (\i x -> do- overChangeVol ys c1 i freq x0 xdelta x- fadeEndsTMN c2 per1 per2 $ "testG" ++ prependZeroes 6 (show i) ++ endingWF ys) v1+ overChangeVolN filestart ys c1 i freq x0 xdelta x+ fadeEndsTMN c2 per1 per2 $ (filestart ++ "G") ++ prependZeroes 6 (show i) ++ endingWF ys) v1 --- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic is going through the 2D points obtained --- with the last two arguments.--- The 'String' should consist of 6 alphanumeric characters. The first four as for the 'soxBasicParams' and the last two -- letters from the \"hlpqt\". --- Otherwise, the default values are used (\"221w\" for the first and \"ll\" for the second one).+-- | Generates a sequence of sounds using 'overChangeVol' so that their time-volume characteristic (if being plotted graphically) is going through +-- the 2D points obtained with the last two arguments.+-- The 'String' should consist of 6 alphanumeric characters. The first four as for the 'soxBasicParams' and the the fifth one -- a letter +-- from the \"hlpqt\". The sixth one is one of the \"els\" or some other symbol. Otherwise, the default values are used (\"221w\" for the first +-- and \"ll\" for the second one). basicF2C :: String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()-basicF2C xs freq x0 xdelta per1 per2 f v = let (ys,x2s) = argString xs in basicF2 ys x2s freq x0 xdelta per1 per2 f v+basicF2C = basicF2CN "test"++-- | A generalized version of the 'basicF2C' with a possibility to specify the name for the mixed files (by default is \"test\" based).+basicF2CN :: FilePath -> String -> Double -> Double -> Double -> Double -> Double -> (Double -> Double) -> V.Vector Double -> IO ()+basicF2CN filestart xs freq x0 xdelta per1 per2 f v = let (ys,x2s) = argString xs in basicF2N filestart ys x2s freq x0 xdelta per1 per2 f v
DobutokO/Sound/Presentation.hs view
@@ -6,7 +6,7 @@ -- Maintainer : olexandr543@yahoo.com -- -- Helps to create experimental music. --- These module contains different representations for the data.+-- This module contains different representations for the data. {-# OPTIONS_GHC -threaded #-} {-# LANGUAGE CPP #-}@@ -56,7 +56,7 @@ -- | The first 'Double' parameter is a time moment (starting from 0) of the playing the sound being represented by 'OvertonesO', the second one is its -- duration. The third one is its maximum amplitude by an absolute value. The fourth one is the minimum duration that can provide a needed human --- feeling of perception (some impression) for the sound. The further one(s) is(are) some adjustment(s) parameter.+-- feeling of perception (some impression) for the sound. The further one(s) is(are) some adjustment(s) parameter(s). data SoundT = StO Double Double Double Double OvertonesO | SAtO Double Double Double Double Double OvertonesO | SAbtO Double Double Double Double Double OvertonesO deriving Eq @@ -101,7 +101,7 @@ #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=804 /* code that applies only to GHC 8.4.* and higher versions */--- | Idempotent semigroup (band) (x <> x = x) if @Semigroup a@ is idempotent (is a band).+-- | Since base-4.9.0.0. Idempotent semigroup (band) (x <> x == x) if @Semigroup a@ is idempotent (is a band). instance (Semigroup a) => Semigroup (Timity1 a) where (<>) (Time1 t01 t11 a0) (Time1 t02 t12 a1) = Time1 (min t01 t02) ((signum (t11 * t12)) * (max (t01 + (abs t11)) (t02 + (abs t12)) - min t01 t02)) (a0 <> a1)@@ -129,13 +129,14 @@ #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=804 /* code that applies only to GHC 8.4.* and higher versions */--- | Idempotent semigroup (x <> x = x) -- band. +-- | Since base-4.9.0.0. Idempotent semigroup (x <> x == x) -- band. instance Semigroup IntervalTim where (<>) (I x01 x02) (I x11 x12) = I (minimum [x01,x02,x11,x12]) (maximum [x01,x02,x11,x12]) #endif #endif --- | Another 'Double' interval representation with no order of the arguments preserved. Has different instance of 'Semigroup' than 'IntervalTim'.+-- | Another 'Double' interval representation with no order of the arguments preserved. Since base-4.9.0.0 has different instance of 'Semigroup' +-- than 'IntervalTim'. data IntervalTimI = II Double Double instance Eq IntervalTimI where@@ -156,7 +157,7 @@ #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=804 /* code that applies only to GHC 8.4.* and higher versions */--- | Idempotent semigroup (x <> x = x) -- band. +-- | Since base-4.9.0.0. Idempotent semigroup (x <> x == x) -- band. instance Semigroup IntervalTimI where (<>) (II x01 x02) (II x11 x12) = II (max (min x01 x02) (min x11 x12)) (min (max x01 x02) (max x11 x12)) #endif@@ -187,7 +188,7 @@ #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=804 /* code that applies only to GHC 8.4.* and higher versions */--- | Idempotent semigroup (x <> x = x) and rectangular band (x <> y <> z = x <> z)+-- | Since base-4.9.0.0. Idempotent semigroup (x <> x == x) and rectangular band (x <> y <> z == x <> z) -- For more information, please, refer to: https://en.wikipedia.org/wiki/Band_(mathematics) instance Semigroup (IntervalG a b) where (<>) (IG x0 _) (IG _ w1) = IG x0 w1@@ -200,6 +201,7 @@ #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__>=710 /* code that applies only to GHC 7.10.* and higher versions */+-- | Since base-4.8.0.0. instance Bifunctor IntervalG where bimap f g (IG x y) = IG (f x) (g y) #endif
dobutokO4.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dobutokO4-version: 0.1.1.0+version: 0.2.0.0 synopsis: Helps to create experimental music. Uses SoX inside. description: Uses SoX fade (in a special 2D way) and frequency modulation. Provides a special representation for the composition. homepage: https://hackage.haskell.org/package/dobutokO4