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

Composition.Sound.Functional.Basics

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. Is more complicated than dobutokO2 and uses its functionality.

Synopsis

# Type synonyms with different semantics

type SoundsO = Array Int (Float, Float) Source #

Is used to represent a sequence of intervals, each note being a Float value (its frequency in Hz).

type OvertonesO = [(Float, Float)] Source #

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.

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

# Work with notes (general)

Array of musical notes in Hz.

neighbourNotes :: Float -> (Int, Int) -> (Float, Float) Source #

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.

Returns the closest note to the given frequency in Hz.

Returns a pure quint lower than the given note.

For the given frequency of the note it generates a list of the tuples, each one of which contains the harmonics' frequency and amplitude.

# Work with overtones

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.

Similar to overSoXSynth but uses overTonesALaClarinet instead of overTones.

## Generalized function

overSoXSynthG :: (Float -> OvertonesO) -> Float -> IO () Source #

Generalized variant of the overSoXSynth with the possibility to set the variant of the overtones for the notes as the first argument.

# Work with enky (extension to octaves functionality)

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.

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.

Generalized version of the whichOctave.

Similarly to whichOctave returns a Maybe number for the n-th elements set of notes (see nkyT). An Int parameter defines that n.

Returns an analogous note in the higher n-th elements set (its frequency in Hz) (see nkyT). An Int parameter defines this n.

Returns an analogous note in the lower n-th elements set (its frequency in Hz) (see nkyT). An Int parameter defines this n.

liftInEnkuV :: Int -> Int -> [Float] -> [Float] Source #

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.

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.

## Work with octaves

Returns a Array Int of tuples with the lowest and highest frequencies for the notes in the octaves.

# Combining intermediate files

mixTest :: IO () Source #

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.

mixTest2 :: Int -> Int -> IO () Source #

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.

# Working with files

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

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.

# Use additional function and Ukrainian texts and generates melody

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.

## 2G generalized auxiliary functions

mixTest2G :: String -> IO () Source #

Similar to mixTest, but allows to change the sound quality parameters for the resulting file. For more information, please, refer to soxBasicParams.

mixTest22G :: Int -> Int -> String -> IO () Source #

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.

Similar to endFromResult, but uses additional String argument to change sound quality parameters. For more information, please, refer to soxBasicParams.

## Auxiliary functions

Generates part of the "test*" files with the additional volume adjustment in dB given by Array Int Float.

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.

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.

numVZeroesPre :: [a] -> Int Source #

Is a minimal number of decimal places that are just enough to represent a length of the list given. For an [] returns 0.

Auxiliary function to get from a sound file specified a duration parameter n that can be used further.

adjust_dbVol :: [String] -> Float -> [String] Source #

Is used internally in the readProcessWithExitCode to adjust volume for the sound with additional dB value given by Float argument.