Copyright | (c) OleksandrZhabenko 2020 |
---|---|
License | MIT |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
- Type synonyms with different semantics
- Work with notes (general)
- Work with enky (extension to octaves functionality)
- Combining intermediate files
- Working with files
- Work with overtones
- Use additional function as a parameter
- Use additional function and Ukrainian texts and generates melody
- 1G generalized functions with dB volume overtones adjustments
- Generalized functions with several functional parameters
Maintainer : olexandr543@yahoo.com
A program and a library to create experimental music from a mono audio and a Ukrainian text.
Synopsis
- type SoundsO = Vector (Double, Double)
- type OvertonesO = Vector (Double, Double)
- type NotePairs = Vector (Double, Double)
- notes :: Vector Double
- neighbourNotes :: Double -> Vector Double -> (Double, Double)
- closestNote :: Double -> Double
- pureQuintNote :: Double -> Double
- overTones :: Double -> OvertonesO
- nkyT :: Int -> NotePairs
- whichEnka :: Int -> Double -> Maybe Int
- enkuUp :: Int -> Double -> Double
- enkuDown :: Int -> Double -> Double
- liftInEnkuV :: Int -> Int -> Vector Double -> Vector Double
- liftInEnku :: Int -> Int -> Double -> Maybe Double
- octavesT :: NotePairs
- mixTest :: IO ()
- freqsFromFile :: FilePath -> Int -> IO (Vector Int)
- endFromResult :: IO ()
- overSoXSynth :: Double -> IO ()
- overSoXSynth2FDN :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO ()
- overSoXSynth2FDN_B :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- overSoXSynth2FDN_S :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO ()
- overSoXSynth2FDN_Sf :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO ()
- overSoXSynth2FDN_Sf3 :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- overSoXSynthGen2FDN :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO ()
- overSoXSynthGen2FDN_B :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> IO ()
- overSoXSynthGen2FDN_S :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO ()
- overSoXSynthGen2FDN_Sf :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO ()
- overSoXSynthGen2FDN_Sf3 :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> IO ()
- dNote :: Int -> Double -> Maybe Double
- overSoXSynth2FDN1G :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> Vector Double -> IO ()
- overSoXSynth2FDN_B1G :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> Vector Double -> IO ()
- overSoXSynth2FDN_S1G :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> Vector Double -> IO ()
- partialTest_k1G :: OvertonesO -> Int -> String -> Vector Double -> IO ()
- soundGenF3 :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- overSoXSynthGen2FDN_SG :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> ((Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO ()) -> IO ()
- overSoXSynthGen2FDN_Sf3G :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> ((Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()) -> IO ()
- soundGenF31G :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> Vector Double -> IO ()
- adjust_dbVol :: [String] -> Double -> [String]
- partialTest_k :: OvertonesO -> Int -> String -> IO ()
- prependZeroes :: Int -> String -> String
- nOfZeroesLog :: Int -> Maybe Int
- numVZeroesPre :: Vector a -> Int
- syllableStr :: Int -> String -> [Int]
- intervalsFromString :: String -> Vector Int
- vStrToVInt :: Vector String -> Vector Int
- strToInt :: String -> Int
- doubleVecFromVecOfDouble :: (Double -> OvertonesO) -> Double -> Vector (Maybe Double) -> Vector OvertonesO
- helpF1 :: Vector (Double -> Double) -> Vector Double -> Vector Int -> Vector (Maybe Double)
- helpF0 :: Int -> String
Type synonyms with different semantics
type SoundsO = Vector (Double, Double) Source #
Is used to represent a sequence of intervals, each note being a Double
value (its frequency in Hz).
type OvertonesO = Vector (Double, Double) Source #
Is used to represent a set of overtones for the single sound, the first Double
value is a frequency and the second one -- an amplitude.
type NotePairs = Vector (Double, Double) Source #
Is used to represent a set of pairs of notes for each element of which the Double
values (notes frequencies in Hz) are somewhat
musically connected one with another..
Work with notes (general)
neighbourNotes :: Double -> Vector Double -> (Double, Double) 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 :: Double -> Double Source #
Returns the closest note to the given frequency in Hz.
pureQuintNote :: Double -> Double Source #
Returns a pure quint lower than the given note.
overTones :: Double -> OvertonesO Source #
For the given frequency of the note it generates a Vector
of the tuples, each one of which contains the harmonics' frequency and amplitude.
Work with enky (extension to octaves functionality)
nkyT :: Int -> NotePairs Source #
Returns a Vector
of tuples with the lowest and highest frequencies for the notes in the sets consisting of n
consequential notes
(including semi-tones). An Int
parameter 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 Vector
of such sets with
their respective lowest and highest frequencies.
Work with octaves
octavesT :: NotePairs Source #
Returns a Vector
of tuples with the lowest and highest frequencies for the notes in the octaves.
Combining intermediate files
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.
Working with files
freqsFromFile :: FilePath -> Int -> IO (Vector Int) Source #
Gets Vector
of 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.
Work with overtones
overSoXSynth :: Double -> 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.
Use additional function as a parameter
overSoXSynth2FDN :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to overSoXSynth2DN
but instead of overTones
function, it uses volatile function f::Double -> Vector (Double, Double)
with
somewhat sophisticated mechanism to normalize the resulting Vector
elements (Double, Double)
. The last one is an experimental feature, so
it is your responsibility to provide a function so that it does not lead to clipping. In such a case, the result of application of the
convertToProperUkrainian
to the String
parameter must not be empty
. Int
argument is an index of the element to be taken from
the intervalsFromString
applied to the String
argument. To obtain compatible with versions prior to 0.20.0.0 behaviour, use for the Int
0.
Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function. But for a lot of functions this works well.
It is recommended to fully simplify the computation for "f" function before using it in the overSoXSynth2FDN
.
overSoXSynth2FDN_B :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Similar to overSoXSynth2DN
but instead of overTones
function, it uses volatile function f::Double -> Vector (Double, Double)
with
somewhat sophisticated mechanism to normalize the resulting Vector
elements (Double, Double)
. The last one is experimental feature, so
it is your responsibility to provide a function so that it does not lead to clipping. In such a case, the result of application of the
convertToProperUkrainian
to the String
parameter must not be empty
. The function also tries to perform filtering to avoid possible beating.
The third Double
parameter in the tuple is used as a limit for frequencies difference in Hz to be filtered out from the resulting sound. It is
considered to be from the range [0.1..10.0]
. An Int
parameter is used to define the needed interval. To obtain compatible with versions prior
to 0.20.0.0 behaviour, use for the Int
0.
Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function. But for a lot of functions this works well.
It is recommended to fully simplify the computation for "f" function before using it in the overSoXSynth2FDN_B
.
Just simple function application
overSoXSynth2FDN_S :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to overSoXSynth2FDN
but it does not make any normalizing transformations with the Vector
argument. To be used properly, it is needed
that every second element in the tuple in the Vector
argument must be in the range [-1.0..1.0] and every first element must be in between
16.351597831287414 and 7902.132820097988 (Hz). An Int
parameter is used to define an interval. To obtain compatible with versions prior to
0.20.0.0 behaviour, use for the Int
0.
Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function. But for a lot of functions this works well.
It is recommended to fully simplify the computation for "f" function before using it in the overSoXSynth2FDN_S
.
With additional filtering
overSoXSynth2FDN_Sf :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to overSoXSynth2FDN_S
but additionally the program filters out from the resulting Vector
after "f" application values that are smaller
by absolute value than 0.001. An Int
parameter is used to define an interval. To obtain compatible with versions prior to
0.20.0.0 behaviour, use for the Int
0.
Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function. But for a lot of functions this works well.
It is recommended to fully simplify the computation for "f" function before using it in the overSoXSynth2FDN_Sf
.
overSoXSynth2FDN_Sf3 :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Similar to overSoXSynth2FDN_S
but additionally the program filters out from the resulting Vector
after "f" application values that are smaller
than the third Double
parameter by an absolute value in the triple of Double
's. An Int
parameter is used to define an interval. To obtain compatible
with versions prior to 0.20.0.0 behaviour, use for the Int
0.
Be aware that the result can be rather unpredictable (the program can even obtain segmentation fault) for not very suitable function. But for a lot of functions this works well.
It is recommended to fully simplify the computation for "f" function before using it in the overSoXSynth2FDN_Sf3
.
Use additional function and Ukrainian texts and generates melody
overSoXSynthGen2FDN :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO () Source #
Uses additional Int
parameters. The first one is a number of enka (see nkyT
). The second one defines, to which n-th elements set
(see nkyT
) belongs the obtained higher notes in the intervals. To obtain reasonable results, please, use for the first one 2, 3, 4, 6, 9, or 12.
The first String
parameter is used to produce durations of the notes. The second one is used to define intervals. A Double
parameter is a
basic sound duration, it defines tempo of the melody in general.
overSoXSynthGen2FDN_B :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> IO () Source #
Uses additional Int
parameters. The first one is a number of enka (see nkyT
). The second one defines, to which n-th elements set
(see nkyT
) belongs the obtained higher notes in the intervals. To obtain reasonable results, please, use for the first one 2, 3, 4, 6, 9, or 12.
The first String
parameter is used to produce durations of the notes. The second one is used to define intervals. The first Double
parameter is a
basic sound duration, it defines tempo of the melody in general. The second one is a limit for frequencies difference in Hz to be filtered out from the
resulting sound. It is considered to be from the range [0.1..10.0]
.
overSoXSynthGen2FDN_S :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO () Source #
Similar to overSoXSynthGen2FDN
, but instead of overSoXSynth2FDN
uses overSoXSynth2FDN_S
function.
overSoXSynthGen2FDN_Sf :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> IO () Source #
Similar to overSoXSynthGen2FDN_S
, but instead of overSoXSynth2FDN_S
uses overSoXSynth2FDN_Sf
function.
overSoXSynthGen2FDN_Sf3 :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> IO () Source #
Similar to overSoXSynthGen2FDN_S
, but instead of overSoXSynth2FDN_S
uses overSoXSynth2FDN_Sf3
function.
1G generalized functions with dB volume overtones adjustments
overSoXSynth2FDN1G :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> Vector Double -> IO () Source #
overSoXSynth2FDN_B1G :: (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> Vector Double -> IO () Source #
overSoXSynth2FDN_S1G :: (Double -> OvertonesO) -> (Double, Double) -> Int -> String -> Vector Double -> IO () Source #
Generalized version of the overSoXSynth2FDN_S
with the additional volume adjustment in dB for overtones given by Vector
of Double
.
partialTest_k1G :: OvertonesO -> Int -> String -> Vector Double -> IO () Source #
Generalized version of the partialTest_k
with the additional volume adjustment in dB given by Vector
of Double
.
Generalized functions with several functional parameters
soundGenF3 :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Can generate multiple notes with their respective overtones that are played simultaneously (e. g. it can be just one note with overtones, an interval with overtones, an accord with overtones etc.). This allows to get a rather complex or even complicated behaviour to obtain expressive and rich sound.
overSoXSynthGen2FDN_SG :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> String -> String -> ((Double -> OvertonesO) -> (Double, Double) -> Int -> String -> IO ()) -> IO () Source #
Similar to overSoXSynthGen2FDN
, but instead of overSoXSynth2FDN
uses overSoXSynth2FDN_S
function.
overSoXSynthGen2FDN_Sf3G :: FilePath -> Int -> Int -> (Double -> OvertonesO) -> Double -> Double -> String -> String -> ((Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()) -> IO () Source #
Similar to overSoXSynthGen2FDN_S
, but instead of overSoXSynth2FDN_S
uses overSoXSynth2FDN_Sf3
function.
1G generalized function with db volume overtones adjustments and several functional parameters
soundGenF31G :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> OvertonesO) -> (Double, Double, Double) -> Int -> String -> Vector Double -> IO () Source #
Generalized variant of the soundGenF3
with volume adjustment in dB given by the second Vector Double
for the overtones.
Auxiliary functions
adjust_dbVol :: [String] -> Double -> [String] Source #
Is used internally in the readProcessWithExitCode
to adjust volume for the sound with additional dB value given by Double
argument.
partialTest_k :: OvertonesO -> Int -> String -> IO () Source #
Creates part of the needed "test*.wav" files in the current directory.
numVZeroesPre :: Vector a -> Int Source #
syllableStr :: Int -> String -> [Int] Source #
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.
intervalsFromString :: String -> Vector Int Source #
Function is used to get numbers of intervals from a Ukrainian String
. It is used internally in the uniqOverSoXSynthN4
function.
doubleVecFromVecOfDouble :: (Double -> OvertonesO) -> Double -> Vector (Maybe Double) -> Vector OvertonesO Source #
Generates a Vector
of OvertonesO
that represents the sound.