_trackSet = false;
_tgtRoll = 0.0;
_rollSuspended = false;
+
+ if ( !_sgr ) {
+ SGSoundMgr *smgr = globals->get_soundmgr();
+ _sgr = smgr->find("atc", true);
+ _sgr->tie_to_listener();
+ }
}
FGAIPlane::~FGAIPlane() {
// For now assume in range !!!
// TODO - implement range checking
// TODO - at the moment the volume is always set off comm1
- double volume = fgGetDouble("/instrumentation/comm[0]/volume");
+ float volume = fgGetFloat("/instrumentation/comm[0]/volume");
Render(plane.callsign, volume, false);
}
}
}
void FGAIPlane::ImmediateTransmit(int callback_code) {
- // TODO - at the moment the volume is always set off comm1
- double volume = fgGetDouble("/instrumentation/comm[0]/volume");
+ // TODO - at the moment the volume is always set off comm1
+ float volume = fgGetFloat("/instrumentation/comm[0]/volume");
+
Render(plane.callsign, volume, false);
if(callback_code) {
ProcessCallback(callback_code);
// Outputs the transmission either on screen or as audio depending on user preference
// The refname is a string to identify this sample to the sound manager
// The repeating flag indicates whether the message should be repeated continuously or played once.
-void FGAIPlane::Render(const string& refname, const double volume, bool repeating) {
+void FGAIPlane::Render(const string& refname, const float volume, bool repeating) {
fgSetString("/sim/messages/ai-plane", pending_transmission.c_str());
#ifdef ENABLE_AUDIO_SUPPORT
voice = (voiceOK && fgGetBool("/sim/sound/voice"));
if(voice) {
- string buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), voice);
- if(voice) {
- SGSoundSample* simple =
- new SGSoundSample((unsigned char*)buf.c_str(), buf.length(), 8000, AL_FORMAT_MONO8 );
- // TODO - at the moment the volume can't be changed
- // after the transmission has started.
+ size_t len;
+ void* buf = vPtr->WriteMessage(pending_transmission, &len);
+ if(voice && (volume > 0.05)) {
+ SGSoundSample* simple = new SGSoundSample(&buf, len, 8000 );
simple->set_volume(volume);
- globals->get_soundmgr()->add(simple, refname);
- if(repeating) {
- globals->get_soundmgr()->play_looped(refname);
- } else {
- globals->get_soundmgr()->play_once(refname);
- }
+ _sgr->add(simple, refname);
+ _sgr->play(refname, repeating);
}
}
#endif // ENABLE_AUDIO_SUPPORT
if(playing) {
if(voice) {
#ifdef ENABLE_AUDIO_SUPPORT
- globals->get_soundmgr()->stop(refname);
- globals->get_soundmgr()->remove(refname);
+ _sgr->stop(refname);
+ _sgr->remove(refname);
#endif
}
playing = false;