FGCom: add silence threshold setting
Require commit 1396848dcf31d181ab740c8eb728cff02f06fd3d from fgdata
This commit is contained in:
parent
6adb8b22df
commit
3254f54f9e
4 changed files with 34 additions and 2 deletions
|
@ -117,6 +117,7 @@ void FGCom::bind()
|
|||
_enabled_node = node->getChild( "enabled", 0, true );
|
||||
_micBoost_node = node->getChild( "mic-boost", 0, true );
|
||||
_micLevel_node = node->getChild( "mic-level", 0, true );
|
||||
_silenceThd_node = node->getChild( "silence-threshold", 0, true );
|
||||
_speakerLevel_node = node->getChild( "speaker-level", 0, true );
|
||||
_selectedInput_node = node->getChild( "device-input", 0, true );
|
||||
_selectedOutput_node = node->getChild( "device-output", 0, true );
|
||||
|
@ -153,6 +154,9 @@ void FGCom::bind()
|
|||
if ( !_micLevel_node->hasValue() )
|
||||
_micLevel_node->setFloatValue(1.0);
|
||||
|
||||
if ( !_silenceThd_node->hasValue() )
|
||||
_silenceThd_node->setFloatValue(-20.0);
|
||||
|
||||
if ( !_register_node->hasValue() )
|
||||
_register_node->setBoolValue(false);
|
||||
|
||||
|
@ -168,6 +172,7 @@ void FGCom::bind()
|
|||
_selectedOutput_node->addChangeListener(this);
|
||||
_selectedInput_node->addChangeListener(this);
|
||||
_speakerLevel_node->addChangeListener(this);
|
||||
_silenceThd_node->addChangeListener(this);
|
||||
_micBoost_node->addChangeListener(this);
|
||||
_micLevel_node->addChangeListener(this);
|
||||
_enabled_node->addChangeListener(this);
|
||||
|
@ -232,7 +237,7 @@ void FGCom::postinit()
|
|||
iaxc_set_formats (IAXC_FORMAT_SPEEX, IAXC_FORMAT_ULAW|IAXC_FORMAT_SPEEX);
|
||||
iaxc_set_speex_settings(1, 5, 0, 1, 0, 3);
|
||||
iaxc_set_filters(IAXC_FILTER_AGC | IAXC_FILTER_DENOISE);
|
||||
iaxc_set_silence_threshold(-20.0);
|
||||
iaxc_set_silence_threshold(_silenceThd_node->getFloatValue());
|
||||
iaxc_start_processing_thread ();
|
||||
|
||||
// Now IAXClient is initialized
|
||||
|
@ -445,6 +450,13 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
|||
return;
|
||||
}
|
||||
|
||||
if (prop == _silenceThd_node && _initialized) {
|
||||
float silenceThd = prop->getFloatValue();
|
||||
SG_CLAMP_RANGE<float>( silenceThd, -60, 0 );
|
||||
iaxc_set_silence_threshold( silenceThd );
|
||||
return;
|
||||
}
|
||||
|
||||
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
||||
if (prop == _micBoost_node && _initialized) {
|
||||
int micBoost = prop->getIntValue();
|
||||
|
|
|
@ -55,6 +55,7 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener
|
|||
SGPropertyNode_ptr _username_node; // sim/fgcom/register/username
|
||||
SGPropertyNode_ptr _password_node; // sim/fgcom/register/password
|
||||
SGPropertyNode_ptr _micLevel_node; // sim/fgcom/mic-level
|
||||
SGPropertyNode_ptr _silenceThd_node; // sim/fgcom/silence-threshold
|
||||
SGPropertyNode_ptr _speakerLevel_node; // sim/fgcom/speaker-level
|
||||
SGPropertyNode_ptr _deviceID_node[4]; // sim/fgcom/device[n]/id
|
||||
SGPropertyNode_ptr _deviceName_node[4]; // sim/fgcom/device[n]/name
|
||||
|
|
|
@ -80,6 +80,7 @@ double *special_frequencies;
|
|||
double previous_com_frequency = 0.0;
|
||||
int previous_ptt = 0;
|
||||
float previous_vol = 0.0;
|
||||
float previous_thd = 0.0;
|
||||
int com_select = 0;
|
||||
int max_com_instruments = 2;
|
||||
struct airport *airportlist;
|
||||
|
@ -97,6 +98,7 @@ static const char *audio_in;
|
|||
static const char *audio_out;
|
||||
static double level_in = 0.7;
|
||||
static double level_out = 0.7;
|
||||
static double silence_thd = -20.0;
|
||||
static bool mic_boost;
|
||||
static char codec_option;
|
||||
static const char *callsign;
|
||||
|
@ -130,6 +132,8 @@ static const OptionEntry fgcomOptionArray[] = {
|
|||
"speaker output level (0.0 - 1.0)", 0},
|
||||
{"mic-boost", 'b', false, OPTION_BOOL, &mic_boost, 0, "enable mic boost",
|
||||
0},
|
||||
{"silence-threshold", 't', false, OPTION_DOUBLE, &silence_thd, 0, "set silence threshold (-60.0 - 0.0)",
|
||||
0},
|
||||
{"list-audio", 'l', false, OPTION_BOOL, &list_audio, 0,
|
||||
"list audio devices", 0},
|
||||
{"set-audio-in", 'r', true, OPTION_STRING, &audio_in, 0,
|
||||
|
@ -213,6 +217,15 @@ process_packet (char *buf)
|
|||
previous_vol = data.OUTPUT_VOL;
|
||||
}
|
||||
|
||||
/* Check for silence threshold change */
|
||||
if (previous_thd != data.SILENCE_THD)
|
||||
{
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Set silent threshold to " << data.SILENCE_THD );
|
||||
|
||||
iaxc_set_silence_threshold( data.SILENCE_THD );
|
||||
previous_thd = data.SILENCE_THD;
|
||||
}
|
||||
|
||||
/* Check for callsign change */
|
||||
if (strcmp(callsign, data.CALLSIGN) != 0)
|
||||
{
|
||||
|
@ -451,7 +464,7 @@ main (int argc, char *argv[])
|
|||
iaxc_set_formats (IAXC_FORMAT_SPEEX, IAXC_FORMAT_ULAW|IAXC_FORMAT_SPEEX);
|
||||
iaxc_set_speex_settings(1, 5, 0, 1, 0, 3);
|
||||
iaxc_set_filters(IAXC_FILTER_AGC | IAXC_FILTER_DENOISE);
|
||||
iaxc_set_silence_threshold(-20.0);
|
||||
iaxc_set_silence_threshold(silence_thd);
|
||||
iaxc_set_event_callback (iaxc_callback);
|
||||
|
||||
iaxc_start_processing_thread ();
|
||||
|
@ -1198,6 +1211,11 @@ parse_fgdata (struct fgdata *data, char *buf)
|
|||
data->OUTPUT_VOL = atof (fields[1]);
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "OUTPUT_VOL=" << data->OUTPUT_VOL );
|
||||
}
|
||||
else if (strcmp (fields[0], "SILENCE_THD") == 0)
|
||||
{
|
||||
data->SILENCE_THD = atof (fields[1]);
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "SILENCE_THD=" << data->SILENCE_THD );
|
||||
}
|
||||
else if (strcmp (fields[0], "CALLSIGN") == 0)
|
||||
{
|
||||
data->CALLSIGN = fields[1];
|
||||
|
|
|
@ -124,6 +124,7 @@ struct fgdata
|
|||
int ALT;
|
||||
float HEAD;
|
||||
float OUTPUT_VOL;
|
||||
float SILENCE_THD;
|
||||
char* CALLSIGN;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue