-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | 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. @package algorithmic-composition-basic @version 0.2.2.0 -- | 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. module Composition.Sound.IntermediateF -- | Gets sizes of the "result*.wav" files in the current directory. getFileRSizes :: IO (Array Int Integer) -- | Similar to getFileRSizes, but sizes are Int, not -- Integer. For most cases it is more memory efficient. getFileRSizesS :: IO (Array Int Int) -- | Variant of getFileRSizes function. getFileRSizesS2 :: IO (Array Int Int) -- | Gets 'Array Int' of tuples of the pairs of "result*.wav" files and -- their respective sizes. getFileRTuples :: IO (Array Int (FilePath, Integer)) -- | Gets Array Int of the filenames for "result*.wav" files -- in the current directory. listVDirectory :: IO [FilePath] -- | 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. isHighQ :: String -> Bool -- | Function-predicate to check whether a file corresponding to its -- String argument is needed to be replaced while processing. shouldBeReplaced :: String -> Bool -- | Gets an index of the element corresponding to the String -- generated by playAndMark function. Partial function. indexesFromMrk :: String -> Int -- | 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 -- Array Int of specially formatted String that -- represents only those files that are connected with the replacement -- procedure. playAndMark :: [FilePath] -> IO [String] -- | Function playAndMark applied to all the "result*.wav" files in -- the current directory. playAMrk :: IO [String] -- | 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. pAnR1 :: [String] -> IO [String] -- | 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. pAnR2 :: [String] -> IO () -- | Marks the needed WAV files as of needed to be replaced or those ones -- considered of higher quality that will replace the needed ones. Then -- actually replaces them as specified. Uses internally playAMrk -- and pAnR2 functions. pAnR_ :: IO () -- | Generalized variant of the playAMrk with a possibility to play -- and mark either FLAC or WAV files. For more information, please, refer -- to soxBasicParams. playAMrk2G :: String -> IO [String] -- | 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. pAnR12G :: String -> [String] -> IO [String] -- | 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. pAnR22G :: String -> [String] -> IO () -- | 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. pAnR_2G :: String -> IO () -- | Parser to the result of listVDirectory2G function to get the -- needed information. infoFromV :: [String] -> [([Int], [String])] -- | Used to obtain parameters for processment. Partial function. internalConv :: ([String], [String]) -> ([Int], [String]) -- | Axiliary function to get a String of consequent digits in the -- name of the "result*.wav" file. ixFromRes :: String -> String -- | 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. ixInterv :: Int -> IO (Int, Int) -- | 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. ixInterv2G :: String -> Int -> IO (Int, Int) -- | IO checkbox whether to add the sound played to the sequence of -- sounds that will replace the needed one. thisOne :: IO Bool -- | Plays a sequence of sounds in the interval of them obtained by -- ixInterv function. playSeqAR :: Int -> IO () -- | Plays a sequence of consequential sounds in the melody in the interval -- of them obtained by ixInterv function for each element index -- from [Int] of indexes. playSeqARV :: [Int] -> IO () -- | Plays a sequence of WAV sounds considered of higher quality. playSeqARV2 :: [String] -> IO () -- | 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. playCollect1Dec :: Array Int String -> Int -> IO Bool -- | 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. playCollectDec :: [String] -> IO [Bool] -- | 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. replaceWithHQs :: FilePath -> [Bool] -> [FilePath] -> IO () -- | A predicate to decide whether an element a belongs to the odd -- number of the lists of a. isOddAsElem :: Eq a => a -> [[a]] -> Bool -- | All [a] must be finite. To obtain Just a0 as a -- result, at least one of the [a] must be not empty and the -- [[a]] must have finite length. If the argument is [] 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. maxLinV :: Ord a => [[a]] -> Maybe a -- | All [a] must be finite. To obtain Just a0 as a -- result, at least one of the [a] must be not empty and the -- [[a]] must have finite length. If the argument is [] 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 => [[a]] -> Maybe a -- | Applied to list of [a] where a is an instance for Ord -- class gives a sorted in the ascending order [[a]], each of them being -- unique. doubleLtoV :: Ord a => [[a]] -> [a] -- | Filters Int elements in a list so that they are limited with -- the first two Int arguments of the function as a lower and a -- higher bounds. filterToBnds :: Int -> Int -> [Int] -> [Int] -- | 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. getFileRSizes2G :: String -> IO (Array Int Integer) -- | 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. getFileRSizesS2G :: String -> IO (Array Int Int) -- | 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. getFileRTuples2G :: String -> IO (Array Int (FilePath, Integer)) -- | Generalized variant of the listVDirectory with a possibility to -- get FilePath for either FLAC or WAV files. For more -- information, please, refer to soxBasicParams. listVDirectory2G :: String -> IO [FilePath] -- | 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: -- --
-- elems . listVDirectory3G ys $ "result" == listVDirectory2G ys --listVDirectory3G :: String -> String -> IO (Array Int FilePath) -- | Generalized variant of the playSeqAR with a possibility to play -- and mark either FLAC or WAV files. For more information, please, refer -- to soxBasicParams. playSeqAR2G :: String -> Int -> IO () -- | Generalized variant of the playSeqARV with a possibility to -- play and mark either FLAC or WAV files. For more information, please, -- refer to soxBasicParams. playSeqARV2G :: String -> [Int] -> IO () -- | Plays a sequence of sounds considered of higher quality. playSeqARV22G :: String -> [String] -> IO () -- | Generalized variant of the playCollectDec with a possibility to -- play and mark either FLAC or WAV files. For more information, please, -- refer to soxBasicParams. playCollectDec2G :: String -> [String] -> IO [Bool] -- | 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. replaceWithHQs2G :: String -> FilePath -> [Bool] -> [FilePath] -> IO () -- | 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. soxBasicParams :: String -> [String] -> [String] -- | 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. reverbE :: FilePath -> [String] -> IO () -- | 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. reverbWE :: FilePath -> [String] -> IO () -- | 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. reverb1E :: FilePath -> [String] -> IO () -- | 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. reverbW1E :: FilePath -> [String] -> IO () -- | 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. reverbE2C :: FilePath -> [String] -> IO () -- | 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. reverbWE2C :: FilePath -> [String] -> IO () -- | 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. reverb1E2C :: FilePath -> [String] -> IO () -- | 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. reverb1WE2C :: FilePath -> [String] -> IO () -- | The same as soxE, but at the end file is being mixed to obtain -- mono audio. 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. soxE1 :: FilePath -> [String] -> IO () -- | 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. getSilenceF :: FilePath -> IO () -- | 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. fadeAllE :: String -> String -> IO () -- | 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). fadeAllEMilN :: Int -> String -> String -> IO () -- | 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. soxE2C :: FilePath -> [String] -> IO () -- | 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. soxE12C :: FilePath -> [String] -> IO () -- | 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. recE :: FilePath -> [String] -> IO () -- | 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. rec1E :: FilePath -> [String] -> IO () -- | 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. playE :: FilePath -> [String] -> IO () f2w :: FilePath -> FilePath w2f :: FilePath -> FilePath cfw2wf :: FilePath -> FilePath efw2 :: FilePath -> String efw2vv :: FilePath -> String wOrf :: FilePath -> String -- | 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. wavToFlac :: 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. flacToWav :: String -> FilePath -> IO () -- | 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. soxREw1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO () -- | 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. soxRE1 :: Int -> Int -> Int -> Int -> Int -> Int -> FilePath -> IO () -- | 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). soxREA1 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> String -> String -> FilePath -> IO () -- | 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. module Composition.Sound.Functional.Basics -- | Is used to represent a sequence of intervals, each note being a -- Float value (its frequency in Hz). type SoundsO = Array Int (Float, Float) -- | Is used to represent a set of overtones for the single sound, the -- first Float value is a frequency and the second one -- an -- amplitude. type OvertonesO = [(Float, Float)] -- | Is used to represent a set of pairs of notes for each element of which -- the Float values (notes frequencies in Hz) are somewhat -- musically connected one with another.. type NotePairs = Array Int (Float, Float) -- | Array of musical notes in Hz. notes :: Array Int Float -- | Function returns either the nearest two musical notes if frequency is -- higher than one for C0 and lower than one for B8 or the nearest note -- duplicated in a tuple. neighbourNotes :: Float -> (Int, Int) -> (Float, Float) -- | Returns the closest note to the given frequency in Hz. closestNote :: Float -> Float -- | Returns a pure quint lower than the given note. pureQuintNote :: Float -> Float -- | For the given frequency of the note it generates a list of the tuples, -- each one of which contains the harmonics' frequency and amplitude. overTones :: Float -> OvertonesO overTonesALaClarinet :: Float -> OvertonesO -- | For the given frequency it generates a musical sound with a timbre. -- The main component of the sound includes the lower pure quint, which -- can be in the same octave or in the one with the number lower by one. -- Please, check before executing whether there is no "x.wav", "test*", -- "result*" and "end.wav" files in the current directory, because they -- can be overwritten. overSoXSynth :: Float -> IO () -- | Similar to overSoXSynth but uses overTonesALaClarinet -- instead of overTones. overSoXSynthALaClarinet :: Float -> IO () -- | Generalized variant of the overSoXSynth with the possibility to -- set the variant of the overtones for the notes as the first argument. -- @ since 0.2.0.0 removed some extra processment with uncertain -- semantics. overSoXSynthG :: (Float -> OvertonesO) -> Float -> IO () -- | Generalized variant of the overSoXSynth with the possibility to -- set the variant of the overtones for the notes as the first argument -- and the harmonizers rules by the first list argument. The first list -- is intended to contain no more than 9 elements (this will generate -- containing no more than 10 different notes chord at once). overSoXSynthGG :: [Float -> Float] -> (Float -> OvertonesO) -> Float -> IO () -- | Returns a Array Int of tuples with the lowest and -- highest frequencies for the notes in the sets consisting of n -- consequential notes (including semi-tones). An Int argument -- defines this n. It can be 2, 3, 4, 6, 9, or 12 (the last one -- is for default octaves, see octavesT). So for different valid -- n you obtain doubles, triples and so on. The function being -- applied returns a Array Int of such sets with their -- respective lowest and highest frequencies. nkyT :: Int -> NotePairs -- | Function can be used to determine to which octave (in the American -- notation for the notes, this is a number in the note written form, e. -- g. for C4 this is 4) the frequency belongs (to be more exact, the -- closest note for the given frequency -- see closestNote taking -- into account its lower pure quint, which can lay in the lower by 1 -- octave). If it is not practical to determine the number, then the -- function returns Nothing. whichOctave :: Float -> Maybe Int -- | Generalized version of the whichOctave. whichOctaveG :: Float -> Maybe Int -- | Similarly to whichOctave returns a Maybe number for the -- n-th elements set of notes (see nkyT). An Int parameter -- defines that n. whichEnka :: Int -> Float -> Maybe Int -- | Returns an analogous note in the higher n-th elements set (its -- frequency in Hz) (see nkyT). An Int parameter defines -- this n. enkuUp :: Int -> Float -> Float -- | Returns an analogous note in the lower n-th elements set (its -- frequency in Hz) (see nkyT). An Int parameter defines -- this n. enkuDown :: Int -> Float -> Float -- | Similarly to liftInOctaveV returns a [Float] (actually -- frequencies) for the n-th elements set of notes (see nkyT) -- instead of octaves. A second Int parameter defines that -- n. liftInEnkuV :: Int -> Int -> [Float] -> [Float] -- | Similarly to liftInOctave returns a Maybe number -- (actually frequency) for the n-th elements set of notes (see -- nkyT). A second Int parameter defines that n. -- Not all pairs return Just x. liftInEnku :: Int -> Int -> Float -> Maybe Float -- | Returns a Array Int of tuples with the lowest and -- highest frequencies for the notes in the octaves. octavesT :: NotePairs -- | Combines (mixes) all "test*" files in the given directory. The files -- should be similar in parameters and must be sound files for SoX to -- work on them properly. Afterwards, the function deletes these combined -- files. mixTest :: IO () -- | Combines (mixes) all "test*" files in the given directory. The files -- should be similar in parameters and must be sound files for SoX to -- work on them properly. Afterwards, the function deletes these combined -- files. The name of the resulting file depends on the first two command -- line arguments so that it is easy to produce unique names for the -- consequent call for the function. The function works properly only for -- the amount of the files not greater than several hundreds. If -- possible, use mixTest function instead. mixTest2 :: Int -> Int -> IO () -- | Gets Int frequencies from the given FilePath using SoX. -- The frequencies are "rough" according to the SoX documentation and the -- duration is too small so they can be definitely other than expected -- ones. Is used as a source of variable numbers (somewhat close each to -- another in their order but not neccessarily). . freqsFromFile :: FilePath -> Int -> IO [Int] -- | Gets an "end.wav" file from the intermediate "result*.wav" files in -- the current directory. If it is not successful, produces the -- notification message and exits without error. If you would like to -- create the file if there are too many intermediate ones, please, run -- "dobutokO2 8" or "dobutokO2 80" in the current directory. endFromResult :: IO () -- | Function to get from the number of semi-tones and a note a -- Maybe note for the second lower note in the interval if any. If -- there is no need to obtain such a note, then the result is -- Nothing. dNote :: Int -> Float -> Maybe Float -- | Similar to mixTest, but allows to change the sound quality -- parameters for the resulting file. For more information, please, refer -- to soxBasicParams. mixTest2G :: String -> IO () -- | Similar to mixTest, but allows to change the sound quality -- parameters for the resulting file. For more information, please, refer -- to soxBasicParams. The name of the resulting file depends on -- the first two command line arguments so that it is easy to produce -- unique names for the consequent call for the function. The function -- works properly only for the amount of the files not greater than -- several hundreds. If possible, use mixTest2G function instead. mixTest22G :: Int -> Int -> String -> IO () -- | Similar to endFromResult, but uses additional String -- argument to change sound quality parameters. For more information, -- please, refer to soxBasicParams. endFromResult2G :: String -> IO () -- | Generates part of the "test*" files with the additional volume -- adjustment in dB given by Array Int Float. partialTest_k1G :: OvertonesO -> Int -> String -> Array Int Float -> IO () -- | Generalized version of the partialTest_k1G with a possibility -- to change sound quality parameters using the additional second -- String argument. For more information, please, refer to -- soxBasicParams. partialTest_k2G :: OvertonesO -> Int -> String -> Array Int Float -> String -> IO () -- | Additional function to prepend zeroes to the given String. The -- number of them are just that one to fulfill the length to the given -- Int parameter. prependZeroes :: Int -> String -> String nOfZeroesLog :: Int -> Maybe Int -- | Is a minimal number of decimal places that are just enough to -- represent a length of the list given. For an [] returns 0. numVZeroesPre :: [a] -> Int -- | Auxiliary function to get from a sound file specified a duration -- parameter n that can be used further. duration1000 :: FilePath -> IO Int -- | Is used internally in the readProcessWithExitCode to adjust -- volume for the sound with additional dB value given by Float -- argument. adjust_dbVol :: [String] -> Float -> [String] -- | 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. module Composition.Sound.Functional.Params -- | Representation of the scales and modes for the notes. Can be extended -- further, but for a lot of situations the following realization is -- sufficient. See, for example, filterInParams and so on. -- String is (are) used as a general classification name, for some -- of them there are provided two String to classify. Lists are -- used to specify remainders in some meaning. See also, -- liftInParams and toneE (toneD) functions, -- elemP and elemCloseP, lengthP and showD. data Params P2 :: Int -> Int -> Params P2s :: Int -> Int -> String -> Params P3sf :: Int -> Int -> Int -> String -> Params P4lsf :: Int -> Int -> Int -> [Int] -> String -> Params P32sf :: Int -> Int -> Int -> String -> String -> Params P3lf :: Int -> Int -> [Int] -> Params -- | Is used to represent a set of durations parameters of the sounds and -- pauses. The positive value corresponds to the sound and the negative -- one -- to the pause. type Durations = Array Int Float -- | Is used to represent a set of volumes in the amplitude scale for SoX -- "vol" effect. type Strengths = Array Int Float -- | Is used to represent a set of intervals for notes (each element is a -- number of semi-tones between parts of interval). Positive values -- corresponds to lower notes and negative to higher ones. type Intervals = Array Int Int -- | 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. For information there were used the following: -- -- https://en.wikipedia.org/wiki/Mode_(music) -- -- https://en.wikipedia.org/wiki/Ukrainian_Dorian_scale -- -- https://en.wikipedia.org/wiki/List_of_musical_scales_and_modes -- -- https://en.wikipedia.org/wiki/Octatonic_scale -- -- several other articles in the English Wikipedia -- -- and in Ukrainian: Смаглій Г., Маловик Л. Теорія музики : Підруч. для -- навч. закл. освіти, культури і мистецтв / Г.А. Смаглій. -- Х. : Вид-во -- "Ранок", 2013. -- 392 с. ISBN 978-617-09-1294-7 filterInParams :: Params -> Maybe (Array Int Float) -- | For the list of a from the Ord class it builds a -- sorted in the ascending order list without duplicates. -- --
-- sortNoDup [2,1,4,5,6,78,7,7,5,4,3,2,5,4,2,4,54,3,5,65,4,3,54,56,43,5,2] = [1,2,3,4,5,6,7,43,54,56,65,78] --sortNoDup :: Ord a => [a] -> [a] -- | Checks whether its first Int argument does not belong to those -- ones that are included into the list argument on the reminders basis. -- The opposite to toneE with the same arguments. The list -- argument must be sorted in the ascending order. toneD :: Int -> Int -> Int -> [Int] -> Bool -- | Checks whether its first Int argument does belong to those ones -- that are included into the list argument on the reminders basis. The -- opposite to toneD with the same arguments. The list argument -- must be sorted in the ascending order. toneE :: Int -> Int -> Int -> [Int] -> Bool -- | Analogous to liftInEnku lifts a frequency into a tonality (or -- something that can be treated alike one) specified by Params. -- If not reasonably one exists then the result is 11440 (Hz). Partial -- function. liftInParams :: Float -> Params -> Float -- | Application of the liftInParams to a list. Partial function. liftInParamsV :: Params -> [Float] -> [Float] -- | Gets a length of the Array Int of Float being -- represented as Params. This is a number of the notes contained -- in the Params. lengthP :: Params -> Int -- | Check whether a given Float value (frequency of a note) is in -- the vector of Floats that corresponds to the given Params. elemP :: Float -> Params -> Bool -- | Check whether a given Float value (frequency of the closest -- note to the given frequency) is in the vector of Floats that -- corresponds to the given Params. elemCloseP :: Float -> Params -> Bool -- | A way to show not the (somewhat algebraic) structure of the -- Params (as the usual show does), but the contained -- frequencies in it. showD :: Params -> String -- | Check whether for the given arguments there are the notes and whether -- String is a name signature for the scale in Params (can -- they be used together to correspond to a non-empty set of notes). isStrParams :: String -> Params -> Bool -- | Check whether for the given arguments there are the notes and whether -- list of Int is a part of the constructed Params (can -- they be used together to correspond to a non-empty set of notes). isListParams :: [Int] -> Params -> Bool -- | Generalized version of the overSoXSynthGen2FDN_SG4G where -- instead of lifting with liftInEnkuV liftInParamsV is -- used. It allows e. g. to use some tonality. For more information, -- please, refer to filterInParams. overSoXSynthGen2FDN_SG4GPar :: FilePath -> Params -> (Float -> OvertonesO) -> Float -> Durations -> String -> ((Float -> OvertonesO) -> (Float, Float) -> Int -> String -> IO ()) -> IO () -- | Generalized version of the overSoXSynthGen2FDN_SG6G where -- instead of lifting with liftInEnkuV liftInParamsV is -- used. It allows e. g. to use some tonality. For more information, -- please, refer to filterInParams. overSoXSynthGen2FDN_SG6GPar :: FilePath -> Params -> (Float -> OvertonesO) -> Float -> Durations -> String -> ((Float -> OvertonesO) -> (Float, Float) -> Int -> String -> IO ()) -> Strengths -> Float -> IO () -- | Generalized version of the overSoXSynthGen2FDN_SG2G where -- instead of lifting with liftInEnkuV liftInParamsV is -- used. It allows e. g. to use some tonality. For more information, -- please, refer to filterInParams. overSoXSynthGen2FDN_SG2GPar :: FilePath -> Params -> (Float -> OvertonesO) -> Float -> String -> String -> ((Float -> OvertonesO) -> (Float, Float) -> Int -> String -> String -> IO ()) -> String -> IO () -- | 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. overSoXSynthGen2FDN_Sf3GPar :: FilePath -> Params -> (Float -> OvertonesO) -> Float -> Float -> String -> String -> ((Float -> OvertonesO) -> (Float, Float, Float) -> Int -> String -> IO ()) -> IO () -- | 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. overSoXSynthGen2FDN_Sf3G2GPar :: FilePath -> Params -> (Float -> OvertonesO) -> Float -> Float -> String -> String -> ((Float -> OvertonesO) -> (Float, Float, Float) -> Int -> String -> String -> IO ()) -> String -> IO () -- | Generates melody for the given parameters. The idea is that every -- application of the function f :: Float -> OvertonesO to -- its argument possibly can produce multiple overtones being represented -- as list of tuples of pairs of Float. We can use the first -- element in the tuple to obtain a new sound parameters and the second -- one -- to obtain its new duration in the melody. Additional function -- g :: Float -> Float is used to avoid the effect of -- becoming less and less -- closer to the zero for the higher overtones -- so the durations will become also less. Besides it allows to rescale -- the durations in a much more convenient way. -- -- The first Float parameter is a multiplication coefficient to -- increase or to decrease the durations (values with an absolute values -- greater than one correspond to increasing inside the g. -- function applied afterwards with function composition and the values -- with an absolute values less than one and not equal to zero correspond -- to decreasing inside the g function. The second Float -- parameter is a usual frequency which is used instead of the 11440.0 -- (Hz) value. The third Float parameter is a main argument -- the -- frequency for which the OvertonesO are generated as a first -- step of the computation. overMeloPar :: (Float -> OvertonesO) -> (Float -> Float) -> Params -> Float -> Float -> Float -> IO () -- | 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.). Partial function. str2DurationsDef :: Int -> String -> Float -> Durations -- | Additional function to produce signs from the given String of -- the Ukrainian text. Ukrainian vowels and voiced consonants gives "+" -- sign (+1), voiceless and sonorous consonants gives "-" sign (-1). "сь" -- and "ць" gives "0". Other symbols are not taken into account. signsFromString :: Int -> String -> Array Int Int -- | Apply volume adjustment to the sound file. It must not be silent. -- Otherwise, it leads to likely noise sounding or errors. The code is -- adapted from the MMSyn7l module from the mmsyn7l package. apply6Gf :: Float -> FilePath -> IO () apply6GSilentFile :: FilePath -> Float -> Float -> IO () -- | Generatlized version of the vStrToVInt with a possibility to -- specify your own Intervals. vStrToVIntG :: Intervals -> String -> Intervals -- | Generatlized version of the strToInt with a possibility to -- specify your own Intervals. strToIntG :: Intervals -> Char -> Int -- | Default values for strToInt. All the intervals are not -- greater than one full octave. defInt :: Intervals -- | Function is used to generate a rhythm of the resulting file 'end.wav' -- from the Ukrainian text and a number of sounds either in the syllables -- or in the words without vowels. syllableStr :: Int -> String -> [Int] -- | Generalized variant of the overSoXSynth2FDN_Sf31G with a -- possibility to specify sound quality using the second String -- parameter. For more information, please, refer to -- soxBasicParams. overSoXSynth2FDN_Sf32G :: (Float -> OvertonesO) -> (Float, Float, Float) -> Int -> String -> Array Int Float -> String -> IO () -- | Function is used to get numbers of intervals from a Ukrainian -- String. It is used internally in the -- uniqOverSoXSynthN4 function. intervalsFromString :: String -> Intervals -- | Generates a melodic line (a somewhat complex changing sound) with a -- possibility to specify sound quality using the String argument. -- For more information, please, refer to soxBasicParams. soundGenF32G :: [Float -> Float] -> [Float] -> [Int] -> (Float -> OvertonesO) -> (Float, Float, Float) -> Int -> Array Int Float -> String -> IO () helpF0 :: Int -> String helpF1 :: [Float -> Float] -> [Float] -> [Int] -> [Maybe Float] -- | Generates a list of OvertonesO that represents the melodic -- line. doubleVecFromVecOfFloat :: (Float -> OvertonesO) -> Float -> [Maybe Float] -> [OvertonesO] instance GHC.Show.Show Composition.Sound.Functional.Params.Params instance GHC.Classes.Ord Composition.Sound.Functional.Params.Params instance GHC.Classes.Eq Composition.Sound.Functional.Params.Params -- | 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. module Composition.Sound.Functional.Elements -- | Renormalizes amplitudes for the frequencies so that the maximum one of -- them (if OvertonesO is not []) is equal by the absolute value -- to 1.0 and the mutual ratios of the amplitudes are preserved. renormF :: OvertonesO -> OvertonesO uniq :: Eq a => [a] -> [a] luniq :: Eq a => [a] -> Int -- | Renormalizes amplitudes for the frequencies so that the maximum one of -- them (if OvertonesO is not []) is equal by the absolute value -- to Float argument and the mutual ratios of the amplitudes are -- preserved. renormFD :: Float -> OvertonesO -> OvertonesO -- | Predicate to check whether all tuples in the list have the same first -- element. sameOvertone :: OvertonesO -> Bool -- | g :: (Float,Float) -> OvertonesO -> OvertonesO is a -- function that defines how the new element is added to the -- OvertonesO. It depends only on the element being added and the -- actual OvertonesO. It does not depend on the Float -- argument for f :: Float -> OvertonesO so for different -- Float for f it gives the same result. sameFreqF :: Float -> (Float, Float) -> (Float -> OvertonesO) -> ((Float, Float) -> OvertonesO -> OvertonesO) -> OvertonesO -- | g :: (Float,Float) -> OvertonesO -> OvertonesO is a -- function that defines how the new element is added to the -- OvertonesO. Variant of sameFreqF where g depends only on -- the elements of the OvertonesO, which first elements in the -- tuples equal to the first element in the (Float,Float). It -- does not depend on the Float argument for f :: Float -> -- OvertonesO so for different Float for f it gives -- the same result. sameFreqFI :: Float -> (Float, Float) -> (Float -> OvertonesO) -> ((Float, Float) -> OvertonesO -> OvertonesO) -> OvertonesO -- | gAdd :: (Float,Float) -> Float -> (Float -> OvertonesO) -- -> OvertonesO is a function that defines how the element is -- added to the OvertonesO. fAddFElem is actually a -- higher-order function, it changes the function f and returns -- a new one. It can be an interesting task (in general) to look at such -- a function through a prism of notion of operator (mathematical, for -- example similar to that ones that are used for quantum mechanics and -- quantum field theory). gAdd allows not only to insert an -- element if missing, but to change all the OvertonesO system. So -- depending on the complexity, it can produce rather complex behaviour. fAddFElem :: (Float, Float) -> (Float -> OvertonesO) -> ((Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO) -> Float -> OvertonesO -- | gRem:: (Float,Float) -> Float -> (Float -> OvertonesO) -- -> OvertonesO is a function that defines how the element is -- removed from the OvertonesO. fRemoveFElem is actually a -- higher-order function, it changes the function f and returns -- a new one. It can be an interesting task (in general) to look at such -- a function through a prism of notion of operator (mathematical, for -- example that ones that are used for quantum mechanics and quantum -- field theory). gRem allows not only to delete an element if -- existing, but to change all the OvertonesO system. So depending -- on the complexity, it can produce rather complex behaviour. fRemoveFElem :: (Float, Float) -> (Float -> OvertonesO) -> ((Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO) -> Float -> OvertonesO -- | Changes elements of the OvertonesO using two functions. It is a -- generalization of the fAddFElem and fRemoveFElem -- functions. For example, if the first of the two inner functional -- arguments acts as gAdd01 or similar, then it adds element to -- the OvertonesO, if it acts as gRem01, then it removes -- the element. Its behaviour is defined by the Float parameter -- (meaning frequency, probably), so you can change elements depending on -- what point it is applied. fChangeFElem :: (Float, Float) -> Float -> (Float -> (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO) -> (Float -> OvertonesO) -> Float -> OvertonesO -- | Example of the function gAdd for the fAddFElem. If the -- frequency is already in the OvertonesO then the corresponding -- amplitude is divided equally between all the elements with the -- repeated given frequency from (Float, Float). Otherwise, it -- is just concatenated to the OvertonesO. gAdd01 :: (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Can be used to produce an example of the function gAdd for -- the fAddFElem. Similar to gAdd01, but uses its first -- argument to renorm the result of the gAdd01 so that its maximum -- by absolute value amplitude equals to the first argument. gAdd02 :: Float -> (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Example of the function gAdd. for the fAddFElem. If -- the frequency is not already in the OvertonesO then the -- corresponding element is added and the OvertonesO are renormed -- with renormF. Otherwise, the element is tried to be inserted -- with a new frequency between the greatest by an absolute values notes -- as an intermediate value with the respective amplitude, or if there is -- only one element, to produce two elements in the resulting list with -- two consequent harmonics. gAdd03 :: (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Example of the function gAdd. for the fAddFElem. It -- tries to insert the given (Float,Float) into the less -- dense frequency region. gAdd04 :: (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Example of the function gRem for the fRemoveFElem. If the -- element is already in the OvertonesO then it is removed (if -- there are more than 5 elements already) and OvertonesO are -- renormalized. Otherwise, all the same for the element already existing -- elements become less in an amlitude for a numbers that in sum equal to -- amplitude of the removed element. gRem01 :: (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Can be used to produce an example of the function gRem for -- the fRemoveFElem. Similar to gRem01, but uses its first -- argument to renorm the result of the gRem01 so that its maximum -- by absolute value amplitude equals to the first argument. gRem02 :: Float -> (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Example of the function gRem for the fRemFElem. It -- tries not to remove elements from the less than 6 elements -- OvertonesO and to remove all the elements in the given range -- with the width of the twice as many as the second Float in the -- first argument tuple and the centre in the first Float in the -- tuple. Similar to somewhat bandreject filter but with more complex -- behaviour for the sound to be more complex. gRem03 :: (Float, Float) -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Similar to fAddFElem, but instead of one element -- (Float,Float) it deals with a list of such elements that is -- OvertonesO. fAddFElems :: OvertonesO -> (Float -> OvertonesO) -> (OvertonesO -> Float -> (Float -> OvertonesO) -> OvertonesO) -> Float -> OvertonesO -- | Similar to fRemoveFElem, but instead of one element -- (Float,Float) it deals with a list of such elements that is -- OvertonesO. fRemoveFElems :: OvertonesO -> (Float -> OvertonesO) -> (OvertonesO -> Float -> (Float -> OvertonesO) -> OvertonesO) -> Float -> OvertonesO -- | Similar to fChangeFElem, but use another form of the changing -- function, so it can deal with not only single element of the -- OvertonesO, but also with several ones. fChangeFElems :: OvertonesO -> Float -> (Float -> OvertonesO -> Float -> (Float -> OvertonesO) -> OvertonesO) -> (Float -> OvertonesO) -> Float -> OvertonesO -- | Binary predicate to check whether two given OvertonesO both -- have the elements with the same first element in the tuples. If -- True then this means that OvertonesO are at least -- partially overlaped by the first elements in the tuples (meaning -- frequencies). freqsOverlapOvers :: OvertonesO -> OvertonesO -> Bool -- | Similar to freqsOverlapOvers, but checks whether the whole -- tuples are the same instead of the first elements in the tuples are -- the same. elemsOverlapOvers :: OvertonesO -> OvertonesO -> Bool -- | Example of the function gAdds for the fAddFElems. -- Partial function. gAdds01 :: OvertonesO -> Float -> (Float -> OvertonesO) -> OvertonesO -- | Can be used to produce an example of the function gAdds for -- the fAddFElems. Similar to gAdds01, but uses its first -- argument to renorm the result of the gAdds01 so that its -- maximum by absolute value amplitude equals to the first argument. gAdds02 :: Float -> OvertonesO -> Float -> (Float -> OvertonesO) -> OvertonesO -- | 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. module Composition.Sound.Keyboard -- | Converts a string of lowercase ASCII letters being typed on the QWERTY -- keyboard layout into corresponding Dvorak keyboard layout. qwerty2dvorak :: ByteString -> ByteString -- | Vice versa to qwerty2dvorak. dvorak2qwerty :: ByteString -> ByteString -- | Get contents into lazy ByteString with filtering of all -- characters that are not a lower case ascii letters. input2BL :: IO ByteString -- | Like input2BL, but takes only first n symbols -- specified with the first Int64 argument. input2BLN :: Int64 -> IO ByteString -- | Like input2BL, but takes only first n symbols -- specified with the second Int64 argument dropping before this -- the first m symbols specified with the first Int64 -- argument. input2BLMN :: Int64 -> Int64 -> IO ByteString -- | Usual way the function readFile2BLGen is used. The text in a -- file being read is treated as a properly typed (entered) one. So there -- is no keyboard layout conversion at all. readFile2BL :: FilePath -> IO ByteString -- | Like readFile2BL, but reads only first n symbols -- specified with the first Int64 argument. readFile2BLN :: Int64 -> FilePath -> IO ByteString -- | Like readFile2BL, but reads only first n symbols -- specified with the second Int64 argument dropping before this -- the first m symbols specified with the first Int64 -- argument. readFile2BLMN :: Int64 -> Int64 -> FilePath -> IO ByteString -- | Reads a given file into a lazy ByteString with filtering of all -- characters that are not a lower case ascii letters. It has additional -- first command line argument to control the way of treating letters: as -- being typed (entered) properly (null String), or needed to be -- converted from qwerty to dvorak layout ("q" String), or vice -- versa (otherwise). readFile2BLGen :: String -> FilePath -> IO ByteString -- | Like readFile2BLGen, but reads only first n symbols -- specified with the first Int64 argument. readFile2BLGenN :: Int64 -> String -> FilePath -> IO ByteString -- | Like readFile2BLGen, but reads only first n symbols -- specified with the second Int64 argument dropping before this -- the first m symbols specified with the first Int64 -- argument. readFile2BLGenMN :: Int64 -> Int64 -> String -> FilePath -> IO ByteString -- | Usual way the function readFileDoublesGen is used. The text in -- a file being read is treated as a properly typed (entered) one. So -- there is no keyboard layout conversion at all. readFileDoubles :: FilePath -> IO [Int] -- | Like readFileDoubles, but returns only first n -- elements of the list specified with the first Int64 argument. readFileDoublesN :: Int64 -> FilePath -> IO [Int] -- | Like readFileDoubles, but returns only first n -- elements of the list specified with the second Int64 argument -- dropping before this the first m elements specified with the -- first Int64 argument. readFileDoublesMN :: Int64 -> Int64 -> FilePath -> IO [Int] -- | After reading a file into a filtered lazy ByteString (see, -- readFile2BLGen) converts the resulting ByteString into a -- list of Int. The arguments have the same meaning as for -- readFile2BLGen. readFileDoublesGen :: String -> FilePath -> IO [Int] -- | Like readFileDoublesGen, but returns only first n -- elements of the list specified with the first Int64 argument. readFileDoublesGenN :: Int64 -> String -> FilePath -> IO [Int] -- | Like readFileDoublesGen, but returns only first n -- symbols specified with the second Int64 argument dropping -- before this the first m symbols specified with the first -- Int64 argument. readFileDoublesGenMN :: Int64 -> Int64 -> String -> FilePath -> IO [Int] -- | Converts a lazy ByteString into a list of Int using -- hashStr2. takeDoubles :: ByteString -> [Int] -- | Hashes two lower case ascii characters. Is used for controlling -- frequencies and operators. hashStr2 :: Char -> Char -> Int -- | Auxiliary function to define how is a ByteString treated, see -- readFile2BLGen. convH :: String -> (ByteString -> ByteString) -> ByteString -> ByteString