algorithmic-composition-basic-0.6.0.0: Helps to create experimental music from a file (or its part) and a Ukrainian text.
Copyright(c) OleksandrZhabenko 2020-2021
LicenseMIT
Maintainerolexandr543@yahoo.com
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010
ExtensionsBangPatterns

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.

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

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)

notes :: Array Int Float Source #

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.

closestNote :: Float -> Float Source #

Returns the closest note to the given frequency in Hz.

pureQuintNote :: Float -> Float Source #

Returns a pure quint lower than the given note.

overTones :: Float -> OvertonesO Source #

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

overSoXSynth :: Float -> IO () Source #

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.

Generalized functions

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. @ since 0.2.0.0 removed some extra processment with uncertain semantics.

overSoXSynthGG :: [Float -> Float] -> (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 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).

overSoXSynth3G :: [Float -> Float] -> (Float -> OvertonesO) -> Float -> Float -> IO () Source #

Generalized variant of the overSoXSynthGG with the possibility to set the duration for the generated sound.

overSoXSynth4G :: [Float -> Float] -> (Float -> OvertonesO) -> String -> Float -> Float -> IO () Source #

Generalized variant of the overSoXSynth3G with the possibility to set the sound rate.

Work with enky (extension to octaves functionality)

nkyT :: Int -> NotePairs Source #

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.

whichOctave :: Float -> Maybe Int Source #

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.

whichOctaveG :: Float -> Maybe Int Source #

Generalized version of the whichOctave.

whichEnka :: Int -> Float -> Maybe Int Source #

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

enkuUp :: Int -> Float -> Float Source #

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

enkuDown :: Int -> Float -> Float Source #

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.

liftInEnku :: Int -> Int -> Float -> Maybe Float Source #

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

octavesT :: NotePairs Source #

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. The function works properly only for the amount of the files not greater than several hundreds. If possible, use mixTest function instead.

Working with files

freqsFromFile :: FilePath -> Int -> IO [Int] Source #

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

endFromResult :: IO () Source #

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

dNote :: Int -> Float -> Maybe Float Source #

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. The function works properly only for the amount of the files not greater than several hundreds. If possible, use mixTest2G function instead.

endFromResult2G :: String -> IO () Source #

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

Auxiliary functions

partialTest_k1G :: OvertonesO -> Int -> String -> Array Int Float -> IO () Source #

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

partialTest_k2G :: OvertonesO -> Int -> String -> Array Int Float -> String -> IO () Source #

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.

prependZeroes :: Int -> String -> String Source #

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.

duration1000 :: FilePath -> IO Int Source #

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.