The joint programs, written in Scilab 5, implement the algorithms proposed in the paper "Perceptually Controlled Reshaping of Sound Histograms"

**************************************
DESCRIPTION OF THE PACKAGE

The core function implementing the Histogram Global Reshaping (HGR) is in "HGR.sci". An example of use of this function is implemented in "test_sparsification.sce" (and "sparsification.sci"), which can be completed with "appli_ISS.sce". The latter illustrates the use of HGR for source separation.
        
The core function implementing the Histogram Local Reshaping (HLR) is in "HLR.sci". An example of use of this function is implemented in "test_Histogram_LPfiltering.sce" (and "histogram_LPfiltering.sci"), which can be completed with "appli_Quantization.sce". The latter illustrates the use of HLR for application of the quantization theorem.
 
The test programs make use of auxiliary files providing functions that can be replaced by anyone's own functions :
        - "read_wav.sci" / "write_wav.sci" to respectively read and write wav files, using integer values on 16 bits
	- "histograms.sci" to compute histograms
        - "estimationGG_MethMoments.sci" to estimate, through the moments method, the shape parameter of a generalized Gaussian distribution
	- "distances.sci" to compute distances between distributions
        - "QuantizationTheorem.sci" for application of the quantization theorem
	- "silences_processing" to deal with silences in audio signals
	- "AR_models.sci" to estimate the MA model of the masking threshold, block by block
        - "ctrl_audibility" to compute the MA approximation of the masking threshold and control the audibility of a noise colored according to this model minus a given attenuation in dB
	- "bloc_filtering.sci" to filter a signal by a filter with block-varying coefficients
        - "correc_discont.sci" to smooth the discontinuities of z-x at the end of each iteration of HGR/HLR algorithm 

Additionally, 4 scripts display the results as presented in the figures of the paper :
    - "fig_HGR_CDF.sce"
    - "fig_HGR_convergence.sce"
    - "fig_HLR_CharFunction.sce"
    - "fig_HLR_convergence.sce"


*******************************************
RUNNING THE TEST PROGRAMS 

Names of variables below are between _ _
All example audio files are in the sub-directory "audio"

--------------------------------
PRELIMINARY STEPS : define quality assessments
To adjust the masking threshold as indicated in the paper (subsection II.D), you need your own scilab functions implementing PESQ and PEAQ. In the file "ctrl_audibility.sci" :
- correct the paths of the functions at lines 48 and 52
- correct the calls at lines 49 and 53 
Alternatively, you can just ear-check the audio file containing the signal z of Fig 4. In this case, in  "test_Histogram_LPfiltering.sce" or "test_sparsification.sce", in the paramMasking structure, replace 'PESQ' or 'PEAQ' by 'none'.

--------------------------------------
For "test_sparsification.sce", you can 
* either simply run with the default values
* or choose 
	- the name of the input and output files, respectively _file_name_ and _file_name_out_
	- paramHGR (line 52)
	- the target shape parameter in sparsification.sci, line 17
It takes some hours for a 15s file at 32kHz.
If you use audio signals with sampling frequencies different from 32kHz, you will probably need to modify paramMasking and paramDisc.

--------------------------------------
For "appli_ISS.sce",
0) If you don't have sparsified the source signals yet, you can copy sparsified versions (those of the web page) from the sparsifiedSourcesForISS/ directory 
1) Install the FastICA toolbox (with atoms)
2) Keep the default values (for lead_vocal and piano) or run test_sparsification.sce on a pair of tracks, for example among the provided duos:
	- guitar + keyboards
	- guitar_acoustic + guitar_solo
	- voice1 + voice2
and then modify the file names : lines 13 to 16, 30-31, and 41 to 44
2) Choose the mixing matrix A (line 27)
3) Execute

--------------------------------------
For "test_Histogram_LPfiltering.sce", you can 
* either simply run with the default values
* or choose 
	- the name of the input and output files, respectively _file_name_ and _file_name_out_
	- the value of _K_ for the cut-off frequency _fc_ (line 49)
	- paramHLR (line 45)
It takes some minutes for a 3s speech file at 8kHz.
If you use audio signals with sampling frequencies different from 8kHz, you will probably need to modify paramMasking and paramDisc.

-------------------------------------------
For "appli_Quantization.sce"

1) Run "test_Histogram_LPfiltering.sce"
2) Set the file names at lines 16-17
3) Execute




