#include "private.h"
#include <ortp/event.h>
#include <ortp/b64.h>
-
+#include <math.h>
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msvolume.h"
}
void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t muted){
- float mic_gain=lp_config_get_float(lc->config,"sound","mic_gain",1);
+ float mic_gain=lc->sound_conf.soft_mic_lev;
float thres = 0;
float recv_gain;
float ng_thres=lp_config_get_float(lc->config,"sound","ng_thres",0.05);
int dc_removal=lp_config_get_int(lc->config,"sound","dc_removal",0);
if (!muted)
- audio_stream_set_mic_gain(st,mic_gain);
+ linphone_core_set_mic_gain_db (lc, mic_gain);
else
audio_stream_set_mic_gain(st,0);
}
if (st->volrecv){
/* parameters for a limited noise-gate effect, using echo limiter threshold */
- float floorgain = 1/mic_gain;
+ float floorgain = 1/pow(10,(mic_gain)/10);
int spk_agc=lp_config_get_int(lc->config,"sound","speaker_agc_enabled",0);
ms_filter_call_method(st->volrecv, MS_VOLUME_ENABLE_AGC, &spk_agc);
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_THRESHOLD,&ng_thres);
#include "lpconfig.h"
#include "private.h"
+#include <math.h>
#include <ortp/telephonyevents.h>
#include <ortp/zrtp.h>
#include "mediastreamer2/mediastream.h"
int tmp;
const char *tmpbuf;
const char *devid;
- float gain=0;
#ifdef __linux
/*alsadev let the user use custom alsa device within linphone*/
devid=lp_config_get_string(lc->config,"sound","alsadev",NULL);
linphone_core_enable_agc(lc,
lp_config_get_int(lc->config,"sound","agc",0));
- gain=lp_config_get_float(lc->config,"sound","playback_gain_db",0);
- linphone_core_set_playback_gain_db (lc,gain);
+ linphone_core_set_playback_gain_db (lc,lp_config_get_float(lc->config,"sound","playback_gain_db",0));
+ linphone_core_set_mic_gain_db (lc,lp_config_get_float(lc->config,"sound","mic_gain_db",0));
linphone_core_set_remote_ringback_tone (lc,lp_config_get_string(lc->config,"sound","ringback_tone",NULL));
if (sndcard) ms_snd_card_set_level(sndcard,MS_SND_CARD_PLAYBACK,level);
}
+/**
+ * Allow to control microphone level: gain in db
+ *
+ * @ingroup media_parameters
+**/
+void linphone_core_set_mic_gain_db (LinphoneCore *lc, float gaindb){
+ float gain=gaindb;
+ LinphoneCall *call=linphone_core_get_current_call (lc);
+ AudioStream *st;
+
+ lc->sound_conf.soft_mic_lev=gaindb;
+
+ if (call==NULL || (st=call->audiostream)==NULL){
+ ms_message("linphone_core_set_mic_gain_db(): no active call.");
+ return;
+ }
+ if (st->volrecv){
+ ms_filter_call_method(st->volsend,MS_VOLUME_SET_DB_GAIN,&gain);
+ }else ms_warning("Could not apply gain: gain control wasn't activated.");
+}
+
+/**
+ * Get microphone gain in db.
+ *
+ * @ingroup media_parameters
+**/
+float linphone_core_get_mic_gain_db(LinphoneCore *lc) {
+ return lc->sound_conf.soft_mic_lev;
+}
+
/**
* Allow to control play level before entering sound card: gain in db
*
}
if (st!=NULL){
audio_stream_set_mic_gain(st,
- (val==TRUE) ? 0 : lp_config_get_float(lc->config,"sound","mic_gain",1));
+ (val==TRUE) ? 0 : pow(10,lc->sound_conf.soft_mic_lev/10));
if ( linphone_core_get_rtp_no_xmit_on_audio_mute(lc) ){
audio_stream_mute_rtp(st,val);
}
ms_free(config->cards);
lp_config_set_string(lc->config,"sound","remote_ring",config->remote_ring);
+ lp_config_set_float(lc->config,"sound","playback_gain_db",config->soft_play_lev);
+ lp_config_set_float(lc->config,"sound","mic_gain_db",config->soft_mic_lev);
if (config->local_ring) ms_free(config->local_ring);
if (config->remote_ring) ms_free(config->remote_ring);
void linphone_core_set_ring_level(LinphoneCore *lc, int level);
void linphone_core_set_play_level(LinphoneCore *lc, int level);
+void linphone_core_set_mic_gain_db(LinphoneCore *lc, float level);
+float linphone_core_get_mic_gain_db(LinphoneCore *lc);
void linphone_core_set_playback_gain_db(LinphoneCore *lc, float level);
-
float linphone_core_get_playback_gain_db(LinphoneCore *lc);
+
void linphone_core_set_rec_level(LinphoneCore *lc, int level);
const char * linphone_core_get_ringer_device(LinphoneCore *lc);
const char * linphone_core_get_playback_device(LinphoneCore *lc);