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 obertones
- Use additional function as a parameter
- Use additional function and Ukrainian texts and generates melody
- 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 ObertonesO = Vector (Double, Double)
- type NotePairs = Vector (Double, Double)
- notes :: Vector Double
- neighbourNotes :: Double -> Vector Double -> (Double, Double)
- closestNote :: Double -> Double
- pureQuintNote :: Double -> Double
- oberTones :: Double -> ObertonesO
- 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 ()
- oberSoXSynth :: Double -> IO ()
- oberSoXSynth2FDN :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO ()
- oberSoXSynth2FDN_B :: (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- oberSoXSynth2FDN_S :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO ()
- oberSoXSynth2FDN_Sf :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO ()
- oberSoXSynth2FDN_Sf3 :: (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- oberSoXSynthGen2FDN :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> IO ()
- oberSoXSynthGen2FDN_B :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> Double -> String -> String -> IO ()
- oberSoXSynthGen2FDN_S :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> IO ()
- oberSoXSynthGen2FDN_Sf :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> IO ()
- oberSoXSynthGen2FDN_Sf3 :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> Double -> String -> String -> IO ()
- dNote :: Int -> Double -> Maybe Double
- soundGenF3 :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()
- oberSoXSynthGen2FDN_SG :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> ((Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO ()) -> IO ()
- oberSoXSynthGen2FDN_Sf3G :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> Double -> String -> String -> ((Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()) -> IO ()
- partialTest_k :: ObertonesO -> 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 -> ObertonesO) -> Double -> Vector (Maybe Double) -> Vector ObertonesO
- 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 ObertonesO = Vector (Double, Double) Source #
Is used to represent a set of obertones 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.
oberTones :: Double -> ObertonesO 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 obertones
oberSoXSynth :: 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
oberSoXSynth2FDN :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to oberSoXSynth2DN
but instead of oberTones
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 oberSoXSynth2FDN
.
oberSoXSynth2FDN_B :: (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Similar to oberSoXSynth2DN
but instead of oberTones
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 oberSoXSynth2FDN_B
.
Just simple function application
oberSoXSynth2FDN_S :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to oberSoXSynth2FDN
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 oberSoXSynth2FDN_S
.
With additional filtering
oberSoXSynth2FDN_Sf :: (Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO () Source #
Similar to oberSoXSynth2FDN_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 oberSoXSynth2FDN_Sf
.
oberSoXSynth2FDN_Sf3 :: (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Similar to oberSoXSynth2FDN_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 oberSoXSynth2FDN_Sf3
.
Use additional function and Ukrainian texts and generates melody
oberSoXSynthGen2FDN :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> 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.
oberSoXSynthGen2FDN_B :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> 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]
.
oberSoXSynthGen2FDN_S :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> IO () Source #
Similar to oberSoXSynthGen2FDN
, but instead of oberSoXSynth2FDN
uses oberSoXSynth2FDN_S
function.
oberSoXSynthGen2FDN_Sf :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> IO () Source #
Similar to oberSoXSynthGen2FDN_S
, but instead of oberSoXSynth2FDN_S
uses oberSoXSynth2FDN_Sf
function.
oberSoXSynthGen2FDN_Sf3 :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> Double -> String -> String -> IO () Source #
Similar to oberSoXSynthGen2FDN_S
, but instead of oberSoXSynth2FDN_S
uses oberSoXSynth2FDN_Sf3
function.
Generalized functions with several functional parameters
soundGenF3 :: Vector (Double -> Double) -> Vector Double -> Vector Int -> (Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO () Source #
Can generates multiple notes with their respective obertones that are played simultaneously (e. g. it can be just one note with obertones, an interval with obertones, an accord with obertones etc.). This allows to get a rather complex or even comlicated behaviour to obtain expressive and rich sound.
oberSoXSynthGen2FDN_SG :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> String -> String -> ((Double -> ObertonesO) -> (Double, Double) -> Int -> String -> IO ()) -> IO () Source #
Similar to oberSoXSynthGen2FDN
, but instead of oberSoXSynth2FDN
uses oberSoXSynth2FDN_S
function.
oberSoXSynthGen2FDN_Sf3G :: FilePath -> Int -> Int -> (Double -> ObertonesO) -> Double -> Double -> String -> String -> ((Double -> ObertonesO) -> (Double, Double, Double) -> Int -> String -> IO ()) -> IO () Source #
Similar to oberSoXSynthGen2FDN_S
, but instead of oberSoXSynth2FDN_S
uses oberSoXSynth2FDN_Sf3
function.
Auxiliary functions
partialTest_k :: ObertonesO -> 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 uniqOberSoXSynthN4
function.
doubleVecFromVecOfDouble :: (Double -> ObertonesO) -> Double -> Vector (Maybe Double) -> Vector ObertonesO Source #
Generates a Vector
of ObertonesO
that represents the melody. The order of elements of the vector is the order of the melody.