#include "AIPlane.hxx"
+SGSampleGroup *FGAIPlane::_sgr = 0;
+
FGAIPlane::FGAIPlane() {
leg = LEG_UNKNOWN;
tuned_station = NULL;
_trackSet = false;
_tgtRoll = 0.0;
_rollSuspended = false;
- _sgr = 0;
+
+ if ( !_sgr ) {
+ SGSoundMgr *smgr;
+ smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+ _sgr = smgr->find("atc", true);
+ }
}
FGAIPlane::~FGAIPlane() {
}
void FGAIPlane::Update(double dt) {
- if (!_sgr) {
- SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
- if (smgr) _sgr = smgr->find("atc", true);
- }
-
if(_pending) {
if(tuned_station) {
if(tuned_station->GetFreqClear()) {
double _tgtRoll;
bool _rollSuspended; // Set true when a derived class has suspended AIPlane's roll control
- SGSampleGroup *_sgr;
+ static SGSampleGroup *_sgr;
};
#endif // _FG_AI_PLANE_HXX
_counter(0.0),
_max_count(5.0)
{
+ SGSoundMgr *smgr;
+ smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+ _sgr = smgr->find("atc", true);
}
FGATC::~FGATC() {
new SGSoundSample((unsigned char*) buf.c_str(), buf.length(), 8000);
// TODO - at the moment the volume can't be changed
// after the transmission has started.
- if (!_sgr) {
- SGSoundMgr *smgr;
- smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
- _sgr = smgr->find("atc", true);
- }
simple->set_volume(volume);
_sgr->add(simple, refname);
_sgr->play(refname, repeating);
#include <simgear/misc/interpolator.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/particles.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/timing/lowleveltime.h>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Scripting/NasalSys.hxx>
-#include <Sound/fg_fx.hxx>
-#include <Sound/beacon.hxx>
-#include <Sound/morse.hxx>
#include <Sound/voice.hxx>
#include <Systems/system_mgr.hxx>
#include <Time/light.hxx>
using std::string;
-class Sound;
-class SGSoundMgr;
extern const char *default_root;
float init_volume;
globals->add_subsystem("replay", new FGReplay);
- ////////////////////////////////////////////////////////////////////
- // Add Sound Manager.
- // Put the sound manager last so it can use the CPU while the GPU
- // is processing the scenery (doubled the frame-rate for me) -EMH-
- ////////////////////////////////////////////////////////////////////
-#ifdef ENABLE_AUDIO_SUPPORT
- init_volume = fgGetFloat("/sim/sound/volume");
- fgSetFloat("/sim/sound/volume", 0.0f);
-
- globals->add_subsystem("soundmgr", new SGSoundMgr);
-#endif
-
////////////////////////////////////////////////////////////////////
// Bind and initialize subsystems.
////////////////////////////////////////////////////////////////////
{
frozen = f;
-#if 0
// Stop sound on a pause
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
if ( smgr != NULL ) {
smgr->resume();
}
}
-#endif
}
// update the view angle as late as possible, but before sound calculations
globals->get_viewmgr()->update(real_delta_time_sec);
+ ////////////////////////////////////////////////////////////////////
+ // Update the sound manager last so it can use the CPU while the GPU
+ // is processing the scenery (doubled the frame-rate for me) -EMH-
+ ////////////////////////////////////////////////////////////////////
+#ifdef ENABLE_AUDIO_SUPPORT
+ static SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+ smgr->update_late(delta_time_sec);
+#endif
+
// END Tile Manager udpates
if (!scenery_loaded && globals->get_tile_mgr()->isSceneryLoaded()
&& cur_fdm_state->get_inited()) {
fgSetBool("sim/sceneryloaded",true);
fgSetFloat("/sim/sound/volume", init_volume);
- SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+#ifdef ENABLE_AUDIO_SUPPORT
smgr->set_volume(init_volume);
+#endif
}
fgRequestRedraw();
} else if ( idle_state == 5 ) {
idle_state++;
+#ifdef ENABLE_AUDIO_SUPPORT
+ ////////////////////////////////////////////////////////////////////
+ // Add the Sound Manager before any other subsystem that uses it.
+ // This makes sure the SoundMgr is available at construction time.
+ ////////////////////////////////////////////////////////////////////
+ init_volume = fgGetFloat("/sim/sound/volume");
+ fgSetFloat("/sim/sound/volume", 0.0f);
+ globals->add_subsystem("soundmgr", new SGSoundMgr);
+#endif
+
////////////////////////////////////////////////////////////////////
// Initialize the 3D aircraft model subsystem (has a dependency on
// the scenery subsystem.)
config_list(fgGetNode("/sim", true)->getChildren("view")),
current(0)
{
+ smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
}
// Destructor
abs_viewer_position = loop_view->getViewPosition();
// update audio listener values
- static SGSoundMgr *smgr = 0;
- if (!smgr) smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
- if (smgr) {
- // set the viewer posotion in Cartesian coordinates in meters
- smgr->set_position(abs_viewer_position);
- smgr->set_orientation(loop_view->getViewOrientation());
-//TODO: should be in meters per second
-// smr->set_veloicty(SGVec3f(0,0,0));
- }
+ // set the viewer posotion in Cartesian coordinates in meters
+ smgr->set_position(abs_viewer_position);
+ smgr->set_orientation(loop_view->getViewOrientation());
+ smgr->set_velocity(SGVec3f(0,0,0)); // TODO: in meters per second
}
void
// forward decls
class FGViewer;
+class SGSoundMgr;
typedef SGSharedPtr<FGViewer> FGViewerPtr;
// Define a structure containing view information
int current;
+ SGSoundMgr *smgr;
+
};
_speed_east(0),
_speed_up(0)
{
+ SGSoundMgr *smgr;
+ smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+ _fx = new FGFX(smgr, "fx");
+ _fx->init();
}
FGAircraftModel::~FGAircraftModel ()
_heading->getDoubleValue());
_aircraft->update();
- if ( !_fx) {
- SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
- if (smgr) {
- _fx = new FGFX(smgr, "fx");
- _fx->init();
- }
- }
-
- if (_fx) {
- // Get the Cartesian coordinates in meters
- SGVec3d pos = SGVec3d::fromGeod(_aircraft->getPosition());
- _fx->set_position( pos );
-
- SGQuatd orient_m = SGQuatd::fromLonLat(_aircraft->getPosition());
- orient_m *= SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
- _pitch->getDoubleValue(),
- _roll->getDoubleValue());
- SGVec3d orient = orient_m.rotateBack(SGVec3d::e1());
- _fx->set_orientation( toVec3f(orient) );
+ // update model's sample group values
+ // Get the Cartesian coordinates in meters
+ SGVec3d pos = SGVec3d::fromGeod(_aircraft->getPosition());
+ _fx->set_position( pos );
+
+ SGQuatd orient_m = SGQuatd::fromLonLat(_aircraft->getPosition());
+ orient_m *= SGQuatd::fromYawPitchRollDeg(_heading->getDoubleValue(),
+ _pitch->getDoubleValue(),
+ _roll->getDoubleValue());
+ SGVec3d orient = orient_m.rotateBack(SGVec3d::e1());
+ _fx->set_orientation( toVec3f(orient) );
- SGVec3f vel = SGVec3f( _speed_north->getFloatValue(),
- _speed_east->getFloatValue(),
- _speed_up->getFloatValue());
+ SGVec3f vel = SGVec3f( _speed_north->getFloatValue(),
+ _speed_east->getFloatValue(),
+ _speed_up->getFloatValue());
// TODO: rotate to properly align with the model orientation
- _fx->set_velocity( vel*SG_FEET_TO_METER );
- }
+ _fx->set_velocity( vel*SG_FEET_TO_METER );
}