]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/fgcom.cxx
New PathsDialog, for managing locations.
[flightgear.git] / src / Network / fgcom.cxx
index 6c1095c885ba632bdb7b7ddfcee19d3fac091f88..8d1bfc96c8bb332af58b23ac6677891247fb75f3 100644 (file)
@@ -60,9 +60,7 @@ const int special_freq[] = { // Define some freq who need to be used with NULL_I
        123450,
        122750,
        121500,
-       123500,
-       121000,
-       723340 };
+       123500 };
 
 static FGCom* static_instance = NULL;
 
@@ -119,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 );
@@ -155,6 +154,9 @@ void FGCom::bind()
   if ( !_micLevel_node->hasValue() )
       _micLevel_node->setFloatValue(1.0);
 
+  if ( !_silenceThd_node->hasValue() )
+      _silenceThd_node->setFloatValue(-35.0);
+
   if ( !_register_node->hasValue() )
       _register_node->setBoolValue(false);
 
@@ -170,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);
@@ -231,8 +234,10 @@ void FGCom::postinit()
     app += _version_node->getStringValue();
 
     iaxc_set_callerid( _callsign_node->getStringValue(), app.c_str() );
-    iaxc_set_formats (IAXC_FORMAT_SPEEX, IAXC_FORMAT_SPEEX);
+    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(_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();
@@ -470,7 +482,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
     float speakerLevel = prop->getFloatValue();
     SG_CLAMP_RANGE<float>( speakerLevel, 0.0, 1.0 );
     _speakerLevel_node->setFloatValue(speakerLevel);
-    //iaxc_output_level_set(speakerLevel);
+    iaxc_output_level_set(speakerLevel);
   }
 
   if (prop == _micLevel_node && _enabled) {
@@ -546,7 +558,10 @@ std::string FGCom::getAirportCode(const double& freq)
 
   flightgear::CommStation* apt = flightgear::CommStation::findByFreq(_currentFreqKhz, aircraftPos);
   if( !apt ) {
-    return std::string();
+    apt = flightgear::CommStation::findByFreq(_currentFreqKhz-10, aircraftPos); // Check for 8.33KHz
+    if( !apt ) {
+      return std::string();
+    }
   }
 
   if( apt->type() == FGPositioned::FREQ_TOWER ) {