mmsyn7ukr-common-0.1.1.0: Some common for mmsyn7ukr and mmsyn7ukr-array functionality using SoX.
Copyright(c) OleksandrZhabenko 2019-2021
LicenseMIT
Maintainerolexandr543@yahoo.com
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010
ExtensionsCpp

Sound.SoXBasics

Description

A program and a library that can be used as a simple basic interface to some SoX functionality.

Synopsis

Encoding file extensions and types functional data type

data ULencode Source #

Constructors

W 
UL1 
UL0 
UL 

Instances

Instances details
Eq ULencode Source # 
Instance details

Defined in Sound.SoXBasics

Ord ULencode Source # 
Instance details

Defined in Sound.SoXBasics

Show ULencode Source # 
Instance details

Defined in Sound.SoXBasics

SoundFileExts ULencode Source # 
Instance details

Defined in Sound.SoXBasics

class SoundFileExts a where Source #

Minimal complete definition

getExts

Instances

Instances details
SoundFileExts ULencode Source # 
Instance details

Defined in Sound.SoXBasics

Working with two extensions

soxOpG :: ULencode -> [String] -> FilePath -> [String] -> FilePath -> [String] -> IO (ExitCode, String, String) Source #

The FilePath cannot be "-n", please, use in such a case a more convinient function soxOpG1.

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.

Some generalized common functions

applyExts2 :: ULencode -> FilePath -> FilePath -> (FilePath, FilePath) Source #

Is partially defined, is used internally here.

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

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

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

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

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

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.

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

Function selMAG 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.

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 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

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.

opFileG :: ULencode -> FilePath -> FilePath -> Float -> Int -> IO () Source #

Function opFileG 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

normG :: ULencode -> 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).

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

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