Play the full 4x VOR and 1x DME morse ident sequence at 30 second intervals.
When you tune into a station start at a "random" point in the sequence. Sped up the words per minute to 13 to which means one sequence per about 4 secs. This means we get through the whole sequence in about 20 seconds leaving 10 seconds of silence.
This commit is contained in:
parent
55e881b83d
commit
6e91c958e3
3 changed files with 108 additions and 15 deletions
|
@ -21,6 +21,8 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
|
#include <simgear/math/sg_random.h>
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Main/bfi.hxx>
|
#include <Main/bfi.hxx>
|
||||||
#include <Navaids/ilslist.hxx>
|
#include <Navaids/ilslist.hxx>
|
||||||
|
@ -29,6 +31,10 @@
|
||||||
|
|
||||||
#include "radiostack.hxx"
|
#include "radiostack.hxx"
|
||||||
|
|
||||||
|
static int nav1_play_count = 0;
|
||||||
|
static time_t nav1_last_time = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boy, this is ugly! Make the VOR range vary by altitude difference.
|
* Boy, this is ugly! Make the VOR range vary by altitude difference.
|
||||||
*/
|
*/
|
||||||
|
@ -257,16 +263,34 @@ FGRadioStack::update()
|
||||||
// play station ident via audio system if on + ident,
|
// play station ident via audio system if on + ident,
|
||||||
// otherwise turn it off
|
// otherwise turn it off
|
||||||
if ( nav1_on_btn && nav1_ident_btn ) {
|
if ( nav1_on_btn && nav1_ident_btn ) {
|
||||||
if ( ! globals->get_soundmgr()->is_playing( "nav1-ident" ) ) {
|
if ( nav1_last_time <
|
||||||
globals->get_soundmgr()->play_once( "nav1-ident" );
|
globals->get_time_params()->get_cur_time() - 30 ) {
|
||||||
|
nav1_last_time = globals->get_time_params()->get_cur_time();
|
||||||
|
nav1_play_count = 0;
|
||||||
|
}
|
||||||
|
if ( nav1_play_count < 4 ) {
|
||||||
|
// play VOR ident
|
||||||
|
if ( !globals->get_soundmgr()->is_playing("nav1-vor-ident") ) {
|
||||||
|
globals->get_soundmgr()->play_once( "nav1-vor-ident" );
|
||||||
|
++nav1_play_count;
|
||||||
|
}
|
||||||
|
} else if ( nav1_play_count < 5 ) {
|
||||||
|
// play DME ident
|
||||||
|
if ( !globals->get_soundmgr()->is_playing("nav1-vor-ident") &&
|
||||||
|
!globals->get_soundmgr()->is_playing("nav1-dme-ident") ) {
|
||||||
|
globals->get_soundmgr()->play_once( "nav1-dme-ident" );
|
||||||
|
++nav1_play_count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals->get_soundmgr()->stop( "nav1-ident" );
|
globals->get_soundmgr()->stop( "nav1-vor-ident" );
|
||||||
|
globals->get_soundmgr()->stop( "nav1-dme-ident" );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nav1_inrange = false;
|
nav1_inrange = false;
|
||||||
nav1_dme_dist = 0.0;
|
nav1_dme_dist = 0.0;
|
||||||
globals->get_soundmgr()->stop( "nav1-ident" );
|
globals->get_soundmgr()->stop( "nav1-vor-ident" );
|
||||||
|
globals->get_soundmgr()->stop( "nav1-dme-ident" );
|
||||||
// cout << "not picking up vor. :-(" << endl;
|
// cout << "not picking up vor. :-(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,12 +409,28 @@ void FGRadioStack::search()
|
||||||
nav1_dme_y = ils.get_dme_y();
|
nav1_dme_y = ils.get_dme_y();
|
||||||
nav1_dme_z = ils.get_dme_z();
|
nav1_dme_z = ils.get_dme_z();
|
||||||
|
|
||||||
if ( globals->get_soundmgr()->exists( "nav1-ident" ) ) {
|
if ( globals->get_soundmgr()->exists( "nav1-vor-ident" ) ) {
|
||||||
globals->get_soundmgr()->remove( "nav1-ident" );
|
globals->get_soundmgr()->remove( "nav1-vor-ident" );
|
||||||
}
|
}
|
||||||
FGSimpleSound *sound = morse.make_ident( nav1_ident );
|
FGSimpleSound *sound;
|
||||||
|
sound = morse.make_ident( nav1_ident, LO_FREQUENCY );
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "nav1-ident" );
|
globals->get_soundmgr()->add( sound, "nav1-vor-ident" );
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav1-dme-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav1-dme-ident" );
|
||||||
|
}
|
||||||
|
sound = morse.make_ident( nav1_ident, HI_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav1-dme-ident" );
|
||||||
|
|
||||||
|
int offset = (int)(sg_random() * 30.0);
|
||||||
|
nav1_play_count = offset / 4;
|
||||||
|
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
|
offset;
|
||||||
|
cout << "offset = " << offset << " play_count = " << nav1_play_count
|
||||||
|
<< " nav1_last_time = " << nav1_last_time << " current time = "
|
||||||
|
<< globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
// cout << "Found an ils station in range" << endl;
|
// cout << "Found an ils station in range" << endl;
|
||||||
// cout << " id = " << ils.get_locident() << endl;
|
// cout << " id = " << ils.get_locident() << endl;
|
||||||
|
@ -415,12 +455,28 @@ void FGRadioStack::search()
|
||||||
nav1_y = nav1_dme_y = nav.get_y();
|
nav1_y = nav1_dme_y = nav.get_y();
|
||||||
nav1_z = nav1_dme_z = nav.get_z();
|
nav1_z = nav1_dme_z = nav.get_z();
|
||||||
|
|
||||||
if ( globals->get_soundmgr()->exists( "nav1-ident" ) ) {
|
if ( globals->get_soundmgr()->exists( "nav1-vor-ident" ) ) {
|
||||||
globals->get_soundmgr()->remove( "nav1-ident" );
|
globals->get_soundmgr()->remove( "nav1-vor-ident" );
|
||||||
}
|
}
|
||||||
FGSimpleSound *sound = morse.make_ident( nav1_ident );
|
FGSimpleSound *sound;
|
||||||
|
sound = morse.make_ident( nav1_ident, LO_FREQUENCY );
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "nav1-ident" );
|
globals->get_soundmgr()->add( sound, "nav1-vor-ident" );
|
||||||
|
|
||||||
|
if ( globals->get_soundmgr()->exists( "nav1-dme-ident" ) ) {
|
||||||
|
globals->get_soundmgr()->remove( "nav1-dme-ident" );
|
||||||
|
}
|
||||||
|
sound = morse.make_ident( nav1_ident, HI_FREQUENCY );
|
||||||
|
sound->set_volume( 0.3 );
|
||||||
|
globals->get_soundmgr()->add( sound, "nav1-dme-ident" );
|
||||||
|
|
||||||
|
int offset = (int)(sg_random() * 30.0);
|
||||||
|
nav1_play_count = offset / 4;
|
||||||
|
nav1_last_time = globals->get_time_params()->get_cur_time() -
|
||||||
|
offset;
|
||||||
|
cout << "offset = " << offset << " play_count = " << nav1_play_count
|
||||||
|
<< " nav1_last_time = " << nav1_last_time << " current time = "
|
||||||
|
<< globals->get_time_params()->get_cur_time() << endl;
|
||||||
|
|
||||||
// cout << "Found a vor station in range" << endl;
|
// cout << "Found a vor station in range" << endl;
|
||||||
// cout << " id = " << nav.get_ident() << endl;
|
// cout << " id = " << nav.get_ident() << endl;
|
||||||
|
@ -430,7 +486,8 @@ void FGRadioStack::search()
|
||||||
nav1_ident = "";
|
nav1_ident = "";
|
||||||
nav1_radial = 0;
|
nav1_radial = 0;
|
||||||
nav1_dme_dist = 0;
|
nav1_dme_dist = 0;
|
||||||
globals->get_soundmgr()->remove( "nav1-ident" );
|
globals->get_soundmgr()->remove( "nav1-vor-ident" );
|
||||||
|
globals->get_soundmgr()->remove( "nav1-dme-ident" );
|
||||||
// cout << "not picking up vor1. :-(" << endl;
|
// cout << "not picking up vor1. :-(" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,42 @@ bool FGMorse::init() {
|
||||||
lo_dah[ i ] = (unsigned char) ( 0.5 * 255.0 ) ;
|
lo_dah[ i ] = (unsigned char) ( 0.5 * 255.0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make High DAH
|
||||||
|
for ( i = 0; i < TRANSITION_BYTES; ++i ) {
|
||||||
|
float level = ( sin( (double) i * 2.0 * M_PI
|
||||||
|
/ (8000.0 / HI_FREQUENCY) ) )
|
||||||
|
* ((double)i / TRANSITION_BYTES) / 2.0 + 0.5;
|
||||||
|
|
||||||
|
/* Convert to unsigned byte */
|
||||||
|
hi_dah[ i ] = (unsigned char) ( level * 255.0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = TRANSITION_BYTES;
|
||||||
|
i < DAH_SIZE - TRANSITION_BYTES - COUNT_SIZE;
|
||||||
|
++i ) {
|
||||||
|
float level = ( sin( (double) i * 2.0 * M_PI
|
||||||
|
/ (8000.0 / HI_FREQUENCY) ) )
|
||||||
|
/ 2.0 + 0.5;
|
||||||
|
|
||||||
|
/* Convert to unsigned byte */
|
||||||
|
hi_dah[ i ] = (unsigned char) ( level * 255.0 ) ;
|
||||||
|
}
|
||||||
|
j = TRANSITION_BYTES;
|
||||||
|
for ( int i = DAH_SIZE - TRANSITION_BYTES - COUNT_SIZE;
|
||||||
|
i < DAH_SIZE - COUNT_SIZE;
|
||||||
|
++i ) {
|
||||||
|
float level = ( sin( (double) i * 2.0 * M_PI
|
||||||
|
/ (8000.0 / HI_FREQUENCY) ) )
|
||||||
|
* ((double)j / TRANSITION_BYTES) / 2.0 + 0.5;
|
||||||
|
--j;
|
||||||
|
|
||||||
|
/* Convert to unsigned byte */
|
||||||
|
hi_dah[ i ] = (unsigned char) ( level * 255.0 ) ;
|
||||||
|
}
|
||||||
|
for ( int i = DAH_SIZE - COUNT_SIZE; i < DAH_SIZE; ++i ) {
|
||||||
|
hi_dah[ i ] = (unsigned char) ( 0.5 * 255.0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
// Make SPACE
|
// Make SPACE
|
||||||
for ( int i = 0; i < SPACE_SIZE; ++i ) {
|
for ( int i = 0; i < SPACE_SIZE; ++i ) {
|
||||||
space[ i ] = (unsigned char) ( 0.5 * 255 ) ;
|
space[ i ] = (unsigned char) ( 0.5 * 255 ) ;
|
||||||
|
|
|
@ -90,8 +90,8 @@ static const char DAH = '2';
|
||||||
static const char end = '0';
|
static const char end = '0';
|
||||||
|
|
||||||
static const int BYTES_PER_SECOND = 8000;
|
static const int BYTES_PER_SECOND = 8000;
|
||||||
static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
|
// static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
|
||||||
// static const int BEAT_LENGTH = 92; // milleseconds (13 wpm)
|
static const int BEAT_LENGTH = 92; // milleseconds (13 wpm)
|
||||||
static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
|
static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
|
||||||
static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
|
static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
|
||||||
static const int DIT_SIZE = 2 * COUNT_SIZE; // 2 counts
|
static const int DIT_SIZE = 2 * COUNT_SIZE; // 2 counts
|
||||||
|
|
Loading…
Add table
Reference in a new issue