From cc406602062529086e4e77e07d9234ce059bcf0e Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 4 Dec 2011 21:43:21 +0100 Subject: [PATCH 1/4] Performance improvement Avoid frequently creating/dropping an identical sound sample, when the nav radio signal is flickering. Always keep most recent sound when signal is lost (only stop it/turn volume off). --- src/Instrumentation/kr_87.cxx | 4 +++- src/Sound/audioident.cxx | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Instrumentation/kr_87.cxx b/src/Instrumentation/kr_87.cxx index 0fa58012e..8ea39569c 100644 --- a/src/Instrumentation/kr_87.cxx +++ b/src/Instrumentation/kr_87.cxx @@ -524,7 +524,9 @@ void FGKR_87::search() { xyz = adf->cart(); if ( _sgr->exists( "adf-ident" ) ) { - _sgr->remove( "adf-ident" ); + // stop is required! -- remove alone wouldn't stop immediately + _sgr->stop( "adf-ident" ); + _sgr->remove( "adf-ident" ); } SGSoundSample *sound; sound = FGMorse::instance()->make_ident( trans_ident, FGMorse::LO_FREQUENCY ); diff --git a/src/Sound/audioident.cxx b/src/Sound/audioident.cxx index 782526c9b..829ce9ab6 100644 --- a/src/Sound/audioident.cxx +++ b/src/Sound/audioident.cxx @@ -70,7 +70,15 @@ void AudioIdent::setVolumeNorm( double volumeNorm ) void AudioIdent::setIdent( const std::string & ident, double volumeNorm ) { - if( _ident == ident ) { + // Signal may flicker very frequently (due to our realistic newnavradio...). + // Avoid recreating identical sound samples all the time, instead turn off + // volume when signal is lost, and save the most recent sample. + if (ident.empty()) + volumeNorm = 0; + + if(( _ident == ident )|| + (volumeNorm == 0)) // don't bother with sounds when volume is OFF anyway... + { if( false == _ident.empty() ) setVolumeNorm( volumeNorm ); return; @@ -88,6 +96,7 @@ void AudioIdent::setIdent( const std::string & ident, double volumeNorm ) sound->set_volume( volumeNorm ); if (!_sgr->add( sound, _fx_name )) { SG_LOG(SG_SOUND, SG_WARN, "Failed to add sound '" << _fx_name << "' for ident '" << ident << "'" ); + delete sound; return; } From b61e22bdb3f4adf788d7f817e2ee9693e74c7e81 Mon Sep 17 00:00:00 2001 From: Vivian Meazza Date: Mon, 5 Dec 2011 08:55:33 +0000 Subject: [PATCH 2/4] Windows fixes/work-arounds Signed-off-by: Vivian Meazza --- src/Radio/radio.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Radio/radio.cxx b/src/Radio/radio.cxx index 4c80a9fe5..e5719e0dc 100644 --- a/src/Radio/radio.cxx +++ b/src/Radio/radio.cxx @@ -362,8 +362,10 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i _elevations.push_front(point_distance); _elevations.push_front(num_points -1); - int size = _elevations.size(); - double itm_elev[size]; + + int size = _elevations.size(); + double itm_elev[10000]; + for(int i=0;i Date: Mon, 5 Dec 2011 21:40:01 +0100 Subject: [PATCH 3/4] Fix a typo in the radio propagation code And for sentimental reason: keep the VC90 project file working --- projects/VC90/FlightGear/FlightGear.vcproj | 24 ++++++++++++++++++++++ src/Radio/itm.cpp | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/projects/VC90/FlightGear/FlightGear.vcproj b/projects/VC90/FlightGear/FlightGear.vcproj index 364454c1b..fd2548b0a 100644 --- a/projects/VC90/FlightGear/FlightGear.vcproj +++ b/projects/VC90/FlightGear/FlightGear.vcproj @@ -3198,6 +3198,30 @@ > + + + + + + + + + + + + diff --git a/src/Radio/itm.cpp b/src/Radio/itm.cpp index 1b970d067..184ac3765 100644 --- a/src/Radio/itm.cpp +++ b/src/Radio/itm.cpp @@ -1000,7 +1000,7 @@ double avar(double zzt, double zzl, double zzc, prop_type &prop, propv_type &pro kdv = propv.mdvar; no_situation_variability = kdv >= 20; if (no_situation_variability) - no_situation_variability -= 20; + kdv -= 20; no_location_variability = kdv >= 10; if (no_location_variability) From b7d59463c8da1a6f5e669768e4a17a277eec00c0 Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 6 Dec 2011 02:04:21 +0200 Subject: [PATCH 4/4] Fix error caused by assert statement in itm.cpp --- src/Radio/itm.cpp | 2 +- src/Radio/radio.cxx | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Radio/itm.cpp b/src/Radio/itm.cpp index 1b970d067..28f7004b4 100644 --- a/src/Radio/itm.cpp +++ b/src/Radio/itm.cpp @@ -1378,7 +1378,7 @@ double dlthx(double pfl[], const double &x1, const double &x2) n = 10 * ka - 5; kb = n - ka + 1; sn = n - 1; - assert((s = new double[n+2]) != 0); + s = new double[n+2]; s[0] = sn; s[1] = 1.0; xb = (xb - xa) / sn; diff --git a/src/Radio/radio.cxx b/src/Radio/radio.cxx index 4c80a9fe5..efb5baf53 100644 --- a/src/Radio/radio.cxx +++ b/src/Radio/radio.cxx @@ -236,7 +236,7 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i double own_alt= own_alt_ft * SG_FEET_TO_METER; - //cerr << "ITM:: pilot Lat: " << own_lat << ", Lon: " << own_lon << ", Alt: " << own_alt << endl; + SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt ); SGGeod max_own_pos = SGGeod::fromDegM( own_lon, own_lat, SG_MAX_ELEVATION_M ); @@ -253,7 +253,7 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i sender_alt = sender_alt_ft * SG_FEET_TO_METER; SGGeod max_sender_pos = SGGeod::fromGeodM( pos, SG_MAX_ELEVATION_M ); SGGeoc sender_pos_c = SGGeoc::fromGeod( sender_pos ); - //cerr << "ITM:: sender Lat: " << parent->getLatitude() << ", Lon: " << parent->getLongitude() << ", Alt: " << sender_alt << endl; + double point_distance= _terrain_sampling_distance; double course = SGGeodesy::courseRad(own_pos_c, sender_pos_c); @@ -363,12 +363,13 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i _elevations.push_front(point_distance); _elevations.push_front(num_points -1); int size = _elevations.size(); - double itm_elev[size]; + double *itm_elev; + itm_elev = new double[size]; for(int i=0;isetDoubleValue("station[0]/field-strength-uV", field_strength_uV); _root_node->setDoubleValue("station[0]/signal", signal); _root_node->setDoubleValue("station[0]/tx-erp", tx_erp); + delete[] itm_elev; return signal; }