Changes to go along with small interface changes in simgear/sound/libsgsound
(which is now written on top of OpenAL.)
This commit is contained in:
parent
4e14316256
commit
df472fe0f5
17 changed files with 84 additions and 69 deletions
14
configure.ac
14
configure.ac
|
@ -314,7 +314,21 @@ esac
|
||||||
opengl_LIBS="$LIBS"
|
opengl_LIBS="$LIBS"
|
||||||
LIBS="$base_LIBS"
|
LIBS="$base_LIBS"
|
||||||
|
|
||||||
|
dnl check for OpenAL libraries
|
||||||
|
case "${host}" in
|
||||||
|
*)
|
||||||
|
dnl default unix style machines
|
||||||
|
|
||||||
|
AC_SEARCH_LIBS(alGenBuffers, openal)
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
openal_LIBS="$LIBS"
|
||||||
|
LIBS="$base_LIBS"
|
||||||
|
|
||||||
AC_SUBST(base_LIBS)
|
AC_SUBST(base_LIBS)
|
||||||
|
AC_SUBST(openal_LIBS)
|
||||||
AC_SUBST(opengl_LIBS)
|
AC_SUBST(opengl_LIBS)
|
||||||
AC_SUBST(thread_LIBS)
|
AC_SUBST(thread_LIBS)
|
||||||
AC_SUBST(network_LIBS)
|
AC_SUBST(network_LIBS)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <simgear/math/point3d.hxx>
|
#include <simgear/math/point3d.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/sound/soundmgr.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
SG_USING_STD(string);
|
SG_USING_STD(string);
|
||||||
|
@ -189,7 +189,7 @@ void FGAIPlane::Render(string refname, bool repeating) {
|
||||||
int len;
|
int len;
|
||||||
unsigned char* buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), len, voice);
|
unsigned char* buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), len, voice);
|
||||||
if(voice) {
|
if(voice) {
|
||||||
SGSimpleSound* simple = new SGSimpleSound(buf, len);
|
SGSoundSample* simple = new SGSoundSample(buf, len, 8000);
|
||||||
// TODO - at the moment the volume is always set off comm1
|
// TODO - at the moment the volume is always set off comm1
|
||||||
// and can't be changed after the transmission has started.
|
// and can't be changed after the transmission has started.
|
||||||
simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
|
simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/sound/soundmgr.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
@ -223,7 +223,7 @@ void FGATC::Render(string msg, string refname, bool repeating) {
|
||||||
int len;
|
int len;
|
||||||
unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
|
unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
|
||||||
if(voice) {
|
if(voice) {
|
||||||
SGSimpleSound* simple = new SGSimpleSound(buf, len);
|
SGSoundSample* simple = new SGSoundSample(buf, len, 8000);
|
||||||
// TODO - at the moment the volume is always set off comm1
|
// TODO - at the moment the volume is always set off comm1
|
||||||
// and can't be changed after the transmission has started.
|
// and can't be changed after the transmission has started.
|
||||||
simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
|
simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
|
||||||
|
|
|
@ -37,21 +37,25 @@ FGATCVoice::FGATCVoice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FGATCVoice::~FGATCVoice() {
|
FGATCVoice::~FGATCVoice() {
|
||||||
delete SoundData;
|
// delete SoundData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
|
// Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
|
||||||
// Return true if successful.
|
// Return true if successful.
|
||||||
bool FGATCVoice::LoadVoice(string voice) {
|
bool FGATCVoice::LoadVoice(string voice) {
|
||||||
|
// FIXME CLO: disabled to try to see if this is causign problemcs
|
||||||
|
// return false;
|
||||||
|
|
||||||
ifstream fin;
|
ifstream fin;
|
||||||
|
|
||||||
SGPath path = globals->get_fg_root();
|
SGPath path = globals->get_fg_root();
|
||||||
string soundPath = "ATC/" + voice + ".wav";
|
path.append( "ATC" );
|
||||||
path.append(soundPath);
|
|
||||||
|
|
||||||
SoundData = new slSample( (char*)path.c_str() );
|
string file = voice + ".wav";
|
||||||
rawDataSize = SoundData->getLength();
|
|
||||||
rawSoundData = (char*)SoundData->getBuffer();
|
SoundData = new SGSoundSample( path.c_str(), file.c_str() );
|
||||||
|
rawDataSize = SoundData->get_size();
|
||||||
|
rawSoundData = SoundData->get_data();
|
||||||
|
|
||||||
path = globals->get_fg_root();
|
path = globals->get_fg_root();
|
||||||
string wordPath = "ATC/" + voice + ".vce";
|
string wordPath = "ATC/" + voice + ".vce";
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#ifndef _FG_ATC_VOICE
|
#ifndef _FG_ATC_VOICE
|
||||||
#define _FG_ATC_VOICE
|
#define _FG_ATC_VOICE
|
||||||
|
|
||||||
#include <plib/sl.h>
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
#if defined( SG_HAVE_STD_INCLUDES ) || defined( __BORLANDC__ ) || (__APPLE__)
|
#if defined( SG_HAVE_STD_INCLUDES ) || defined( __BORLANDC__ ) || (__APPLE__)
|
||||||
|
@ -37,6 +35,8 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <simgear/sound/sample_openal.hxx>
|
||||||
|
|
||||||
SG_USING_STD(map);
|
SG_USING_STD(map);
|
||||||
SG_USING_STD(list);
|
SG_USING_STD(list);
|
||||||
SG_USING_STD(string);
|
SG_USING_STD(string);
|
||||||
|
@ -77,7 +77,7 @@ private:
|
||||||
// the sound and word position data
|
// the sound and word position data
|
||||||
char* rawSoundData;
|
char* rawSoundData;
|
||||||
unsigned int rawDataSize;
|
unsigned int rawDataSize;
|
||||||
slSample* SoundData;
|
SGSoundSample *SoundData;
|
||||||
|
|
||||||
// A map of words vs. byte position and length in rawSoundData
|
// A map of words vs. byte position and length in rawSoundData
|
||||||
atc_word_map_type wordMap;
|
atc_word_map_type wordMap;
|
||||||
|
|
|
@ -444,7 +444,7 @@ void FGKR_87::update( double dt ) {
|
||||||
// play station ident via audio system if on + ant mode,
|
// play station ident via audio system if on + ant mode,
|
||||||
// otherwise turn it off
|
// otherwise turn it off
|
||||||
if ( vol_btn >= 0.01 && audio_btn ) {
|
if ( vol_btn >= 0.01 && audio_btn ) {
|
||||||
SGSimpleSound *sound;
|
SGSoundSample *sound;
|
||||||
sound = globals->get_soundmgr()->find( "adf-ident" );
|
sound = globals->get_soundmgr()->find( "adf-ident" );
|
||||||
if ( sound != NULL ) {
|
if ( sound != NULL ) {
|
||||||
if ( !adf_btn ) {
|
if ( !adf_btn ) {
|
||||||
|
@ -513,7 +513,7 @@ void FGKR_87::search() {
|
||||||
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
|
if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
|
||||||
globals->get_soundmgr()->remove( "adf-ident" );
|
globals->get_soundmgr()->remove( "adf-ident" );
|
||||||
}
|
}
|
||||||
SGSimpleSound *sound;
|
SGSoundSample *sound;
|
||||||
sound = morse.make_ident( trans_ident, LO_FREQUENCY );
|
sound = morse.make_ident( trans_ident, LO_FREQUENCY );
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "adf-ident" );
|
globals->get_soundmgr()->add( sound, "adf-ident" );
|
||||||
|
|
|
@ -192,7 +192,7 @@ void FGMarkerBeacon::search()
|
||||||
// cout << "OUTER MARKER" << endl;
|
// cout << "OUTER MARKER" << endl;
|
||||||
if ( last_beacon != FGMkrBeacon::OUTER ) {
|
if ( last_beacon != FGMkrBeacon::OUTER ) {
|
||||||
if ( ! globals->get_soundmgr()->exists( "outer-marker" ) ) {
|
if ( ! globals->get_soundmgr()->exists( "outer-marker" ) ) {
|
||||||
SGSimpleSound *sound = beacon.get_outer();
|
SGSoundSample *sound = beacon.get_outer();
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "outer-marker" );
|
globals->get_soundmgr()->add( sound, "outer-marker" );
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ void FGMarkerBeacon::search()
|
||||||
// cout << "MIDDLE MARKER" << endl;
|
// cout << "MIDDLE MARKER" << endl;
|
||||||
if ( last_beacon != FGMkrBeacon::MIDDLE ) {
|
if ( last_beacon != FGMkrBeacon::MIDDLE ) {
|
||||||
if ( ! globals->get_soundmgr()->exists( "middle-marker" ) ) {
|
if ( ! globals->get_soundmgr()->exists( "middle-marker" ) ) {
|
||||||
SGSimpleSound *sound = beacon.get_middle();
|
SGSoundSample *sound = beacon.get_middle();
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "middle-marker" );
|
globals->get_soundmgr()->add( sound, "middle-marker" );
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void FGMarkerBeacon::search()
|
||||||
// cout << "INNER MARKER" << endl;
|
// cout << "INNER MARKER" << endl;
|
||||||
if ( last_beacon != FGMkrBeacon::INNER ) {
|
if ( last_beacon != FGMkrBeacon::INNER ) {
|
||||||
if ( ! globals->get_soundmgr()->exists( "inner-marker" ) ) {
|
if ( ! globals->get_soundmgr()->exists( "inner-marker" ) ) {
|
||||||
SGSimpleSound *sound = beacon.get_inner();
|
SGSoundSample *sound = beacon.get_inner();
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, "inner-marker" );
|
globals->get_soundmgr()->add( sound, "inner-marker" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ FGNavCom::update(double dt)
|
||||||
if ( power_btn && (bus_power->getDoubleValue() > 1.0)
|
if ( power_btn && (bus_power->getDoubleValue() > 1.0)
|
||||||
&& nav_ident_btn && audio_btn )
|
&& nav_ident_btn && audio_btn )
|
||||||
{
|
{
|
||||||
SGSimpleSound *sound;
|
SGSoundSample *sound;
|
||||||
sound = globals->get_soundmgr()->find( nav_fx_name );
|
sound = globals->get_soundmgr()->find( nav_fx_name );
|
||||||
if ( sound != NULL ) {
|
if ( sound != NULL ) {
|
||||||
sound->set_volume( nav_vol_btn );
|
sound->set_volume( nav_vol_btn );
|
||||||
|
@ -653,7 +653,7 @@ void FGNavCom::search()
|
||||||
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
|
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
|
||||||
globals->get_soundmgr()->remove( nav_fx_name );
|
globals->get_soundmgr()->remove( nav_fx_name );
|
||||||
}
|
}
|
||||||
SGSimpleSound *sound;
|
SGSoundSample *sound;
|
||||||
sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
|
sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
globals->get_soundmgr()->add( sound, nav_fx_name );
|
globals->get_soundmgr()->add( sound, nav_fx_name );
|
||||||
|
@ -703,7 +703,7 @@ void FGNavCom::search()
|
||||||
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
|
if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
|
||||||
globals->get_soundmgr()->remove( nav_fx_name );
|
globals->get_soundmgr()->remove( nav_fx_name );
|
||||||
}
|
}
|
||||||
SGSimpleSound *sound;
|
SGSoundSample *sound;
|
||||||
sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
|
sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
|
||||||
sound->set_volume( 0.3 );
|
sound->set_volume( 0.3 );
|
||||||
if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
|
if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ fgfs_LDADD = \
|
||||||
$(network_LIBS) \
|
$(network_LIBS) \
|
||||||
-lz \
|
-lz \
|
||||||
$(opengl_LIBS) \
|
$(opengl_LIBS) \
|
||||||
$(audio_LIBS)
|
$(openal_LIBS)
|
||||||
|
|
||||||
metar_SOURCES = metar_main.cxx
|
metar_SOURCES = metar_main.cxx
|
||||||
|
|
||||||
|
|
|
@ -1622,6 +1622,24 @@ bool fgInitSubsystems() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Initialize the sound subsystem.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
globals->set_soundmgr(new SGSoundMgr);
|
||||||
|
globals->get_soundmgr()->init();
|
||||||
|
globals->get_soundmgr()->bind();
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Initialize the sound-effects subsystem.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
globals->add_subsystem("fx", new FGFX);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialise ATC display system
|
// Initialise ATC display system
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1646,7 +1664,6 @@ bool fgInitSubsystems() {
|
||||||
globals->set_AI_mgr(new FGAIMgr);
|
globals->set_AI_mgr(new FGAIMgr);
|
||||||
globals->get_AI_mgr()->init();
|
globals->get_AI_mgr()->init();
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialise the AI Model Manager
|
// Initialise the AI Model Manager
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1655,24 +1672,6 @@ bool fgInitSubsystems() {
|
||||||
globals->add_subsystem("ai_model", new FGAIManager);
|
globals->add_subsystem("ai_model", new FGAIManager);
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Initialize the sound subsystem.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
globals->set_soundmgr(new SGSoundMgr);
|
|
||||||
globals->get_soundmgr()->init();
|
|
||||||
globals->get_soundmgr()->bind();
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Initialize the sound-effects subsystem.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
globals->add_subsystem("fx", new FGFX);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
globals->add_subsystem("instrumentation", new FGInstrumentMgr);
|
globals->add_subsystem("instrumentation", new FGInstrumentMgr);
|
||||||
globals->add_subsystem("systems", new FGSystemMgr);
|
globals->add_subsystem("systems", new FGSystemMgr);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <simgear/timing/sg_time.hxx>
|
#include <simgear/timing/sg_time.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/sound/soundmgr.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
|
||||||
#include STL_IOSTREAM
|
#include STL_IOSTREAM
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool FGBeacon::init() {
|
||||||
ptr += INNER_DIT_LEN;
|
ptr += INNER_DIT_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
inner = new SGSimpleSound( inner_buf, INNER_SIZE );
|
inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND );
|
||||||
|
|
||||||
// Make middle marker beacon sound
|
// Make middle marker beacon sound
|
||||||
len= (int)(MIDDLE_DIT_LEN / 2.0 );
|
len= (int)(MIDDLE_DIT_LEN / 2.0 );
|
||||||
|
@ -69,7 +69,7 @@ bool FGBeacon::init() {
|
||||||
ptr += MIDDLE_DIT_LEN;
|
ptr += MIDDLE_DIT_LEN;
|
||||||
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
|
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
|
||||||
|
|
||||||
middle = new SGSimpleSound( middle_buf, MIDDLE_SIZE );
|
middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND );
|
||||||
|
|
||||||
// Make outer marker beacon sound
|
// Make outer marker beacon sound
|
||||||
len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 );
|
len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 );
|
||||||
|
@ -82,7 +82,7 @@ bool FGBeacon::init() {
|
||||||
ptr += OUTER_DAH_LEN;
|
ptr += OUTER_DAH_LEN;
|
||||||
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
||||||
|
|
||||||
outer = new SGSimpleSound( outer_buf, OUTER_SIZE );
|
outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/sound/soundmgr.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
|
||||||
#include <plib/sl.h>
|
#include <plib/sl.h>
|
||||||
#include <plib/sm.h>
|
#include <plib/sm.h>
|
||||||
|
@ -100,9 +100,9 @@ private:
|
||||||
unsigned char middle_buf[ MIDDLE_SIZE ] ;
|
unsigned char middle_buf[ MIDDLE_SIZE ] ;
|
||||||
unsigned char outer_buf[ OUTER_SIZE ] ;
|
unsigned char outer_buf[ OUTER_SIZE ] ;
|
||||||
|
|
||||||
SGSimpleSound *inner;
|
SGSoundSample *inner;
|
||||||
SGSimpleSound *middle;
|
SGSoundSample *middle;
|
||||||
SGSimpleSound *outer;
|
SGSoundSample *outer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -112,9 +112,9 @@ public:
|
||||||
// allocate and initialize sound samples
|
// allocate and initialize sound samples
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
SGSimpleSound *get_inner() { return inner; }
|
SGSoundSample *get_inner() { return inner; }
|
||||||
SGSimpleSound *get_middle() { return middle; }
|
SGSoundSample *get_middle() { return middle; }
|
||||||
SGSimpleSound *get_outer() { return outer; }
|
SGSoundSample *get_outer() { return outer; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/sound/sound.hxx>
|
#include <simgear/sound/xmlsound.hxx>
|
||||||
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ FGFX::init()
|
||||||
|
|
||||||
node = root.getNode("fx");
|
node = root.getNode("fx");
|
||||||
for (i = 0; i < node->nChildren(); i++) {
|
for (i = 0; i < node->nChildren(); i++) {
|
||||||
SGSound *sound = new SGSound();
|
SGXmlSound *sound = new SGXmlSound();
|
||||||
|
|
||||||
sound->init(globals->get_props(), node->getChild(i),
|
sound->init(globals->get_props(), node->getChild(i),
|
||||||
globals->get_soundmgr(), globals->get_fg_root());
|
globals->get_soundmgr(), globals->get_fg_root());
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
class SGSound;
|
class SGXmlSound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generator for FlightGear sound effects.
|
* Generator for FlightGear sound effects.
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
vector<SGSound *> _sound;
|
vector<SGXmlSound *> _sound;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ void make_tone( unsigned char *buf, int freq,
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for ( i = 0; i < trans_len; ++i ) {
|
for ( i = 0; i < trans_len; ++i ) {
|
||||||
float level = ( sin( (double) i * 2.0 * SGD_PI / (8000.0 / freq) ) )
|
float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
|
||||||
* ((double)i / trans_len) / 2.0 + 0.5;
|
* ((double)i / trans_len) / 2.0 + 0.5;
|
||||||
|
|
||||||
/* Convert to unsigned byte */
|
/* Convert to unsigned byte */
|
||||||
|
@ -95,7 +95,7 @@ void make_tone( unsigned char *buf, int freq,
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = trans_len; i < len - trans_len; ++i ) {
|
for ( i = trans_len; i < len - trans_len; ++i ) {
|
||||||
float level = ( sin( (double) i * 2.0 * SGD_PI / (8000.0 / freq) ) )
|
float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
|
||||||
/ 2.0 + 0.5;
|
/ 2.0 + 0.5;
|
||||||
|
|
||||||
/* Convert to unsigned byte */
|
/* Convert to unsigned byte */
|
||||||
|
@ -103,7 +103,7 @@ void make_tone( unsigned char *buf, int freq,
|
||||||
}
|
}
|
||||||
j = trans_len;
|
j = trans_len;
|
||||||
for ( i = len - trans_len; i < len; ++i ) {
|
for ( i = len - trans_len; i < len; ++i ) {
|
||||||
float level = ( sin( (double) i * 2.0 * SGD_PI / (8000.0 / freq) ) )
|
float level = ( sin( (double) i * 2.0 * SGD_PI / (BYTES_PER_SECOND / freq) ) )
|
||||||
* ((double)j / trans_len) / 2.0 + 0.5;
|
* ((double)j / trans_len) / 2.0 + 0.5;
|
||||||
--j;
|
--j;
|
||||||
|
|
||||||
|
@ -165,8 +165,8 @@ bool FGMorse::cust_init(const int freq ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make a SGSimpleSound morse code transmission for the specified string
|
// make a SGSoundSample morse code transmission for the specified string
|
||||||
SGSimpleSound *FGMorse::make_ident( const string& id, const int freq ) {
|
SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
|
||||||
char *idptr = (char *)id.c_str();
|
char *idptr = (char *)id.c_str();
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
@ -260,7 +260,8 @@ SGSimpleSound *FGMorse::make_ident( const string& id, const int freq ) {
|
||||||
buf_ptr += SPACE_SIZE;
|
buf_ptr += SPACE_SIZE;
|
||||||
|
|
||||||
// 4. create the simple sound and return
|
// 4. create the simple sound and return
|
||||||
SGSimpleSound *sample = new SGSimpleSound( buffer, length );
|
SGSoundSample *sample = new SGSoundSample( buffer, length,
|
||||||
|
BYTES_PER_SECOND );
|
||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/sound/soundmgr.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
|
||||||
#include <plib/sl.h>
|
|
||||||
#include <plib/sm.h>
|
|
||||||
|
|
||||||
|
|
||||||
// Quoting from http://www.kluft.com/~ikluft/ham/morse-intro.html by
|
// Quoting from http://www.kluft.com/~ikluft/ham/morse-intro.html by
|
||||||
|
@ -88,7 +85,7 @@ static const char DA = '2';
|
||||||
static const char DAH = '2';
|
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 = 22050;
|
||||||
// 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);
|
||||||
|
@ -124,7 +121,7 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
// make a SimpleSound morse code transmission for the specified string
|
// make a SimpleSound morse code transmission for the specified string
|
||||||
SGSimpleSound *make_ident( const string& id,
|
SGSoundSample *make_ident( const string& id,
|
||||||
const int freq = LO_FREQUENCY );
|
const int freq = LO_FREQUENCY );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue