Copyright | (c) OleksandrZhabenko 2019-2021 2024 |
---|---|
License | MIT |
Maintainer | olexandr.zhabenko@yahoo.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
A program and a library that can be used as a simple basic interface to some SoX functionality.
Synopsis
- data ULencode
- class SoundFileExts a where
- soxOpG :: ULencode -> [String] -> FilePath -> [String] -> FilePath -> [String] -> IO (ExitCode, String, String)
- soxOpG1 :: ULencode -> [String] -> FilePath -> [String] -> [String] -> IO (ExitCode, String, String)
- ulAccessParameters :: [String]
- ulResultParameters :: [String]
- doubleCleanCheck :: FilePath -> FinalException -> IO ()
- presenseCheck :: FilePath -> FinalException -> IO ()
- secondFileClean :: FilePath -> FilePath -> FinalException -> IO ()
- twoIntermediateFs :: ExitCode -> FilePath -> FilePath -> FilePath -> FinalException -> IO ()
- twoExceptions1File :: ExitCode -> FilePath -> FinalException -> FinalException -> IO ()
- applyExts2 :: ULencode -> FilePath -> FilePath -> (FilePath, FilePath)
- beforeExtStr :: FilePath -> String
- maxAbs :: (String, String) -> (String, Bool)
- getMaxAG :: ULencode -> FilePath -> (Int, Int) -> IO String
- getMinAG :: ULencode -> FilePath -> (Int, Int) -> IO String
- selMaxAbsG :: ULencode -> FilePath -> (Int, Int) -> IO (String, Bool)
- selMAG :: ULencode -> FilePath -> (Int, Int) -> Bool -> IO String
- extremeSG :: ULencode -> FilePath -> (Int, Int) -> Int -> IO (String, Bool) -> IO Int
- extremeSG1G :: ULencode -> FilePath -> IO Int
- soxStatG :: ULencode -> FilePath -> IO ()
- upperBndG :: ULencode -> FilePath -> IO Int
- durationAG :: ULencode -> FilePath -> IO Float
- sampleAnG :: ULencode -> FilePath -> Integer -> IO (String, String)
- alterVadBG :: ULencode -> FilePath -> Float -> Int -> Float -> IO ()
- alterVadEG :: ULencode -> FilePath -> Float -> Int -> Float -> IO ()
- alterVadHelpG :: ULencode -> FilePath -> Float -> Float -> Int -> Float -> IO ()
- opFileG :: ULencode -> FilePath -> FilePath -> Float -> Int -> IO ()
- normG :: ULencode -> FilePath -> IO ()
- normLG :: ULencode -> FilePath -> Int -> IO ()
- gainLG :: ULencode -> FilePath -> Float -> IO ()
- quarterSinFadeG :: ULencode -> FilePath -> IO ()
- silenceBothG :: ULencode -> FilePath -> Int -> Int -> IO ()
- resampleAG :: ULencode -> FilePath -> Int -> IO ()
- noiseProfBG :: ULencode -> FilePath -> IO ()
- noiseProfEG :: ULencode -> FilePath -> IO ()
- noiseReduceBG :: ULencode -> FilePath -> IO ()
- noiseReduceEG :: ULencode -> FilePath -> IO ()
- noiseReduceBUG :: ULencode -> FilePath -> Float -> IO ()
- noiseReduceEUG :: ULencode -> FilePath -> Float -> IO ()
- sincAG :: ULencode -> FilePath -> IO ()
- volSG :: ULencode -> FilePath -> Float -> IO ()
- volS2G :: ULencode -> FilePath -> FilePath -> IO ()
- getMaxA :: FilePath -> (Int, Int) -> IO String
- getMinA :: FilePath -> (Int, Int) -> IO String
- selMaxAbs :: FilePath -> (Int, Int) -> IO (String, Bool)
- selMA :: FilePath -> (Int, Int) -> Bool -> IO String
- extremeS :: FilePath -> (Int, Int) -> Int -> IO (String, Bool) -> IO Int
- extremeS1 :: FilePath -> IO Int
- soxStat :: FilePath -> IO ()
- upperBnd :: FilePath -> IO Int
- durationA :: FilePath -> IO Float
- sampleAn :: FilePath -> Integer -> IO (String, String)
- alterVadB :: FilePath -> Float -> Int -> Float -> IO ()
- alterVadE :: FilePath -> Float -> Int -> Float -> IO ()
- alterVadHelp :: FilePath -> Float -> Float -> Int -> Float -> IO ()
- opFile :: FilePath -> FilePath -> Float -> Int -> IO ()
- norm :: FilePath -> IO ()
- normL :: FilePath -> Int -> IO ()
- gainL :: FilePath -> Float -> IO ()
- quarterSinFade :: FilePath -> IO ()
- silenceBoth :: FilePath -> Int -> Int -> IO ()
- resampleA :: FilePath -> Int -> IO ()
- noiseProfB :: FilePath -> IO ()
- noiseProfE :: FilePath -> IO ()
- noiseReduceB :: FilePath -> IO ()
- noiseReduceE :: FilePath -> IO ()
- noiseReduceBU :: FilePath -> Float -> IO ()
- noiseReduceEU :: FilePath -> Float -> IO ()
- sincA :: FilePath -> IO ()
- volS :: FilePath -> Float -> IO ()
- volS2 :: FilePath -> FilePath -> IO ()
Encoding file extensions and types functional data type
class SoundFileExts a where Source #
Working with two extensions
soxOpG :: ULencode -> [String] -> FilePath -> [String] -> FilePath -> [String] -> IO (ExitCode, String, String) Source #
soxOpG1 :: ULencode -> [String] -> FilePath -> [String] -> [String] -> IO (ExitCode, String, String) Source #
The variant of the soxOpG
that is used if the second file is not used (or in the situation where some
other file is used, too, e. g. with the .prof extension). For the functions in the module, this corresponds
to the "-n" second file argument.
ulAccessParameters :: [String] Source #
ulResultParameters :: [String] Source #
Some generalized common functions
doubleCleanCheck :: FilePath -> FinalException -> IO () Source #
presenseCheck :: FilePath -> FinalException -> IO () Source #
secondFileClean :: FilePath -> FilePath -> FinalException -> IO () Source #
twoIntermediateFs :: ExitCode -> FilePath -> FilePath -> FilePath -> FinalException -> IO () Source #
twoExceptions1File :: ExitCode -> FilePath -> FinalException -> FinalException -> IO () Source #
applyExts2 :: ULencode -> FilePath -> FilePath -> (FilePath, FilePath) Source #
Is partially defined, is used internally here.
beforeExtStr :: FilePath -> String Source #
Get Information
selMaxAbsG :: ULencode -> FilePath -> (Int, Int) -> IO (String, Bool) Source #
Function selMaxAbsG
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.
extremeSG :: ULencode -> FilePath -> (Int, Int) -> Int -> IO (String, Bool) -> IO Int Source #
Function extremeSG
returns an approximate sample number of the extremum, which will be used further for fade effect.
extremeSG1G :: ULencode -> FilePath -> IO Int Source #
Variant of the function extremeSG
with all the additional information included.
soxStatG :: ULencode -> FilePath -> IO () Source #
Function soxStatG
prints a SoX statistics for the audio file.
upperBndG :: ULencode -> FilePath -> IO Int Source #
Function upperBndG
returns a maximum number of samples for use in other functions.
durationAG :: ULencode -> FilePath -> IO Float Source #
Function durationAG
returns a duration of the audio file in seconds.
sampleAnG :: ULencode -> FilePath -> Integer -> IO (String, String) Source #
Function sampleAnG
analyzes the one sample 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 String
s. 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
alterVadBG :: ULencode -> FilePath -> Float -> Int -> Float -> IO () Source #
Function alterVadBG
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 alterVadBG
.
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.
alterVadEG :: ULencode -> 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.
alterVadHelpG :: ULencode -> FilePath -> Float -> Float -> Int -> Float -> IO () Source #
Function alterVadHelpG
is used internally in the alterVadBG
and alterVadEG
functions.
Amplitude modification
normLG :: ULencode -> FilePath -> Int -> IO () Source #
Function normLG
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).
gainLG :: ULencode -> FilePath -> Float -> IO () Source #
Function normLG
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).
quarterSinFadeG :: ULencode -> FilePath -> IO () Source #
Function quarterSinFadeG
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
silenceBothG :: ULencode -> FilePath -> Int -> Int -> IO () Source #
Function silenceBothG
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).
Changing sample rate
resampleAG :: ULencode -> FilePath -> Int -> IO () Source #
Function resampleAG
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
noiseProfBG :: ULencode -> FilePath -> IO () Source #
Function noiseProfBG
creates with SoX a file containing a noise profile for the first 0.05 s of the audio file given.
noiseProfEG :: ULencode -> FilePath -> IO () Source #
Function noiseProfEG
creates with SoX a file containing a noise profile for the last 0.05 s of the audio file given.
noiseReduceBG :: ULencode -> FilePath -> IO () Source #
Function noiseReduceBG
reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfBG
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).
noiseReduceEG :: ULencode -> FilePath -> IO () Source #
Function noiseReduceEG
reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfEG
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).
noiseReduceBUG :: ULencode -> FilePath -> Float -> IO () Source #
Function noiseReduceBUG
reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfBUG
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.
noiseReduceEUG :: ULencode -> FilePath -> Float -> IO () Source #
Function noiseReduceEUG
reduces with SoX a noise in the file given with the corresponding noise profile created with noiseProfEGU
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
sincAG :: ULencode -> FilePath -> IO () Source #
Function sincAG
uses a "sinc" effect with -a 50 -I 0.07k-11k
band-pass filter for the audio file given.
Volume amplification
volSG :: ULencode -> 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).
volS2G :: ULencode -> FilePath -> FilePath -> IO () Source #
Function volS2G
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).
Variants that uses just .wav files
quarterSinFade :: FilePath -> IO () Source #
noiseProfB :: FilePath -> IO () Source #
noiseProfE :: FilePath -> IO () Source #
noiseReduceB :: FilePath -> IO () Source #
noiseReduceE :: FilePath -> IO () Source #