Copyright | (c) OleksandrZhabenko 2020 2024 |
---|---|
License | MIT |
Maintainer | oleksandr.zhabenko@yahoo.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
DobutokO.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 SoundsO = Vector (Float, Float)
- type OvertonesO = Vector (Float, Float)
- type NotePairs = Vector (Float, Float)
- notes :: Vector Float
- neighbourNotes :: Float -> Vector Float -> (Float, Float)
- closestNote :: Float -> Float
- pureQuintNote :: Float -> Float
- overTones :: Float -> OvertonesO
- overSoXSynth :: 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 -> Vector Float -> Vector Float
- liftInEnku :: Int -> Int -> Float -> Maybe Float
- octavesT :: NotePairs
- mixTest :: IO ()
- mixTest2 :: Int -> Int -> IO ()
- freqsFromFile :: FilePath -> Int -> IO (Vector Int)
- endFromResult :: IO ()
- dNote :: Int -> Float -> Maybe Float
- mixTest2G :: String -> IO ()
- mixTest22G :: Int -> Int -> String -> IO ()
- endFromResult2G :: String -> IO ()
- partialTest_k :: OvertonesO -> Int -> String -> IO ()
- partialTest_k1G :: OvertonesO -> Int -> String -> Vector Float -> IO ()
- partialTest_k2G :: OvertonesO -> Int -> String -> Vector Float -> String -> IO ()
- prependZeroes :: Int -> String -> String
- nOfZeroesLog :: Int -> Maybe Int
- numVZeroesPre :: Vector a -> Int
- duration1000 :: FilePath -> IO Int
- adjust_dbVol :: [String] -> Float -> [String]
Type synonyms with different semantics
type SoundsO = Vector (Float, Float) Source #
Is used to represent a sequence of intervals, each note being a Float
value (its frequency in Hz).
type OvertonesO = Vector (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 = Vector (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 -> Vector Float -> (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 Vector
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.
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.
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 (actually frequency) for the n-th elements set of notes (see nkyT
).
An Int
parameter defines that n
.
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.
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
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.
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.
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_k :: OvertonesO -> Int -> String -> IO () Source #
Creates part of the needed "test*.wav" files in the current directory.
partialTest_k1G :: OvertonesO -> Int -> String -> Vector Float -> IO () Source #
Generalized version of the partialTest_k
with the additional volume adjustment in dB given by Vector
of Float
.
partialTest_k2G :: OvertonesO -> Int -> String -> Vector 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 :: Vector a -> Int Source #
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.