Copyright | (c) OleksandrZhabenko 2020 2024 |
---|---|
License | MIT |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
DobutokO.Sound.IntermediateF
Description
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.
Synopsis
- getFileRSizes :: IO (Vector Integer)
- getFileRSizesS :: IO (Vector Int)
- getFileRSizesS2 :: IO (Vector Int)
- getFileRTuples :: IO (Vector (FilePath, Integer))
- listVDirectory :: IO (Vector FilePath)
- isHighQ :: String -> Bool
- shouldBeReplaced :: String -> Bool
- indexesFromMrk :: String -> Int
- playAndMark :: Vector FilePath -> IO (Vector String)
- playAMrk :: IO (Vector String)
- pAnR1 :: Vector String -> IO (Vector String)
- pAnR2 :: Vector String -> IO ()
- pAnR_ :: IO ()
- playAMrk2G :: String -> IO (Vector String)
- pAnR12G :: String -> Vector String -> IO (Vector String)
- pAnR22G :: String -> Vector String -> IO ()
- pAnR_2G :: String -> IO ()
- infoFromV :: Vector String -> [(Vector Int, Vector String)]
- internalConv :: ([String], [String]) -> (Vector Int, Vector String)
- ixFromRes :: String -> String
- ixInterv :: Int -> IO (Int, Int)
- ixInterv2G :: String -> Int -> IO (Int, Int)
- thisOne :: IO Bool
- playSeqAR :: Int -> IO ()
- playSeqARV :: Vector Int -> IO ()
- playSeqARV2 :: Vector String -> IO ()
- playCollect1Dec :: Vector String -> Int -> IO Bool
- playCollectDec :: Vector String -> IO (Vector Bool)
- replaceWithHQs :: FilePath -> Vector Bool -> Vector FilePath -> IO ()
- isOddAsElem :: Eq a => a -> Vector [a] -> Bool
- maxLinV :: Ord a => Vector [a] -> Maybe a
- minLinV :: Ord a => Vector [a] -> Maybe a
- doubleLtoV :: Ord a => [[a]] -> Vector a
- filterToBnds :: Int -> Int -> [Int] -> [Int]
- getFileRSizes2G :: String -> IO (Vector Integer)
- getFileRSizesS2G :: String -> IO (Vector Int)
- getFileRTuples2G :: String -> IO (Vector (FilePath, Integer))
- listVDirectory2G :: String -> IO (Vector FilePath)
- listVDirectory3G :: String -> String -> IO (Vector FilePath)
- playSeqAR2G :: String -> Int -> IO ()
- playSeqARV2G :: String -> Vector Int -> IO ()
- playSeqARV22G :: String -> Vector String -> IO ()
- playCollectDec2G :: String -> Vector String -> IO (Vector Bool)
- replaceWithHQs2G :: String -> FilePath -> Vector Bool -> Vector FilePath -> IO ()
- soxBasicParams :: String -> [String] -> [String]
- reverbE :: FilePath -> [String] -> IO ()
- reverbWE :: FilePath -> [String] -> IO ()
- reverb1E :: FilePath -> [String] -> IO ()
- reverbW1E :: FilePath -> [String] -> IO ()
- reverbE2C :: FilePath -> [String] -> IO ()
- reverbWE2C :: FilePath -> [String] -> IO ()
- reverb1E2C :: FilePath -> [String] -> IO ()
- reverb1WE2C :: FilePath -> [String] -> IO ()
- soxE1 :: FilePath -> [String] -> IO ()
- getSilenceF :: FilePath -> IO ()
- fadeAllE :: String -> String -> IO ()
- fadeAllEMilN :: Int -> String -> String -> IO ()
- soxE2C :: FilePath -> [String] -> IO ()
- soxE12C :: FilePath -> [String] -> IO ()
- recE :: FilePath -> [String] -> IO ()
- rec1E :: FilePath -> [String] -> IO ()
- playE :: FilePath -> [String] -> IO ()
- f2w :: FilePath -> FilePath
- w2f :: FilePath -> FilePath
- cfw2wf :: FilePath -> FilePath
- efw2 :: FilePath -> String
- efw2vv :: FilePath -> String
- wOrf :: FilePath -> String
- wavToFlac :: String -> FilePath -> IO ()
- flacToWav :: String -> FilePath -> IO ()
- soxREw1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO ()
- soxRE1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO ()
- soxREA1 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> String -> String -> FilePath -> IO ()
Basic functions to work with intermediate files "result*wav"
getFileRSizes :: IO (Vector Integer) Source #
Gets sizes of the "result*.wav" files in the current directory.
getFileRSizesS :: IO (Vector Int) Source #
Similar to getFileRSizes
, but sizes are Int
, not Integer
. For most cases it is more memory efficient.
getFileRSizesS2 :: IO (Vector Int) Source #
Variant of getFileRSizes
function.
getFileRTuples :: IO (Vector (FilePath, Integer)) Source #
Gets Vector
of tuples of the pairs of "result*.wav" files and their respective sizes.
listVDirectory :: IO (Vector FilePath) Source #
Gets Vector
of the filenames for "result*.wav" files in the current directory.
isHighQ :: String -> Bool Source #
Function-predicate to check whether a file corresponding to its String
argument is considered as one of higher quality and therefore can be used
to replace the not so suitable ones while processing.
shouldBeReplaced :: String -> Bool Source #
Function-predicate to check whether a file corresponding to its String
argument is needed to be replaced while processing.
indexesFromMrk :: String -> Int Source #
Gets an index of the Vector
element corresponding to the String
generated by playAndMark
function.
Functions to edit the melody by editing the intermediate files "result*"
playAndMark :: Vector FilePath -> IO (Vector String) Source #
During function evaluation you can listen to the sound files and mark them with "1" and "0". The first one means that the sound is considered
of higher quality and is intended to be used as a replacement for the worse sounds marked by "0". The function returns a Vector
of specially formatted
String
that represents only those files that are connected with the replacement procedure.
playAMrk :: IO (Vector String) Source #
Function playAndMark
applied to all the "result*.wav" files in the current directory.
pAnR1 :: Vector String -> IO (Vector String) Source #
Process the sound corresponding to the first element in the first argument. Returns a tail
of the first element of the first command line argument.
Replaces (if specified) the sound with a sequence of (or just one, or made no replacement at all) sounds considered of higher quality.
pAnR2 :: Vector String -> IO () Source #
Process the WAV sounds consequently corresponding to the elements in the first argument. Replaces (if specified) the sounds with a sequence of (or just one, or made no replacement at all) sounds considered of higher quality for every sound needed.
2G generalized variants
playAMrk2G :: String -> IO (Vector String) Source #
Generalized variant of the playAMrk
with a possibility to play and mark either FLAC or WAV files. For more information, please, refer to
soxBasicParams
.
pAnR12G :: String -> Vector String -> IO (Vector String) Source #
Generalized variant of the pAnR1
with a possibility to work either with FLAC files or with WAV files.
Please, use with the FLAC files or with the WAV files separately. Do not intend to work with both types of them simultaneously using this function.
pAnR22G :: String -> Vector String -> IO () Source #
Generalized variant of the pAnR2
with a possibility to work either with FLAC files or with WAV files.
Please, use with the FLAC files or with the WAV files separately. Do not intend to work with both types of them simultaneously using this function.
pAnR_2G :: String -> IO () Source #
Generalized variant of the pAnR_
with a possibility to work either with FLAC files or with WAV files.
Please, use with the FLAC files or with the WAV files separately. Do not intend to work with both types of them simultaneously using this function.
Additional functions
Get information
infoFromV :: Vector String -> [(Vector Int, Vector String)] Source #
Parser to the result of listVDirectory2G
function to get the needed information.
internalConv :: ([String], [String]) -> (Vector Int, Vector String) Source #
Used to obtain parameters for processment.
ixFromRes :: String -> String Source #
Axiliary function to get a String
of consequent digits in the name of the "result*.wav" file.
ixInterv :: Int -> IO (Int, Int) Source #
Given an index of the element in the listVDirectory
output returns a tuple of the boundaries of the indexes usable for playback.
Note: index0 is probably from [0..], l1 is necessarily from [0..]. Interesting case is: 0 <= index0 < l1.
ixInterv2G :: String -> Int -> IO (Int, Int) Source #
Given an index of the element in the listVDirectory2G
(with the same String
as the second argument) output returns a tuple of the
boundaries of the indexes usable for playback.
Note: index0 is probably from [0..], l1 is necessarily from [0..]. Interesting case is: 0 <= index0 < l1.
IO
checkbox whether to add the sound played to the sequence of sounds that will replace the needed one.
Process and Edit
playSeqAR :: Int -> IO () Source #
Plays a sequence of sounds in the interval of them obtained by ixInterv
function.
playSeqARV2 :: Vector String -> IO () Source #
Plays a sequence of WAV sounds considered of higher quality.
playCollect1Dec :: Vector String -> Int -> IO Bool Source #
Plays a sound file considered to be of higher quality and then you define whether to use the played sound to replace that one considered to be replaced.
playCollectDec :: Vector String -> IO (Vector Bool) Source #
The same as playSeqARV2
, but additionally collects the resulting Bool
values and then returns them. It is used to define, which sounds from those of
higher quality will replace those ones considered to be replaced.
replaceWithHQs :: FilePath -> Vector Bool -> Vector FilePath -> IO () Source #
Actually replaces the file represented by FilePath
argument with no (then there is no replacement at all), or with just one,
or with a sequence of sounds being considered of higher quality to form a new melody. If the lengths of the second and the third
arguments differs from each other then the function uses as these arguments truncated vectors of the minimal of the two lengths.
isOddAsElem :: Eq a => a -> Vector [a] -> Bool Source #
A predicate to decide whether an element a
belongs to the odd number of the lists of a
in the Vector
.
maxLinV :: Ord a => Vector [a] -> Maybe a Source #
All [a]
must be finite. To obtain Just a0
as a result, at least one of the [a]
must be not empty and Vector
must have finite length.
If Vector
is empty
or all [a]
are null (the vector has finite length), then the result is Nothing
. Otherwise, it will run infinitely
just until it runs over the available memory.
minLinV :: Ord a => Vector [a] -> Maybe a Source #
All [a]
must be finite. To obtain Just a0
as a result, at least one of the [a]
must be not empty and Vector
must have finite length.
If Vector
is empty
or all [a]
are null (the vector has finite length), then the result is Nothing
. Otherwise, it will run infinitely
just until it runs over the available memory.
doubleLtoV :: Ord a => [[a]] -> Vector a Source #
2G generalized functions
getFileRSizes2G :: String -> IO (Vector Integer) Source #
Generalized variant of the getFileRSizes
with a possibility to get sizes either of FLAC or of WAV files. For more information, please, refer to
soxBasicParams
.
getFileRSizesS2G :: String -> IO (Vector Int) Source #
Generalized variant of the getFileRSizesS
with a possibility to get sizes either of FLAC or of WAV files. For more information, please, refer to
soxBasicParams
.
getFileRTuples2G :: String -> IO (Vector (FilePath, Integer)) Source #
Generalized variant of the getFileRTuples
with a possibility to get sizes either of FLAC or of WAV files. For more information, please, refer to
soxBasicParams
.
listVDirectory2G :: String -> IO (Vector FilePath) Source #
Generalized variant of the listVDirectory
with a possibility to get FilePath
for either FLAC or WAV files. For more information, please, refer to
soxBasicParams
.
3G generalized function
listVDirectory3G :: String -> String -> IO (Vector FilePath) Source #
Generalized variant of the listVDirectory2G
with a possibility to get FilePath
for not only "result*" files, but to specify their
beginning with the second String
argument. For example:
listVDirectory3G ys "result" == listVDirectory2G ys
Process and Edit
playSeqAR2G :: String -> Int -> IO () Source #
Generalized variant of the playSeqAR
with a possibility to play and mark either FLAC or WAV files. For more information, please, refer to
soxBasicParams
.
playSeqARV2G :: String -> Vector Int -> IO () Source #
Generalized variant of the playSeqARV
with a possibility to play and mark either FLAC or WAV files. For more information, please, refer to
soxBasicParams
.
playSeqARV22G :: String -> Vector String -> IO () Source #
Plays a sequence of sounds considered of higher quality.
playCollectDec2G :: String -> Vector String -> IO (Vector Bool) Source #
Generalized variant of the playCollectDec
with a possibility to play and mark either FLAC or WAV files. For more information, please, refer to
soxBasicParams
.
replaceWithHQs2G :: String -> FilePath -> Vector Bool -> Vector FilePath -> IO () Source #
Generalized variant of the replaceWithHQs
with a possibility to work either with FLAC files or with WAV files.
Please, use with the FLAC files or with the WAV files separately. Do not intend to work with both types of them simultaneously using this function.
SoX effects application
soxBasicParams :: String -> [String] -> [String] Source #
Is used internally in the functions to specify different SoX parameters for the sound synthesis (rate, bit depth and file extension). Possible
file extensions are: ".wav" (a default one) and ".flac" (being lossless compressed); rates -- 8000, 11025, 16000, 22050 (a default one), 32000,
44100, 48000, 88200, 96000, 176400, 192000 Hz; bit depths -- 16 bits and 24 bits. The first two digits in a String
argument encodes rate,
the next one -- bit depth and the last symbol -- letter 'w' or 'f' -- file extension. Because of SoX uses FLAC optionally, before use it, please,
check whether your installation supports it.
With "reverb" as the first
No file type changes
reverbE :: FilePath -> [String] -> IO () Source #
Takes a filename to be applied a SoX "reverb" effect with parameters of list of String
(the second argument). Produces the temporary
new file with the name ((name-of-the-file) ++ ("reverb.wav" OR "reverb.flac") -- the type is preserved), which then is removed.
Please, remember that for the mono audio the after applied function file is stereo with 2 channels.
Besides, you can specify other SoX effects after reverberation in a list of String
. The syntaxis is that every separate literal must be
a new element in the list. If you plan to create again mono audio in the end of processment, then probably use reverb1E
funcion instead.
If you would like to use instead of "reverb" its modification "reverb -w" effect (refer to SoX documentation), then probably it is more
convenient to use reverbWE
function. Please, check by yourself whether you have enough permissions to read and write to the FilePath
-specified
file and to the containing it directory. The function is not intended to be used in otherwise cases.
reverbWE :: FilePath -> [String] -> IO () Source #
The same as reverbE
, but uses "reverb -w" effect instead of "reverb". The name of the temporary file is
((name-of-the-file) ++ ("reverbW.wav" OR "reverbW.flac") -- the type is preserved). Please, for more information, refer to SoX documentation.
Please, check by yourself whether you have enough permissions to read and write to the FilePath
-specified
file and to the containing it directory. The function is not intended to be used in otherwise cases.
reverb1E :: FilePath -> [String] -> IO () Source #
The same as reverbE
, but at the end file is being mixed to obtain mono audio. The name of the temporary file is ((name-of-the-file) ++
("reverb1.wav" OR "reverb1.flac") -- the type is preserved).
Please, check by yourself whether you have enough permissions to read and write to the FilePath
-specified
file and to the containing it directory. The function is not intended to be used in otherwise cases.
reverbW1E :: FilePath -> [String] -> IO () Source #
The same as reverbWE
, but at the end file is being mixed to obtain mono audio. The name of the temporary file is ((name-of-the-file)
++ ("reverbW1.wav" OR "reverbW1.flac") -- the type is preserved). Please, check by yourself whether you have enough permissions
to read and write to the FilePath
-specified file and to the containing it directory. The function is not intended to be used in otherwise cases.
File type changes
reverbE2C :: FilePath -> [String] -> IO () Source #
Similar to reverbE
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
reverbWE2C :: FilePath -> [String] -> IO () Source #
Similar to reverbWE
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
reverb1E2C :: FilePath -> [String] -> IO () Source #
Similar to reverb1E
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
reverb1WE2C :: FilePath -> [String] -> IO () Source #
Similar to reverb1WE
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
Generalized
No file type changes
getSilenceF :: FilePath -> IO () Source #
Changes the volume of the given FilePath
with supported by SoX sound file type so that it becomes 0 (zero). Makes so it a silence file with the
same parameters for duration, rate, bit depth and file type.
fadeAllE :: String -> String -> IO () Source #
Applies fadeEnds
to all the "zs*.wav" (or instead all the "zs*.flac") files in the current directory. The file extension
is defined by the first String
argument in accordance with soxBasicParams
. zs
here is given by the second String
argument.
fadeAllEMilN :: Int -> String -> String -> IO () Source #
Applies fadeEndsMilN
to all the "zs*.wav" (or instead all the "zs*.flac") files in the current directory. The file extension
is defined by the first String
argument in accordance with soxBasicParams
. zs
here is given by the second String
argument. The Int
argument
defines a number of miliseconds to be under fading effect (no more than 10).
File type changes
soxE2C :: FilePath -> [String] -> IO () Source #
Similar to soxE
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
soxE12C :: FilePath -> [String] -> IO () Source #
Similar to soxE1
, but replaces the primary WAV file with the new FLAC file (or vice versa). So if successful the resulting file has another
extension and type.
Playing and recording
recE :: FilePath -> [String] -> IO () Source #
Function takes a FilePath
for the new recorded file (if it already exists then it is overwritten) and a list of String
. The last one is
sent to SoX rec or something equivalent as its arguments after the filename. If you plan just afterwards to produce mono audio, it's simpler to use
rec1E
function instead. Please, check by yourself whether you have enough permissions to read and write to the FilePath
-specified
file and to the containing it directory. The function is not intended to be used in otherwise cases.
Function is adopted and changed recA
function.
rec1E :: FilePath -> [String] -> IO () Source #
Function takes a FilePath
for the new recorded file (if it already exists then it is overwritten) and a list of String
. The last one is
sent to SoX rec or something equivalent as its arguments after the filename. Please, check by yourself whether you have enough permissions
to read and write to the FilePath
-specified file and to the containing it directory. The function is not intended to be used in otherwise cases.
Function is adopted and changed recA
function.
playE :: FilePath -> [String] -> IO () Source #
Plays a FilePath
file with a SoX further effects specified by the list of String
. It can be e. g. used to (safely) test the result of applying
some SoX effects and only then to use soxE
or some similar functions to actually apply them.
Please, check by yourself whether you have enough permissions to read the FilePath
-specified
file and the containing it directory. The function is not intended to be used in otherwise cases.
Function is adopted and changed playA
function.
2G auxiliary functions
wavToFlac :: String -> FilePath -> IO () #
Converts WAV file to FLAC file using SoX (please, check before whether your installation supports FLAC files) using possible rate and bit depth
conversion accordingly to soxBasicParams
format. If the conversion is successful (ExitCode
is ExitSuccess
) then removes the primary file.
flacToWav :: String -> FilePath -> IO () #
Converts FLAC file to WAV file using SoX (please, check before whether your installation supports FLAC files) using possible rate and bit depth
conversion accordingly to soxBasicParams
format. If the conversion is successful (ExitCode
is ExitSuccess
) then removes the primary file.
Special SoX effects
soxREw1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO () Source #
Applies a special chain of the SoX effects to a file to obtain a somewhat similar to some instruments sound for some values of the Int
parameters.
These last ones are used (after some normalizing transformation) as the arguments for the SoX "reverb -w" effect. For more information about their
meaning, please, refer to the SoX and reverberation documentation, besides you can give them a try.
soxRE1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO () Source #
Applies a special chain of the SoX effects to a file to obtain a somewhat other its sounding. Similar to soxREw1
in realization, but can give
rather another sounding.
soxREA1 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> String -> String -> FilePath -> IO () Source #
Applies a special chain of the SoX effects to the files which are obtained as a result of the listVDirectory3G
in the current directory.
For some values of the first six Int
parameters you obtain somewhat similar to some instruments sounds.
These parameters are used (after some normalizing transformation) as the arguments for the SoX "reverb -w" effect. For more information about their
meaning, please, refer to the SoX and reverberation documentation, besides you can give them a try. The last Int
parameter is the first argument
for the afterwards general SoX "reverb" effect. String
arguments are that ones for the listVDirectory3G
. The FilePath
argument is a name
for the resulting file (in the supported by the SoX format).