]> git.mxchange.org Git - flightgear.git/commitdiff
prepare for festival volume
authoradrian <adrian@localhost.com>
Thu, 24 Nov 2011 08:00:28 +0000 (10:00 +0200)
committeradrian <adrian@localhost.com>
Thu, 24 Nov 2011 08:00:28 +0000 (10:00 +0200)
src/ATC/trafficcontrol.cxx
src/CMakeLists.txt
src/Radio/radio.cxx

index 507c8f11388d40ae1a07331929eaace06a1745a6..2b0d20c6793bbe2924c29e13b9d0d084941f8538 100644 (file)
@@ -744,7 +744,8 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent,
                 || (onBoardRadioFreqI1 == stationFreq)) {
             if (rec->allowTransmissions()) {
                
-               if( fgGetBool( "/instrumentation/use-itm-attenuation", false ) ) {
+               if( fgGetBool( "/sim/radio/use-itm-attenuation", false ) ) {
+                       //cerr << "Using ITM radio propagation" << endl;
                        FGRadio* radio = new FGRadio();
                        SGGeod sender_pos;
                        double sender_alt_ft, sender_alt;
@@ -760,7 +761,8 @@ void FGATCController::transmit(FGTrafficRecord * rec, FGAirportDynamics *parent,
                                      sender_pos= SGGeod::fromDegM( rec->getLongitude(),
                                             rec->getLatitude(), sender_alt );
                                }
-                       radio->receiveText(sender_pos, stationFreq, text, ground_to_air);
+                               double frequency = ((double)stationFreq) / 100;
+                       radio->receiveText(sender_pos, frequency, text, ground_to_air);
                        delete radio;
                }
                else {
index f3ebefd912be1bd11c538359004a39626ade4bc9..bf2d6e30d7302e55bfa5e6e2f68ae746914700f1 100644 (file)
@@ -6,9 +6,9 @@ include_directories(${PROJECT_SOURCE_DIR})
 foreach( mylibfolder 
                Airports
                Aircraft
-               Radio
                ATC
                ATCDCL
+               Radio
                Autopilot
                Cockpit
                Environment
index 83068a285f8292ce8878f5a98fa105790a82156c..7e9c4cba9e142d3fc50affeb62ec64490ba1b394 100644 (file)
@@ -76,16 +76,22 @@ double FGRadio::getFrequency(int radio) {
 void FGRadio::receiveText(SGGeod tx_pos, double freq, string text,
        int ground_to_air) {
 
+       /*
        double comm1 = getFrequency(1);
        double comm2 = getFrequency(2);
        if ( (freq != comm1) &&  (freq != comm2) ) {
+               cerr << "Frequency not tuned: " << freq << " Radio1: " << comm1 << " Radio2: " << comm2 << endl;
                return;
        }
        else {
+       */
                double signal = ITM_calculate_attenuation(tx_pos, freq, ground_to_air);
-               if (signal <= 0)
+               //cerr << "Signal: " << signal << endl;
+               if (signal <= 0.0) {
+                       //cerr << "Signal below sensitivity: " << signal << " dBm" << endl;
                        return;
-               if ((signal > 0) && (signal < 12)) {
+               }
+               if ((signal > 0.0) && (signal < 12.0)) {
                        //for low SNR values implement a way to make the conversation
                        //hard to understand but audible
                        //how this works in the real world, is the receiver AGC fails to capture the slope
@@ -94,17 +100,28 @@ void FGRadio::receiveText(SGGeod tx_pos, double freq, string text,
                        //therefore the correct way would be to work on the volume
                        /*
                        string hash_noise = " ";
-                       int reps = fabs((int)signal - 11);
+                       int reps = (int) (fabs(floor(signal - 11.0)) * 2);
+                       cerr << "Reps: " << reps << endl;
                        int t_size = text.size();
-                       for (int n=1;n<=reps * 2;n++) {
-                               int pos = rand() % t_size -1;
+                       for (int n = 1; n <= reps; ++n) {
+                               int pos = rand() % (t_size -1);
+                               cerr << "Pos: " << pos << endl;
                                text.replace(pos,1, hash_noise);
                        }
                        */
-                       
+                       double volume = (fabs(signal - 12.0) / 12);
+                       double old_volume = fgGetDouble("/sim/sound/voices/voice/volume");
+                       //cerr << "Usable signal at limit: " << signal << endl;
+                       fgSetDouble("/sim/sound/voices/voice/volume", volume);
+                       fgSetString("/sim/messages/atc", text.c_str());
+                       fgSetDouble("/sim/sound/voices/voice/volume", old_volume);
                }
-               fgSetString("/sim/messages/atc", text.c_str());
-       }
+               else {
+                       //cerr << "Signal completely readable: " << signal << " dBm" << endl;
+                       fgSetString("/sim/messages/atc", text.c_str());
+               }
+               
+       //}
        
 }
 
@@ -181,9 +198,10 @@ double FGRadio::ITM_calculate_attenuation(SGGeod pos, double freq,
        // If distance larger than this value (300 km), assume reception imposssible 
        if (distance_m > 300000)
                return -1.0;
-       // If above 9000, consider LOS mode and calculate free-space att
-       if (own_alt > 9000) {
+       // If above 8000, consider LOS mode and calculate free-space att
+       if (own_alt > 8000) {
                dbloss = 20 * log10(distance_m) +20 * log10(frq_mhz) -27.55;
+               cerr << "LOS-mode:: Link budget: " << link_budget << ", Attenuation: " << dbloss << " dBm, free-space attenuation" << endl;
                signal = link_budget - dbloss;
                return signal;
        }
@@ -210,7 +228,7 @@ double FGRadio::ITM_calculate_attenuation(SGGeod pos, double freq,
        else
                transmitter_height += Aircraft_HAAT;
        
-       cerr << "ITM:: RX-height: " << receiver_height << ", TX-height: " << transmitter_height << ", Distance: " << distance_m << endl;
+       cerr << "ITM:: RX-height: " << receiver_height << " meters, TX-height: " << transmitter_height << " meters, Distance: " << distance_m << " meters" << endl;
        
        unsigned int e_size = (deque<unsigned>::size_type)max_points;