algorithmic-composition-basic-0.1.1.0: Helps to create experimental music from a file (or its part) and a Ukrainian text.

Composition.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

# Basic functions to work with intermediate files "result*wav"

Gets sizes of the "result*.wav" files in the current directory.

Similar to getFileRSizes, but sizes are Int, not Integer. For most cases it is more memory efficient.

Variant of getFileRSizes function.

Gets 'Array Int' of tuples of the pairs of "result*.wav" files and their respective sizes.

Gets Array Int of the filenames for "result*.wav" files in the current directory.

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.

Function-predicate to check whether a file corresponding to its String argument is needed to be replaced while processing.

Gets an index of the 'Array Int' element corresponding to the String generated by playAndMark function.

# Functions to edit the melody by editing the intermediate files "result*"

playAndMark :: [FilePath] -> IO [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 Array Int of specially formatted String that represents only those files that are connected with the replacement procedure.

Function playAndMark applied to all the "result*.wav" files in the current directory.

pAnR1 :: [String] -> IO [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 :: [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.

pAnR_ :: IO () Source #

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.

## 2G generalized variants

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 -> [String] -> IO [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 -> [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.

## Get information

infoFromV :: [String] -> [([Int], [String])] Source #

Parser to the result of listVDirectory2G function to get the needed information.

internalConv :: ([String], [String]) -> ([Int], [String]) Source #

Used to obtain parameters for processment.

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.

playSeqARV :: [Int] -> IO () Source #

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.

playSeqARV2 :: [String] -> IO () Source #

Plays a sequence of WAV sounds considered of higher quality.

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 :: [String] -> IO [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 -> [Bool] -> [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 -> [[a]] -> Bool Source #

A predicate to decide whether an element a belongs to the odd number of the lists of a.

maxLinV :: Ord a => [[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 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 Source #

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.

doubleLtoV :: Ord a => [[a]] -> [a] Source #

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.

filterToBnds :: Int -> Int -> [Int] -> [Int] Source #

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.

# 2G generalized functions

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.

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.

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.

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

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

## 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 -> [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 -> [String] -> IO () Source #

Plays a sequence of sounds considered of higher quality.

playCollectDec2G :: String -> [String] -> IO [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 -> [Bool] -> [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

soxE1 :: FilePath -> [String] -> IO () Source #

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.

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).