mmsyn7ukr-array-0.2.0.0: A simple reduced basic interface to some SoX functionality or to produce a voice that can be used by mmsyn7h-array, dobutokO2-array and other similar packages
Copyright(c) OleksandrZhabenko 2019-2022
LicenseMIT
Maintainerolexandr543@yahoo.com
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010

SoXBasics.Arr

Description

A program and a library that can be used as a simple basic interface to some SoX functionality or for producing the approximately Ukrainian speech with your own recorded voice (actually it produces the needed sound representations).

Synopsis

Get Information

maxAbs :: (String, String) -> (String, Bool) Source #

Function maxAbs allows to choose a maximum by absolute value if the values are written as String. Bool True corresponds to maximum value, False - to minimum value

getMaxA :: FilePath -> (Int, Int) -> IO String Source #

Function getMaxA returns a maximum amplitude of the sound in the file in the given lower and upper bounds represented as a tuple of Int values.

getMinA :: FilePath -> (Int, Int) -> IO String Source #

Function getMinA returns a minimum amplitude of the sound in the file in the given lower and upper bounds represented as a tuple of Int values.

selMaxAbs :: FilePath -> (Int, Int) -> IO (String, Bool) Source #

Function selMaxAbs returns a maximum by absolute value amplitude of the sound and allows by its second value in the tuple determine whether it is a maximum or minimum. Bool True corresponds to maximum value, False - to minimum value.

selMA :: FilePath -> (Int, Int) -> Bool -> IO String Source #

Function selMA returns a maximum or a minimum of the sound amplitude of the file depending on the Bool value given. Bool True corresponds to maximum value, False - to minimum value.

extremeS :: FilePath -> (Int, Int) -> Int -> IO (String, Bool) -> IO Int Source #

Function extremeS returns an approximate sample number of the extremum, which will be used further for fade effect.

extremeS1 :: FilePath -> IO Int Source #

Variant of the function extremeS with all the additional information included.

soxStat :: FilePath -> IO () Source #

Function soxStat prints a SoX statistics for the audio file.

upperBnd :: FilePath -> IO Int Source #

Function upperBnd returns a maximum number of samples for use in other functions.

durationA :: FilePath -> IO Float Source #

Function durationA returns a duration of the audio file in seconds.

sampleAn :: FilePath -> Integer -> IO (String, String) Source #

Function sampleAn analyzes the one samle of the 1-channel sound file (or k samples for the k-channel file) and returns a tuple pair of the maximum and minimum amplitudes of the sound given as Strings. For the 1-channel sound file they are the same. The Integer parameter is the number of the sample, starting from which SoX analyzes the sound. If it is less than number of the samples available, then the function returns the value for the last one sample for the 1-channel file (or the last k samples for the k-channel sound file). The file must not be in a RAW format for the function to work properly.

Produce sound

Trimming the silence

alterVadB :: FilePath -> Float -> Int -> Float -> IO () Source #

Function alterVadB removes an approximate silence measured by the absolute value of the sound amplitude from the beginning of the file. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from). The file must have maximum amplitude absolute value close to 1 before call to the alterVadB. The second Float parameter is used to exit the iteration cycle. The Int parameter from the range [0..3] specifies a maximum amplitude, starting from which the sound will not be trimmed.

alterVadE :: FilePath -> Float -> Int -> Float -> IO () Source #

Function alterVadE removes an approximate silence measured by the absolute value of the sound amplitude from the end of the file. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from). The second Float parameter is used to exit the iteration cycle. The Int parameter from the range [0..3] specifies a maximum amplitude, starting from which the sound will not be trimmed.

alterVadHelp :: FilePath -> Float -> Float -> Int -> Float -> IO () Source #

Function alterVadHelp is used internally in the alterVadB and alterVadE functions.

opFile :: FilePath -> Float -> Int -> IO () Source #

Function opFile is used internally in alterVadB to check whether FilePath exist and if so to do some processing to allow the alterVadB function iterate further.

Amplitude modification

norm :: FilePath -> IO () Source #

Function norm applies a SoX normalization effect on the audio file. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

normL :: FilePath -> Int -> IO () Source #

Function normL applies a SoX gain effect on the audio file with the maximum absolute dB value given by the Int argument. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

gainL :: FilePath -> Float -> IO () Source #

Function normL applies a SoX "gain -b [db-Value]" effect on the audio file with dB value given by the Float argument. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

quarterSinFade :: FilePath -> IO () Source #

Function quarterSinFade applies a fade effect by SoX to the audio file with "q" type. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

Adding silence

silenceBoth :: FilePath -> Int -> Int -> IO () Source #

Function silenceBoth adds some silence to both ends of the audio. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

Recording

recA :: FilePath -> Float -> IO () Source #

Function recA records audio file with the given name and duration in seconds. For Windows it uses a default audio device and "-t waveaudio -d" option to the SoX.

recB :: FilePath -> (Float, Float) -> IO () Source #

Function recB records audio file with the given name and duration in seconds. For Windows it uses a default audio device and "-t waveaudio -d" option to the SoX. Unlike recA, the duration of the pause in seconds (before the SoX executable actually starts to record sound data after an initialization of the sound recording device) is controlled by the second Float function argument.

Changing sample rate

resampleA :: FilePath -> Int -> IO () Source #

Function resampleA changes the sample rate for the recorded audio for further processing. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

Working with noise

noiseProfB :: FilePath -> IO () Source #

Function noiseProfB creates with SoX a file containing a noise profile for the first 0.05 s of the audio file given.

noiseProfE :: FilePath -> IO () Source #

Function noiseProfE creates with SoX a file containing a noise profile for the last 0.05 s of the audio file given.

noiseReduceB :: FilePath -> IO () Source #

Function noiseReduceB reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfB function. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

noiseReduceE :: FilePath -> IO () Source #

Function noiseReduceE reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfE function. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

noiseReduceBU :: FilePath -> Float -> IO () Source #

Function noiseReduceBU reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfBU function. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from). The Float parameter is a number between 0 and 1 showing the level of reducing the noise (the greater number means that the function will reduce more intensively may be even aggressively so that for greater numbers it can remove some sensitive and important sound data as a noise). Internally this parameter is passed unchanged to the "sox" so that it uses it as an amount parameter for the "noisered" effect. Therefore, please, (as being stated in the SoX manual) experiment with the amount to get suitable results.

noiseReduceEU :: FilePath -> Float -> IO () Source #

Function noiseReduceEU reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfEU function. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from). The Float parameter is a number between 0 and 1 showing the level of reducing the noise (the greater number means that the function will reduce more intensively may be even aggressively so that for greater numbers it can remove some sensitive and important sound data as a noise). Internally this parameter is passed unchanged to the "sox" so that it uses it as an amount parameter for the "noisered" effect. Therefore, please, (as being stated in the SoX manual) experiment with the amount to get suitable results.

Filtering

sincA :: FilePath -> IO () Source #

Function sincA uses a "sinc" effect with -a 50 -I 0.07k-11k band-pass filter for the audio file given.

Volume amplification

volS :: FilePath -> Float -> IO () Source #

Function volS changes the given audio with the linear ratio for the amplitude so that the resulting amlitude is equal to the given Float parameter. The function must be used with the FilePath parameter containing no directories in its name (that means the file of the FilePath parameter must be in the same directory where the function is called from).

volS2 :: FilePath -> FilePath -> IO () Source #

Function volS2 changes the given audio (the first FilePath parameter, which must be normalized e. g. by the norm function before) with the linear ratio for the amplitude so that the resulting amlitude is equal to the maximum by absolute value amplitude for the file given by the second FilePath parameter. The function must be used with the first FilePath parameter containing no directories in its name (that means the file of the first FilePath parameter must be in the same directory where the function is called from).

Playing sound

playA :: FilePath -> IO () Source #

Function playA plays the given file with SoX. For Windows it uses "-t waveaudio -d" options for SoX.