Copyright | (c) OleksandrZhabenko 2020-2021 |
---|---|
License | MIT |
Maintainer | olexandr543@yahoo.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extensions | BangPatterns |
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 SoundsO = Array Int (Float, Float)
- type OvertonesO = [(Float, Float)]
- type NotePairs = Array Int (Float, Float)
- notes :: Array Int Float
- neighbourNotes :: Float -> (Int, Int) -> (Float, Float)
- closestNote :: Float -> Float
- pureQuintNote :: Float -> Float
- overTones :: Float -> OvertonesO
- overTonesALaClarinet :: Float -> OvertonesO
- overSoXSynth :: Float -> IO ()
- overSoXSynthALaClarinet :: Float -> IO ()
- overSoXSynthG :: (Float -> OvertonesO) -> Float -> IO ()
- overSoXSynthGG :: [Float -> Float] -> (Float -> OvertonesO) -> Float -> IO ()
- overSoXSynth3G :: [Float -> Float] -> (Float -> OvertonesO) -> Float -> Float -> IO ()
- overSoXSynth4G :: [Float -> Float] -> (Float -> OvertonesO) -> String -> Float -> Float -> IO ()
- nkyT :: Int -> NotePairs
- whichOctave :: Float -> Maybe Int
- whichOctaveG :: Float -> Maybe Int
- whichEnka :: Int -> Float -> Maybe Int
- enkuUp :: Int -> Float -> Float
- enkuDown :: Int -> Float -> Float
- liftInEnkuV :: Int -> Int -> [Float] -> [Float]
- liftInEnku :: Int -> Int -> Float -> Maybe Float
- octavesT :: NotePairs
- mixTest :: IO ()
- mixTest2 :: Int -> Int -> IO ()
- freqsFromFile :: FilePath -> Int -> IO [Int]
- endFromResult :: IO ()
- dNote :: Int -> Float -> Maybe Float
- mixTest2G :: String -> IO ()
- mixTest22G :: Int -> Int -> String -> IO ()
- endFromResult2G :: String -> IO ()
- partialTest_k1G :: OvertonesO -> Int -> String -> Array Int Float -> IO ()
- partialTest_k2G :: OvertonesO -> Int -> String -> Array Int Float -> String -> IO ()
- prependZeroes :: Int -> String -> String
- nOfZeroesLog :: Int -> Maybe Int
- numVZeroesPre :: [a] -> Int
- duration1000 :: FilePath -> IO Int
- adjust_dbVol :: [String] -> Float -> [String]
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)
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.
overSoXSynthALaClarinet :: Float -> IO () Source #
Similar to overSoXSynth
but uses overTonesALaClarinet
instead of overTones
.
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
.
Work with 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.
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
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 #
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
.
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.