optek_hifi2_drc_vol.h 4.67 KB
/*
	Optek DRC & VOL
		Copyright by Optek in June 9, 2016
*/

#ifndef _OPTEK_HIFI2_DRC_VOL_H
#define _OPTEK_HIFI2_DRC_VOL_H


/*
	input->no input
	return->string of optek_drc_vol build date,time and version
*/
const char *optek_drc_vol_data_get(void);
const char *optek_drc_vol_time_get(void);
const char *optek_drc_vol_version_get(void);

/*
	input no
	return->how many bytes needed for optek_drc
*/
int optek_drc_vol_alloc(void);

void optek_drc_vol_init (void);



/*
	objmem->mem allocated for optek_drc_vol
	attack_threshold->DRC attack level
	release_threshold->DRC release level, should be < attack_threshold, 
		it is better = attack_threshold * down_rate (for example 1db) and it is better several times (for example 4 or 6) of attack_rate
	attack_rate->in attack phase, drc_vol = drc_vol * attack_rate, it should be < 0db
	release_rate->in release phase, drc_vol = drc_vol * release_rate, it should be > 0db
	lev_detect_release_time->level detect release time, it should be < 0db, 
		it depends on input signal frequency, for example 1kHz signal, 0.04db down is ok, for 100Hz, 0.004db down is ok 
	clipping_enable-> 0 means no clipping, 1 means clipping
	update_samples->DRC update time, about 1ms samples
	return->return optek_drc_vol handle
*/
void * optek_drc_vol_open (void * objmem, int attack_threshold, int release_threshold, int attack_rate, int release_rate, int lev_detect_release_time,
						   uint8_t clipping_enable, uint8_t update_samples);


/*
	handle->optek_drc_vol handle
	master_vol->real vol = master_vol * vol, for different applications
	vol_init_L->int vol for chan L
	vol_init_R->int vol for chan R
	up_rate->soft vol up step, should > 0db, vol* up_rate
	down_rate->soft vol down step, should <0db, vol * down_rate
	post_scale->0, not support post scale; 1, support post scale
	L_R_same_vol->for soft vol, 0 means L/R vol is not same, 1 means L/R vol is same
	return->no return
*/
void optek_drc_vol_open_vol (void * handle, int master_vol, int vol_init_L, int vol_init_R, int up_rate,
							   int down_rate, uint8_t post_scale, uint8_t L_R_same_vol);


/*
	handle->optek_drc_vol handle
	attack_threshold->DRC attack level
	release_threshold->DRC release level, should be < attack_threshold, 
	it is better = attack_threshold * down_rate (for example 1db) and it is better several times (for example 4 or 6) of attack_rate
	attack_rate->in attack phase, drc_vol = drc_vol * attack_rate, it should be < 0db
	release_rate->in release phase, drc_vol = drc_vol * release_rate, it should be > 0db
	lev_detect_release_time->level detect release time, it should be < 0db, 
	it depends on input signal frequency, for example 1kHz signal, 0.04db down is ok, for 100Hz, 0.004db down is ok 
	clipping_enable-> 0 means no clipping, 1 means clipping
	update_samples->DRC update time, about 1ms samples
	attack_hold_samples ->   attack hold time,unit is samples
	return->no return
*/
void optek_drc_vol_set_drc (void *handle,  int attack_threshold, int release_threshold, int attack_rate, int release_rate,
							int lev_detect_release_time,
					 uint8_t clipping_enable, uint8_t update_samples,uint32_t attack_hold_samples);


/*
	handle->optek_drc_vol handle
	return->no return
*/
void optek_drc_vol_set_mute_on (void *handle);

/*
	handle->optek_drc_vol handle
	return->no return
*/
void optek_drc_vol_set_mute_off (void *handle);


/*
	handle->optek_drc_vol handle
	vol_L->L vol
	vol_R->R vol
	return->no return
*/
void optek_drc_vol_set_vol (void *handle, int vol_L, int vol_R);


/*
	handle->optek_drc_vol handle
	master_vol->master vol
	return->no return
*/
void optek_drc_vol_set_master_vol (void *handle, int master_vol);


/*
	handle->optek_drc_vol handle
	update_samples->update time
	return->no return
*/
void optek_drc_vol_set_update_samples (void *handle, int update_samples);

/*
	when opening, vol update time is same with drc update time
	handle->optek_drc_vol handle
	update_samples->update vol_time
	return->no return
*/
void optek_drc_vol_set_vol_update_samples (void *handle, int update_samples);


/*
	handle->optek_drc_vol handle
	up_rate->vol up change rate
	down_rate->vol down change rate
	return->no return
*/
void optek_drc_vol_set_rate (void *handle, int up_rate, int down_rate);

/*
	handle->optek_drc_vol
	x->input
	r->output
	N->samples (L sampes + R samples for stereo)
	return void
*/
//MCPS:3.69 Average: 3.73 Peak: 4.09
void optek_drc_zdt_vol_stereo_24b_process (void *handle, const int *x, int *r, int N) OPTEK_HIFI2_DSP_ATTIB;


/*
	handle->optek_drc_vol
	x->input
	r->output
	N->samples (L sampes + R samples for stereo)
	return void
*/
//MCPS: 2.95 Average: 2.98 Peak: 3.24
void optek_drc_soft_vol_stereo_24b_process (void *handle, const int *x, int *r, int N) OPTEK_HIFI2_DSP_ATTIB;


#endif	//_OPTEK_HIFI2_DRC_VOL_H