From 99c54d976aa6d992b650ea935fd923f327628de3 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 16 Mar 2001 05:33:04 +0000 Subject: [PATCH] More tweaks to radio and sound. --- src/Cockpit/radiostack.cxx | 37 +++++++++++++++++++++++++------------ src/Cockpit/radiostack.hxx | 30 +++++++++++++++++++++--------- src/Sound/soundmgr.cxx | 22 +++++++++++++++++----- src/Sound/soundmgr.hxx | 4 ++++ 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 349db3b1d..86e1b80b1 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -128,9 +128,9 @@ FGRadioStack::bind () fgTie("/radios/nav1/radials/selected", this, &FGRadioStack::get_nav1_sel_radial, &FGRadioStack::set_nav1_sel_radial); - fgTie("/radios/nav1/on", this, - &FGRadioStack::get_nav1_on_btn, - &FGRadioStack::set_nav1_on_btn); + fgTie("/radios/nav1/volume", this, + &FGRadioStack::get_nav1_vol_btn, + &FGRadioStack::set_nav1_vol_btn); fgTie("/radios/nav1/ident", this, &FGRadioStack::get_nav1_ident_btn, &FGRadioStack::set_nav1_ident_btn); @@ -156,9 +156,9 @@ FGRadioStack::bind () fgTie("/radios/nav2/radials/selected", this, &FGRadioStack::get_nav2_sel_radial, &FGRadioStack::set_nav2_sel_radial); - fgTie("/radios/nav2/on", this, - &FGRadioStack::get_nav2_on_btn, - &FGRadioStack::set_nav2_on_btn); + fgTie("/radios/nav2/volume", this, + &FGRadioStack::get_nav2_vol_btn, + &FGRadioStack::set_nav2_vol_btn); fgTie("/radios/nav2/ident", this, &FGRadioStack::get_nav2_ident_btn, &FGRadioStack::set_nav2_ident_btn); @@ -183,9 +183,9 @@ FGRadioStack::bind () &FGRadioStack::get_adf_alt_freq, &FGRadioStack::set_adf_alt_freq); fgTie("/radios/adf/rotation", this, &FGRadioStack::get_adf_rotation, &FGRadioStack::set_adf_rotation); - fgTie("/radios/adf/on", this, - &FGRadioStack::get_adf_on_btn, - &FGRadioStack::set_adf_on_btn); + fgTie("/radios/adf/volume", this, + &FGRadioStack::get_adf_vol_btn, + &FGRadioStack::set_adf_vol_btn); fgTie("/radios/adf/ident", this, &FGRadioStack::get_adf_ident_btn, &FGRadioStack::set_adf_ident_btn); @@ -363,7 +363,12 @@ FGRadioStack::update() if ( nav1_valid && nav1_inrange ) { // play station ident via audio system if on + ident, // otherwise turn it off - if ( nav1_on_btn && nav1_ident_btn ) { + if ( nav1_vol_btn > 0.1 && nav1_ident_btn ) { + FGSimpleSound *sound; + sound = globals->get_soundmgr()->find( "nav1-vor-ident" ); + sound->set_volume( nav1_vol_btn * 0.3 ); + sound = globals->get_soundmgr()->find( "nav1-dme-ident" ); + sound->set_volume( nav1_vol_btn * 0.3 ); if ( nav1_last_time < globals->get_time_params()->get_cur_time() - 30 ) { nav1_last_time = globals->get_time_params()->get_cur_time(); @@ -451,7 +456,12 @@ FGRadioStack::update() if ( nav2_valid && nav2_inrange ) { // play station ident via audio system if on + ident, // otherwise turn it off - if ( nav2_on_btn && nav2_ident_btn ) { + if ( nav2_vol_btn > 0.1 && nav2_ident_btn ) { + FGSimpleSound *sound; + sound = globals->get_soundmgr()->find( "nav2-vor-ident" ); + sound->set_volume( nav2_vol_btn * 0.3 ); + sound = globals->get_soundmgr()->find( "nav2-dme-ident" ); + sound->set_volume( nav2_vol_btn * 0.3 ); if ( nav2_last_time < globals->get_time_params()->get_cur_time() - 30 ) { nav2_last_time = globals->get_time_params()->get_cur_time(); @@ -508,7 +518,10 @@ FGRadioStack::update() if ( adf_valid && adf_inrange ) { // play station ident via audio system if on + ident, // otherwise turn it off - if ( adf_on_btn && adf_ident_btn ) { + if ( adf_vol_btn > 0.1 && adf_ident_btn ) { + FGSimpleSound *sound; + sound = globals->get_soundmgr()->find( "adf-ident" ); + sound->set_volume( adf_vol_btn * 0.3 ); if ( adf_last_time < globals->get_time_params()->get_cur_time() - 30 ) { adf_last_time = globals->get_time_params()->get_cur_time(); diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index 0f147c3af..e0bda36c6 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -86,7 +86,7 @@ class FGRadioStack : public FGSubsystem double nav1_heading; double nav1_target_gs; double nav1_magvar; - bool nav1_on_btn; + double nav1_vol_btn; bool nav1_ident_btn; string nav2_ident; @@ -124,7 +124,7 @@ class FGRadioStack : public FGSubsystem double nav2_heading; double nav2_target_gs; double nav2_magvar; - bool nav2_on_btn; + double nav2_vol_btn; bool nav2_ident_btn; string adf_ident; @@ -144,7 +144,7 @@ class FGRadioStack : public FGSubsystem double adf_x; double adf_y; double adf_z; - bool adf_on_btn; + double adf_vol_btn; bool adf_ident_btn; // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8 @@ -176,7 +176,11 @@ public: inline void set_nav1_sel_radial( double radial ) { nav1_sel_radial = radial; need_update = true; } - inline void set_nav1_on_btn( bool val ) { nav1_on_btn = val; } + inline void set_nav1_vol_btn( double val ) { + if ( val < 0.0 ) val = 0.0; + if ( val > 1.0 ) val = 1.0; + nav1_vol_btn = val; + } inline void set_nav1_ident_btn( bool val ) { nav1_ident_btn = val; } // NAV2 Setters @@ -187,7 +191,11 @@ public: inline void set_nav2_sel_radial( double radial ) { nav2_sel_radial = radial; need_update = true; } - inline void set_nav2_on_btn( bool val ) { nav2_on_btn = val; } + inline void set_nav2_vol_btn( double val ) { + if ( val < 0.0 ) val = 0.0; + if ( val > 1.0 ) val = 1.0; + nav2_vol_btn = val; + } inline void set_nav2_ident_btn( bool val ) { nav2_ident_btn = val; } // ADF Setters @@ -196,7 +204,11 @@ public: } inline void set_adf_alt_freq( double freq ) { adf_alt_freq = freq; } inline void set_adf_rotation( double rot ) { adf_rotation = rot; } - inline void set_adf_on_btn( bool val ) { adf_on_btn = val; } + inline void set_adf_vol_btn( double val ) { + if ( val < 0.0 ) val = 0.0; + if ( val > 1.0 ) val = 1.0; + adf_vol_btn = val; + } inline void set_adf_ident_btn( bool val ) { adf_ident_btn = val; } @@ -241,7 +253,7 @@ public: inline double get_nav1_magvar() const { return nav1_magvar; } double get_nav1_heading_needle_deflection() const; double get_nav1_gs_needle_deflection() const; - inline bool get_nav1_on_btn() const { return nav1_on_btn; } + inline double get_nav1_vol_btn() const { return nav1_vol_btn; } inline bool get_nav1_ident_btn() const { return nav1_ident_btn; } inline bool get_nav2_inrange() const { return nav2_inrange; } @@ -269,14 +281,14 @@ public: inline double get_nav2_magvar() const { return nav2_magvar; } double get_nav2_heading_needle_deflection() const; double get_nav2_gs_needle_deflection() const; - inline bool get_nav2_on_btn() const { return nav2_on_btn; } + inline double get_nav2_vol_btn() const { return nav2_vol_btn; } inline bool get_nav2_ident_btn() const { return nav2_ident_btn; } inline bool get_adf_inrange() const { return adf_inrange; } inline double get_adf_lon() const { return adf_lon; } inline double get_adf_lat() const { return adf_lat; } inline double get_adf_heading() const { return adf_heading; } - inline bool get_adf_on_btn() const { return adf_on_btn; } + inline double get_adf_vol_btn() const { return adf_vol_btn; } inline bool get_adf_ident_btn() const { return adf_ident_btn; } }; diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index 5a170e9a4..97a7b0aa7 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -135,8 +135,8 @@ bool FGSoundMgr::remove( const string& refname ) { // audio scheduler) FGSimpleSound *sample = it->second; - cout << "Playing " - << sample->get_sample()->getPlayCount() << " instances!" << endl; + // cout << "Playing " << sample->get_sample()->getPlayCount() + // << " instances!" << endl; audio_sched->stopSample( sample->get_sample() ); audio_sched->addSampleEnvelope( sample->get_sample(), 0, 0, @@ -158,15 +158,15 @@ bool FGSoundMgr::remove( const string& refname ) { // are you going to do? Hopefully the plib team will do a new // stable relase with these problems fixed. - cout << "plib broken audio, skipping actual remove" << endl; + // cout << "plib broken audio, skipping actual remove" << endl; return false; #else // must call audio_sched->update() after stopping the sound // but before deleting it. audio_sched -> update(); - cout << "Still playing " - << sample->get_sample()->getPlayCount() << " instances!" << endl; + // cout << "Still playing " << sample->get_sample()->getPlayCount() + // << " instances!" << endl; delete sample; sounds.erase( it ); @@ -190,6 +190,18 @@ bool FGSoundMgr::exists( const string& refname ) { } +// return a pointer to the FGSimpleSound if the specified sound exists +// in the sound manager system, otherwise return NULL +FGSimpleSound *FGSoundMgr::find( const string& refname ) { + sound_map_iterator it = sounds.find( refname ); + if ( it != sounds.end() ) { + return it->second; + } else { + return NULL; + } +} + + // tell the scheduler to play the indexed sample in a continuous // loop bool FGSoundMgr::play_looped( const string& refname ) { diff --git a/src/Sound/soundmgr.hxx b/src/Sound/soundmgr.hxx index b475aaf0c..547b467bc 100644 --- a/src/Sound/soundmgr.hxx +++ b/src/Sound/soundmgr.hxx @@ -109,6 +109,10 @@ public: // return true of the specified sound exists in the sound manager system bool exists( const string& refname ); + // return a pointer to the FGSimpleSound if the specified sound + // exists in the sound manager system, otherwise return NULL + FGSimpleSound *find( const string& refname ); + // tell the scheduler to play the indexed sample in a continuous // loop bool play_looped( const string& refname ); -- 2.39.5