Commit 3f66715d authored by jehan's avatar jehan

add set gain in DB for MSVolume

parent 2e18cdfe
......@@ -173,7 +173,7 @@ void ms_sleep(int seconds);
* The max payload size allowed.
* Filters that generate data that can be sent through RTP should make packets
* whose size is below ms_get_payload_max_size().
* The default value is 1440 computed as the standart internet MTU minus IPv6 header,
* The default value is 1440 computed as the standard internet MTU minus IPv6 header,
* UDP header and RTP header. As IPV4 header is smaller than IPv6 header, this
* value works for both.
*
......
......@@ -58,6 +58,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_VOLUME_SET_NOISE_GATE_FLOORGAIN MS_FILTER_METHOD(MS_VOLUME_ID,12,float)
/* set a gain in db */
#define MS_VOLUME_SET_DB_GAIN MS_FILTER_METHOD(MS_VOLUME_ID,13,float)
extern MSFilterDesc ms_volume_desc;
#endif
......@@ -47,15 +47,17 @@ static void enc_uninit(MSFilter *f){
static void enc_process(MSFilter *f){
EncState *s=(EncState*)f->data;
mblk_t *im;
int16_t buf[160];
int16_t buf[320];
while((im=ms_queue_get(f->inputs[0]))!=NULL){
ms_bufferizer_put(s->bufferizer,im);
}
while(ms_bufferizer_read(s->bufferizer,(uint8_t*)buf,sizeof(buf))==sizeof(buf)) {
mblk_t *om=allocb(33,0);
mblk_t *om=allocb(66,0);
gsm_encode(s->state,(gsm_signal*)buf,(gsm_byte*)om->b_wptr);
om->b_wptr+=33;
gsm_encode(s->state,(gsm_signal*)(buf+160),(gsm_byte*)om->b_wptr);
om->b_wptr+=33;
mblk_set_timestamp_info(om,s->ts);
ms_queue_put(f->outputs[0],om);
s->ts+=sizeof(buf)/2;
......
......@@ -106,7 +106,6 @@ static int volume_get(MSFilter *f, void *arg){
float *farg=(float*)arg;
Volume *v=(Volume*)f->data;
*farg=10*ortp_log10f((v->energy+1)/max_e);
return 0;
}
......@@ -199,6 +198,14 @@ static void volume_noise_gate_process(Volume *v , float energy, mblk_t *om){
}
}
static int volume_set_db_gain(MSFilter *f, void *gain){
float *fgain=(float*)gain;
Volume *v=(Volume*)f->data;
v->gain=v->static_gain=v->target_gain = pow(10,(*fgain)/10);
ms_message("MSVolume set gain to [%f db], [%f] linear",*fgain,v->gain);
return 0;
}
static int volume_set_gain(MSFilter *f, void *arg){
float *farg=(float*)arg;
Volume *v=(Volume*)f->data;
......@@ -391,6 +398,7 @@ static MSFilterMethod methods[]={
{ MS_VOLUME_ENABLE_NOISE_GATE, volume_enable_noise_gate},
{ MS_VOLUME_SET_NOISE_GATE_THRESHOLD, volume_set_noise_gate_threshold},
{ MS_VOLUME_SET_NOISE_GATE_FLOORGAIN, volume_set_noise_gate_floorgain},
{ MS_VOLUME_SET_DB_GAIN , volume_set_db_gain },
{ 0 , NULL }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment