]> git.mxchange.org Git - flightgear.git/commitdiff
Changes to go along with small interface changes in simgear/sound/libsgsound
authorcurt <curt>
Sat, 24 Apr 2004 19:28:12 +0000 (19:28 +0000)
committercurt <curt>
Sat, 24 Apr 2004 19:28:12 +0000 (19:28 +0000)
(which is now written on top of OpenAL.)

17 files changed:
configure.ac
src/ATC/AIPlane.cxx
src/ATC/ATC.cxx
src/ATC/ATCVoice.cxx
src/ATC/ATCVoice.hxx
src/Cockpit/kr_87.cxx
src/Cockpit/marker_beacon.cxx
src/Cockpit/navcom.cxx
src/Main/Makefile.am
src/Main/fg_init.cxx
src/Main/fg_props.cxx
src/Sound/beacon.cxx
src/Sound/beacon.hxx
src/Sound/fg_fx.cxx
src/Sound/fg_fx.hxx
src/Sound/morse.cxx
src/Sound/morse.hxx

index a16421615d2732d5b2f07044c7df1e47b573c247..8ab5c3f992cb4d24affd5f3e2c908556dcd6b78b 100644 (file)
@@ -314,7 +314,21 @@ esac
 opengl_LIBS="$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(openal_LIBS)
 AC_SUBST(opengl_LIBS)
 AC_SUBST(thread_LIBS)
 AC_SUBST(network_LIBS)
index 32cea572b0138617807d0962ea3aec1468ddc4a7..a7f021c61279d1ec66875b2bd604fb776d920655 100644 (file)
@@ -22,7 +22,7 @@
 #include <Main/fg_props.hxx>
 #include <simgear/math/point3d.hxx>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/sound/soundmgr.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
 #include <math.h>
 #include <string>
 SG_USING_STD(string);
@@ -189,7 +189,7 @@ void FGAIPlane::Render(string refname, bool repeating) {
                int len;
                unsigned char* buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), len, 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 
                        // and can't be changed after the transmission has started.
                        simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
index ca6e99e30498e859d6e07d8ac65e57bdba9da2d9..f17700c675e38e9934bd8160c321607284364c3e 100644 (file)
@@ -22,7 +22,7 @@
 #  include <config.h>
 #endif
 
-#include <simgear/sound/soundmgr.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -223,7 +223,7 @@ void FGATC::Render(string msg, string refname, bool repeating) {
                int len;
                unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, 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 
                        // and can't be changed after the transmission has started.
                        simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
index 71d9f5fc8248545c2b94c9b053892266fed87ad9..6751f93e8d3f44df4db6250442190b573c966608 100644 (file)
@@ -37,21 +37,25 @@ 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).
 // Return true if successful.
 bool FGATCVoice::LoadVoice(string voice) {
+    // FIXME CLO: disabled to try to see if this is causign problemcs
+    // return false;
+
        ifstream fin;
 
        SGPath path = globals->get_fg_root();
-       string soundPath = "ATC/" + voice + ".wav";
-       path.append(soundPath);
+       path.append( "ATC" );
+
+        string file = voice + ".wav";
        
-       SoundData = new slSample( (char*)path.c_str() );
-       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();
        string wordPath = "ATC/" + voice + ".vce";
index 657e5ecb20301ec4cd761d933a0d1f3b606057af..9d9fb7d92be9e37625f279b84920ea42f02d0e5a 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef _FG_ATC_VOICE
 #define _FG_ATC_VOICE
 
-#include <plib/sl.h>
-
 #include <simgear/compiler.h>
 
 #if defined( SG_HAVE_STD_INCLUDES ) || defined( __BORLANDC__ ) || (__APPLE__)
@@ -37,6 +35,8 @@
 #include <list>
 #include <string>
 
+#include <simgear/sound/sample_openal.hxx>
+
 SG_USING_STD(map);
 SG_USING_STD(list);
 SG_USING_STD(string);
@@ -77,7 +77,7 @@ private:
        // the sound and word position data
        char* rawSoundData;
        unsigned int rawDataSize;
-       slSample* SoundData;
+        SGSoundSample *SoundData;
 
        // A map of words vs. byte position and length in rawSoundData
        atc_word_map_type wordMap;
index dc84a4592fd40a017bb1ad3fa14a3c3139a4b742..81c0224c0ab36a32cf1836b01c3835ee3281488b 100644 (file)
@@ -444,7 +444,7 @@ void FGKR_87::update( double dt ) {
        // play station ident via audio system if on + ant mode,
        // otherwise turn it off
        if ( vol_btn >= 0.01 && audio_btn ) {
-           SGSimpleSound *sound;
+           SGSoundSample *sound;
            sound = globals->get_soundmgr()->find( "adf-ident" );
             if ( sound != NULL ) {
                 if ( !adf_btn ) {
@@ -513,7 +513,7 @@ void FGKR_87::search() {
            if ( globals->get_soundmgr()->exists( "adf-ident" ) ) {
                globals->get_soundmgr()->remove( "adf-ident" );
            }
-           SGSimpleSound *sound;
+           SGSoundSample *sound;
            sound = morse.make_ident( trans_ident, LO_FREQUENCY );
            sound->set_volume( 0.3 );
            globals->get_soundmgr()->add( sound, "adf-ident" );
index 88e3e03708ca964299039485c412dbbe3a4baa4b..efe73b6640f03083328c422eb1ce1012473ea567 100644 (file)
@@ -192,7 +192,7 @@ void FGMarkerBeacon::search()
        // cout << "OUTER MARKER" << endl;
         if ( last_beacon != FGMkrBeacon::OUTER ) {
             if ( ! globals->get_soundmgr()->exists( "outer-marker" ) ) {
-                SGSimpleSound *sound = beacon.get_outer();
+                SGSoundSample *sound = beacon.get_outer();
                 sound->set_volume( 0.3 );
                 globals->get_soundmgr()->add( sound, "outer-marker" );
             }
@@ -209,7 +209,7 @@ void FGMarkerBeacon::search()
        // cout << "MIDDLE MARKER" << endl;
        if ( last_beacon != FGMkrBeacon::MIDDLE ) {
            if ( ! globals->get_soundmgr()->exists( "middle-marker" ) ) {
-               SGSimpleSound *sound = beacon.get_middle();
+               SGSoundSample *sound = beacon.get_middle();
                sound->set_volume( 0.3 );
                globals->get_soundmgr()->add( sound, "middle-marker" );
            }
@@ -226,7 +226,7 @@ void FGMarkerBeacon::search()
        // cout << "INNER MARKER" << endl;
        if ( last_beacon != FGMkrBeacon::INNER ) {
            if ( ! globals->get_soundmgr()->exists( "inner-marker" ) ) {
-               SGSimpleSound *sound = beacon.get_inner();
+               SGSoundSample *sound = beacon.get_inner();
                sound->set_volume( 0.3 );
                globals->get_soundmgr()->add( sound, "inner-marker" );
            }
index 03fae8220bb6208705746fd68b9849b8cba3df97..929f81191f0784a8baa7b752e6130fa11dae7227 100644 (file)
@@ -541,7 +541,7 @@ FGNavCom::update(double dt)
        if ( power_btn && (bus_power->getDoubleValue() > 1.0)
              && nav_ident_btn && audio_btn )
         {
-           SGSimpleSound *sound;
+           SGSoundSample *sound;
            sound = globals->get_soundmgr()->find( nav_fx_name );
             if ( sound != NULL ) {
                 sound->set_volume( nav_vol_btn );
@@ -653,7 +653,7 @@ void FGNavCom::search()
            if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
                globals->get_soundmgr()->remove( nav_fx_name );
            }
-           SGSimpleSound *sound;
+           SGSoundSample *sound;
            sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
            sound->set_volume( 0.3 );
            globals->get_soundmgr()->add( sound, nav_fx_name );
@@ -703,7 +703,7 @@ void FGNavCom::search()
            if ( globals->get_soundmgr()->exists( nav_fx_name ) ) {
                globals->get_soundmgr()->remove( nav_fx_name );
            }
-           SGSimpleSound *sound;
+           SGSoundSample *sound;
            sound = morse.make_ident( nav_trans_ident, LO_FREQUENCY );
            sound->set_volume( 0.3 );
            if ( globals->get_soundmgr()->add( sound, nav_fx_name ) ) {
index 774999354916014809bbb1c760a2d9e38ea3fd46..f3f801463425c20c392863be94f7b867046b02b3 100644 (file)
@@ -94,7 +94,7 @@ fgfs_LDADD = \
        $(network_LIBS) \
        -lz \
        $(opengl_LIBS) \
-       $(audio_LIBS)
+       $(openal_LIBS)
 
 metar_SOURCES = metar_main.cxx
 
index 6e1197735e764a2c002335a09dcd7c34cb0792ba..daf286844ff4f0b01a40919ba9c206c80f258c57 100644 (file)
@@ -1622,6 +1622,24 @@ bool fgInitSubsystems() {
     }
 #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
     ////////////////////////////////////////////////////////////////////
@@ -1646,7 +1664,6 @@ bool fgInitSubsystems() {
     globals->set_AI_mgr(new FGAIMgr);
     globals->get_AI_mgr()->init();
 
-
     ////////////////////////////////////////////////////////////////////
     // Initialise the AI Model Manager
     ////////////////////////////////////////////////////////////////////
@@ -1655,24 +1672,6 @@ bool fgInitSubsystems() {
     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("systems", new FGSystemMgr);
 
index 66a9086fb7b13e5c64472209e305280f597a4842..2c93ad36cb47de433224de253cadc54726b0239e 100644 (file)
@@ -29,7 +29,7 @@
 #include <simgear/timing/sg_time.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/matlib.hxx>
-#include <simgear/sound/soundmgr.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
 
 #include STL_IOSTREAM
 
index 3da3843f9f7f0997c693289f46876fa523f26672..6fad631e581a69a0e4d9a331f50eadaaf9f6ba0a 100644 (file)
@@ -51,7 +51,7 @@ bool FGBeacon::init() {
        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
     len= (int)(MIDDLE_DIT_LEN / 2.0 );
@@ -69,7 +69,7 @@ bool FGBeacon::init() {
     ptr += MIDDLE_DIT_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
     len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 );
@@ -82,7 +82,7 @@ bool FGBeacon::init() {
     ptr += 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;
 }
index 3b9a6e3c026697b77a9d66faef0ac533148aaa14..6d680762239f3daf536d7186e3586103bb253256 100644 (file)
@@ -31,7 +31,7 @@
 #endif
 
 #include <simgear/compiler.h>
-#include <simgear/sound/soundmgr.hxx>
+#include <simgear/sound/soundmgr_openal.hxx>
 
 #include <plib/sl.h>
 #include <plib/sm.h>
@@ -100,9 +100,9 @@ private:
     unsigned char middle_buf[ MIDDLE_SIZE ] ;
     unsigned char outer_buf[ OUTER_SIZE ] ;
 
-    SGSimpleSound *inner;
-    SGSimpleSound *middle;
-    SGSimpleSound *outer;
+    SGSoundSample *inner;
+    SGSoundSample *middle;
+    SGSoundSample *outer;
 
 public:
 
@@ -112,9 +112,9 @@ public:
     // allocate and initialize sound samples
     bool init();
 
-    SGSimpleSound *get_inner() { return inner; }
-    SGSimpleSound *get_middle() { return middle; }
-    SGSimpleSound *get_outer() { return outer; }
+    SGSoundSample *get_inner() { return inner; }
+    SGSoundSample *get_middle() { return middle; }
+    SGSoundSample *get_outer() { return outer; }
    
 };
 
index 93e8b779b770ac61e256ec4c6e93c633e2d674f7..6b1a16eb3e897410b9d415926a4f6f0eba0892c5 100644 (file)
@@ -32,7 +32,7 @@
 #endif
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/props/props.hxx>
-#include <simgear/sound/sound.hxx>
+#include <simgear/sound/xmlsound.hxx>
 
 #include <Main/fg_props.hxx>
 
@@ -76,7 +76,7 @@ FGFX::init()
 
    node = root.getNode("fx");
    for (i = 0; i < node->nChildren(); i++) {
-      SGSound *sound = new SGSound();
+      SGXmlSound *sound = new SGXmlSound();
 
       sound->init(globals->get_props(), node->getChild(i),
                   globals->get_soundmgr(), globals->get_fg_root());
index 0cc29dc393ac10aab3b2e4fded1ad203006e8dc4..5c43db42d2d3403372548b120db5a33d0ac1cabc 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <simgear/structure/subsystem_mgr.hxx>
 
-class SGSound;
+class SGXmlSound;
 
 /**
  * Generator for FlightGear sound effects.
@@ -51,7 +51,7 @@ public:
 
 private:
 
-  vector<SGSound *> _sound;
+  vector<SGXmlSound *> _sound;
 
 };
 
index aaec7f50ef724d3b74aa5421b20ebd9c82621778..ef0b43fa7da6ec1fccbdb0f5314c25e16ba2db0d 100644 (file)
@@ -87,7 +87,7 @@ void make_tone( unsigned char *buf, int freq,
     int i, j;
 
     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;
 
        /* 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 ) {
-       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;
 
        /* Convert to unsigned byte */
@@ -103,7 +103,7 @@ void make_tone( unsigned char *buf, int freq,
     }
     j = trans_len;
     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;
        --j;
 
@@ -165,8 +165,8 @@ bool FGMorse::cust_init(const int freq ) {
 }
 
 
-// make a SGSimpleSound morse code transmission for the specified string
-SGSimpleSound *FGMorse::make_ident( const string& id, const int freq ) {
+// make a SGSoundSample morse code transmission for the specified string
+SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
     char *idptr = (char *)id.c_str();
 
     int length = 0;
@@ -260,7 +260,8 @@ SGSimpleSound *FGMorse::make_ident( const string& id, const int freq ) {
     buf_ptr += SPACE_SIZE;
 
     // 4. create the simple sound and return
-    SGSimpleSound *sample = new SGSimpleSound( buffer, length );
+    SGSoundSample *sample = new SGSoundSample( buffer, length,
+                                               BYTES_PER_SECOND );
 
     return sample;
 }
index 6166e747586ebe40dc4c383671bc0af5e3b8e2a2..bd0f1aec18d4e5970a2489441607b1b348b367db 100644 (file)
 #endif
 
 #include <simgear/compiler.h>
-#include <simgear/sound/soundmgr.hxx>
-
-#include <plib/sl.h>
-#include <plib/sm.h>
+#include <simgear/sound/soundmgr_openal.hxx>
 
 
 // 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 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 = 92;  // milleseconds (13 wpm)
 static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
@@ -124,8 +121,8 @@ public:
     bool init();
 
     // make a SimpleSound morse code transmission for the specified string
-    SGSimpleSound *make_ident( const string& id,
-                              const int freq = LO_FREQUENCY );
+    SGSoundSample *make_ident( const string& id,
+                               const int freq = LO_FREQUENCY );
 };